public Authentication authenticate( UserDetails principal, String credentials, List<GrantedAuthority> authorities) { Authentication authentication = new TestingAuthenticationToken(principal, credentials, authorities); authentication.setAuthenticated(true); SecurityContextHolder.getContext().setAuthentication(authentication); return authentication; }
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { UserDetails details = (UserDetails) authentication.getPrincipal(); if (details.getPassword() == null || details.getPassword().isEmpty()) { authentication.setAuthenticated(true); } final Collection<SimpleGrantedAuthority> authorities = (Collection<SimpleGrantedAuthority>) authentication.getAuthorities(); authorities.clear(); authorities.add(new SimpleGrantedAuthority("NOT_VALIDATED")); return authentication; }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { logger.info("authenticate() enter: " + authentication); Authentication result = authentication; if (useAuthCopy) result = new UsernamePasswordAuthenticationToken( authentication.getPrincipal(), authentication.getCredentials(), authentication.getAuthorities()); if (!result.isAuthenticated()) result.setAuthenticated(true); logger.info("authenticate() finished: " + result); return result; }