SecurityContextHolder 中,供當前請求的上下文作用(當前API)。public interface UserDetails extends Serializable {
Collection<? extends GrantedAuthority> getAuthorities();
String getPassword();
String getUsername();
boolean isAccountNonExpired();
// 帳號是否鎖住了? 像是密碼輸錯過多次等
boolean isAccountNonLocked();
boolean isCredentialsNonExpired();
boolean isEnabled();
}
loadUserByUsername 作為標準取得資料庫中User的途徑!AuthenticationManager!PasswordEncoder 比對明文與加密密碼比對驗證過後,給出一個 UsernamePasswordAuthenticationToken 作為Authentication物件,最後再存入SecurityContextHolder!本篇文章出自《每天學Java直到今年結束》Day228,大家可以到我的網站上查看~