List of usage examples for org.springframework.security.authentication UsernamePasswordAuthenticationToken getAuthorities
public Collection<GrantedAuthority> getAuthorities()
From source file:org.geoserver.security.iride.IrideAuthenticationProvider.java
/** * Returns the {@link UsernamePasswordAuthenticationToken} token. * * @param auth the {@link UsernamePasswordAuthenticationToken} token * @return the {@link UsernamePasswordAuthenticationToken} token * @see UsernamePasswordAuthenticationProvider#authenticate(Authentication, HttpServletRequest) *//* ww w. jav a2 s . c o m*/ private UsernamePasswordAuthenticationToken buildAuthenticationToken(UsernamePasswordAuthenticationToken auth) { if (auth == null) { // pass request to next provider in the chain return null; } if (!auth.getAuthorities().contains(GeoServerRole.AUTHENTICATED_ROLE)) { final List<GrantedAuthority> roles = new ArrayList<>(); roles.addAll(auth.getAuthorities()); roles.add(GeoServerRole.AUTHENTICATED_ROLE); final UsernamePasswordAuthenticationToken newAuth = new UsernamePasswordAuthenticationToken( auth.getPrincipal(), auth.getCredentials(), roles); newAuth.setDetails(auth.getDetails()); return newAuth; } return auth; }