UsernamePasswordAuthenticationFilter
是 AbstractAuthenticationProcessingFilter
的子類,主要作用是對用戶身份信息的驗證。
關於 AbstractAuthenticationProcessingFilter
的分析見此:
AbstractAuthenticationProcessingFilter 源碼解析
繼承關係
UsernamePasswordAuthenticationFilter
繼承自AbstractAuthenticationProcessingFilter
。
public class UsernamePasswordAuthenticationFilter extends
AbstractAuthenticationProcessingFilter {
sernamePasswordAuthenticationFilter
實現的父類方法 attemptAuthentication()
中的用戶身份驗證邏輯。
- 1,2兩個代碼是從request中提取用戶名稱和密碼
- 3 代碼爲構造
UsernamePasswordAuthenticationToken
對象,其繼承AbstractAuthenticationToken,AbstractAuthenticationToken 實現了Authentication,它是用戶信息的載體,從來存儲和傳遞用戶名稱和密碼。 - 4 代碼調用了this.getAuthenticationManager()方法或AuthenticationManager實例,
-
protected AuthenticationManager getAuthenticationManager() { return this.authenticationManager; }