July 2018
Intermediate to advanced
268 pages
7h 36m
English
AuthorityGranter is entrusted to provide relevant roles to the authenticated user. We will be creating our own custom class by implementing org.springframework.security.authentication.jaas.AuthorityGranter:
public class JaasAuthorityGranter implements AuthorityGranter { @Override public Set<String> grant(Principal principal) { if (principal.getName().equalsIgnoreCase("Authenticated_admin")) { return Collections.singleton("ROLE_ADMIN"); } else if (principal.getName().equalsIgnoreCase("Authenticated_user")) { return Collections.singleton("ROLE_USER"); } return Collections.singleton("ROLE_USER"); }}
Being a sample implementation, in this class, we look at the logged in users username and grant a hard-coded ...
Read now
Unlock full access