あなたは間違いなくUserDetailService
あなた自身を記述する必要があります。プリンシパルオブジェクトにはユーザがあり、AuthenticationToken
には他のログイン情報のMap(String、String)を格納できるDetailsオブジェクトもあります。
public class RequestFormDeatils extends SpringSecurityFilter {
protected void doFilterHttp(HttpServletRequest request, ...) {
SecurityContext sec = SecurityContextHolder.getContent();
AbstractAuthenticationToken auth = (AbstractAuthenticationToken)sec.getAuthentication();
Map<String, String> m = new HashMap<String, String>;
m.put("myCustom1", request.getParameter("myCustom1"));
m.put("myCustom2", request.getParameter("myCustom2"));
auth.setDetails(m);
}
今、どこでも、あなたのコードの中で、あなたのUserDetails
オブジェクトに結合するために、それをせずに、このセキュリティ関連の情報を伝播し、または引数として渡すためにSecurityContext
を使用して取得します。私はこのコードをSpring Security Filterチェーンの最後にあるSecurityFilter
で行っています。
<bean id="requestFormFilter" class="...RequestFormDetails">
<custom-filter position="LAST" />
</bean>
この情報は、ユーザーが削除されると(ログアウト時など)削除されます。
誰かが私が聞きたい正確に何を尋ねられたとき、私は大好きです! – Adelin