use of ai.elimu.model.enums.Role in project webapp by elimu-ai.
the class CustomAuthenticationManager method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
logger.info("authenticate");
logger.info("authentication.getName(): " + authentication.getName());
Contributor contributor = (Contributor) authentication.getPrincipal();
logger.info("contributor: " + contributor);
logger.info("contributor.getRoles(): " + contributor.getRoles());
for (Role role : contributor.getRoles()) {
AUTHORITIES.add(new SimpleGrantedAuthority("ROLE_" + role.toString()));
}
return new UsernamePasswordAuthenticationToken(authentication.getName(), authentication.getCredentials(), AUTHORITIES);
}
Aggregations