LOGGER.log(Level.FINE, "Auth request with {0}", authentication);
if (authentication instanceof UsernamePasswordAuthenticationToken) {
UsernamePasswordAuthenticationToken inTok = (UsernamePasswordAuthenticationToken)authentication;
AuthUser authUser = null;
try {
authUser = ruleReaderService.authorize(
inTok.getPrincipal().toString(),
inTok.getCredentials().toString());
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error in authenticating with GeoFence", e);
throw new AuthenticationException("Error in GeoFence communication", e) {};
}
if(authUser != null) {
LOGGER.log(Level.FINE, "User {0} authenticated: {1}", new Object[]{inTok.getPrincipal(), authUser});
List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
roles.addAll(inTok.getAuthorities());
roles.add(GeoServerRole.AUTHENTICATED_ROLE);
if(authUser.getRole() == AuthUser.Role.ADMIN) {
roles.add(GeoServerRole.ADMIN_ROLE);
roles.add(new SimpleGrantedAuthority("ADMIN")); // needed for REST?!?
}
outTok = new UsernamePasswordAuthenticationToken(