Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
- Authentication authentication) throws IOException, ServletException {
- clearAuthenticationAttributes(request);
- }
- public List<GrantedAuthority> getUserAuthorities() {
- Object principals = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- //Тут нужна эта проверка тк если сразу получить principals без проверки
- //На анонимность пользавателя можем получим NullPointerException
- if (!principals.toString().equals("anonymousUser")) {
- org.springframework.security.core.userdetails.User u =
- (org.springframework.security.core.userdetails.User)
- principals;
- List<GrantedAuthority> authorities = new LinkedList();
- authorities.addAll(u.getAuthorities());
- return authorities;
- }
- return new List();
- }
- @Override
- public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
- Authentication authentication) throws IOException, ServletException {
- for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) {
- String authority = grantedAuthority.getAuthority();
- }
- clearAuthenticationAttributes(request);
- }
Add Comment
Please, Sign In to add comment