gwt + spring security
I use gwt requestBuilder to query server result, if server-side spring checked user is not authenticated, it will forward to
<form-login
login-page="/gwtapplication.html#!login"
, but gwt is not forwarded to that page. see below
requestBuilder.setCallback(new RequestCallback() {
@Override
public void onError(final Request request, final Throwable
exception) {
resultCallback.onFailure(exception);
}
@Override
public void onResponseReceived(final Request request,
final Response response) {
if(response.getHeader("Content-
Type").toLowerCase().equals("text/html".toLowerCase()))
{
//response.getText() is
/**
Expires Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie JSESSIONID=1emk892yva1e9;Path=/
Location http://127.0.0.1:8888/gwtapplication.html#!login
Content-Length 0
开发者_运维技巧 Server Jetty(6.1.x)
**/
}
}
});
The call RequestBuilder performs is intecepted by spring security and redirected to the authentication page instead of the normal
result. Because RequestBuilder is not asking for a new version of your GWT page, but a separate
page, this has no effect on redirecting your GWT page. Just like an image would be retrieved in the src
tag, which instead of the image returned the authentication page would be returned. If you want to redirect upon RequestBuilder results you would have to do this in GWT by yourself, by setting a new HistoryItem to the !login
token.
精彩评论