1 2 3 4 | public interface SecurityContext extends Serializable { Authentication getAuthentication(); void setAuthentication(Authentication authentication); } |
1 2 3 4 5 6 7 8 | public interface Authentication extends Principal, Serializable { Collection<? extends GrantedAuthority> getAuthorities(); Object getCredentials(); Object getDetails(); Object getPrincipal(); boolean isAuthenticated(); void setAuthenticated(boolean isAuthenticated); } |
1 2 3 4 5 6 7 8 9 | public interface UserDetails extends Serializable { Collection<? extends GrantedAuthority> getAuthorities(); String getPassword(); String getUsername(); boolean isAccountNonExpired(); boolean isAccountNonLocked(); boolean isCredentialsNonExpired(); boolean isEnabled(); } |
1 | Authentication authenticate(Authentication authentication)throws AuthenticationException; |
1 2 3 4 5 6 7 8 | AuthenticationManager amanager = new CustomAuthenticationManager(); Authentication namePwd = new CustomAuthentication(“name”, “password”); try { Authentication result = amanager.authenticate(namePwd); SecurityContextHolder.getContext.setAuthentication(result); } catch(AuthenticationException e) { // TODO 验证失败 } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |