私はSpringとSpringのセキュリティに比較的慣れていません。
Spring セキュリティを使用してサーバー側でユーザーを認証する必要があるプログラムを作成しようとしていましたが、
私は次のことを思いつきました:
public class CustomAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider{
@Override
protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken)
throws AuthenticationException
{
System.out.println("Method invoked : additionalAuthenticationChecks isAuthenticated ? :"+usernamePasswordAuthenticationToken.isAuthenticated());
}
@Override
protected UserDetails retrieveUser(String username,UsernamePasswordAuthenticationToken authentication) throws AuthenticationException
{
System.out.println("Method invoked : retrieveUser");
//so far so good, i can authenticate user here, and throw exception if not authenticated!!
//THIS IS WHERE I WANT TO ACCESS SESSION OBJECT
}
}
私のユースケースは、ユーザーが認証されたときに、次のような属性を配置する必要があるということです:
session.setAttribute("userObject", myUserObject);
myUserObject は、サーバー コード全体で複数のユーザー リクエストにアクセスできるクラスのオブジェクトです。