Я использую код из этой статьи: http://www.javacodegeeks.com/2010/12/securing-gwt-apps-with-spring-security.html
По сути, вы реализуете интерфейс Spring
org.springframework.security.authentication.AuthenticationProvider
, который имеет authenticate (Authentication) метод.Вы получаете имя пользователя и пароль, введенные пользователем в этом методе с помощью:
String username = (String) authentication.getPrincipal();
String password = (String) authentication.getCredentials();
// now try to get the user from your DB
User user = db.getUser(username, password);
, а в контексте Spring вы настраиваете фильтр безопасности Spring (см. Ссылку) и объявляете свой AuthenticationProvider:
<bean id="authProvider" class="com.example.security.MyAuthenticationProvider" />
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider ref="authProvider" />
</security:authentication-manager>
Я вообще не использую GWT для входа в систему ... просто обычная страница JSP .... вы можете увидеть пример страницы входа в систему JSP (и ссылку выхода из системы) здесь Когда пользователь входит в систему, загружается приложение GWT.Чтобы выйти, просто сделайте что-то вроде:
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "/j_spring_security_logout");
try {
rb.sendRequest(null, new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
GWT.log("Logged user out: " + response.getStatusText());
}
public void onError(Request request, Throwable caught) {
// try to recover somehow
}
});
} catch (RequestException re) {
someOtherLogoutMechanism();
}