Class BearerAuthorities
java.lang.Object
com.irurueta.authserver.resourceserver.api.web.security.BearerAuthorities
Maps the
roles claim of a token onto authorities, for both JWT and opaque tokens.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateUtility class: not meant to be instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAdministrator(org.springframework.security.core.Authentication authentication) Tells whether the caller is an administrator.static Collection<org.springframework.security.core.GrantedAuthority> roleAuthorities(Collection<String> roles) Maps role names to authorities, adding theROLE_prefix when it is missing.
-
Field Details
-
ROLES_CLAIM
Name of the claim that carries the roles.- See Also:
-
ADMIN_ROLE
Authority of an administrator.- See Also:
-
ROLE_PREFIX
Prefix of a role authority.- See Also:
-
-
Constructor Details
-
BearerAuthorities
private BearerAuthorities()Utility class: not meant to be instantiated.
-
-
Method Details
-
roleAuthorities
public static Collection<org.springframework.security.core.GrantedAuthority> roleAuthorities(Collection<String> roles) Maps role names to authorities, adding theROLE_prefix when it is missing.- Parameters:
roles- role names; may benull.- Returns:
- the role authorities, empty when there are no roles.
-
isAdministrator
public static boolean isAdministrator(org.springframework.security.core.Authentication authentication) Tells whether the caller is an administrator.- Parameters:
authentication- the authenticated caller.- Returns:
truewhen it holdsROLE_ADMIN.
-