我有一個定製的彈簧AuthenticationProvider
類,但嘗試攔截loadUserDetails
方法中的HTTPServletRequest
和HTTPServletResponse
。在loadUserDetails方法中捕獲httpServeletRequest
@Component("darnGoodAuthenticaionProvider")
public class DarnGoodAuthenticaionProvider
extends HandlerInterceptorAdapter
implements AuthenticationUserDetailsService {
private HttpServletRequest request;
private HttpServletResponse response;
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler)
throws Exception {
this.request = request;
this.response = response;
// we don't want anything falling here
return true;
}
@Override
public UserDetails loadUserDetails(Authentication token)throws
UsernameNotFoundException{
.......
}
}
我知道,從HandlerIntercepterAdapter
的preHandler
方法能夠給工作,但我怎麼能肯定的是,preHandler
方法之前loadUserDetails
調用,這樣我就可以得到請求和響應準備?
由於
'DarnGoodAuthenticaionProvider'拼寫錯誤:) –
@Sotirios Delimanolis我不這麼認爲,我用城市詞典:d – Dreamer