LoginBean
認証情報が有効かどうかを示す ajax コールバック パラメータを返す特定の を呼び出すログイン フォームがあります。コードは次のとおりです。
public void doLogin() {
Authentication authenticationRequestToken =
new UsernamePasswordAuthenticationToken(user, password);
try {
Authentication authenticationResponseToken =
authenticationManager.authenticate(authenticationRequestToken);
SecurityContextHolder.getContext().
setAuthentication(authenticationResponseToken);
if (authenticationResponseToken.isAuthenticated()) {
RequestContext context = RequestContext.getCurrentInstance();
FacesMessage msg;
boolean loggedIn = true;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", user);
FacesContext.getCurrentInstance().addMessage(null, msg);
context.addCallbackParam("loggedIn", loggedIn);
}
} .authenticate(...) catches ...
// Here I need some code that continue whatever j_spring_security_check
// would do after authenticating.
}
私のアプリケーションが現在動作している方法では、この への呼び出しの後doLogin()
、フォームが に送信されj_spring_security_check
、認証プロセスが再び行われ、前の作業が無駄になります。私はこれに対する解決策を見つけようとしています。
つまり、フィルターによってインターセプトされたときに何が起こるかをシミュレートするものj_spring_security_check
(またはこのインターセプトを明示的に強制する方法) が必要なので、フォームが送信された後ではなく、ボタンの後ろで処理が行われます。