Class SimpleAuthorityMapper
java.lang.Object
org.springframework.security.core.authority.mapping.SimpleAuthorityMapper
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean,GrantedAuthoritiesMapper
public final class SimpleAuthorityMapper
extends Object
implements GrantedAuthoritiesMapper, org.springframework.beans.factory.InitializingBean
Simple one-to-one
GrantedAuthoritiesMapper which allows for case conversion of
the authority name and the addition of a string prefix (which defaults to ROLE_
).- Since:
- 3.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidmapAuthorities(Collection<? extends GrantedAuthority> authorities) Creates a mapping of the supplied authorities based on the case-conversion and prefix settings.voidsetConvertToLowerCase(boolean convertToLowerCase) Whether to convert the authority value to lower case in the mapping.voidsetConvertToUpperCase(boolean convertToUpperCase) Whether to convert the authority value to upper case in the mapping.voidsetDefaultAuthority(String authority) Sets a default authority to be assigned to all usersvoidSets the prefix which should be added to the authority name (if it doesn't already exist)
-
Constructor Details
-
SimpleAuthorityMapper
public SimpleAuthorityMapper()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
mapAuthorities
Creates a mapping of the supplied authorities based on the case-conversion and prefix settings. The mapping will be one-to-one unless duplicates are produced during the conversion. If a default authority has been set, this will also be assigned to each mapping.- Specified by:
mapAuthoritiesin interfaceGrantedAuthoritiesMapper- Parameters:
authorities- the original authorities- Returns:
- the converted set of authorities
-
setPrefix
Sets the prefix which should be added to the authority name (if it doesn't already exist)- Parameters:
prefix- the prefix, typically to satisfy the behaviour of anAccessDecisionVoter.
-
setConvertToUpperCase
public void setConvertToUpperCase(boolean convertToUpperCase) Whether to convert the authority value to upper case in the mapping.- Parameters:
convertToUpperCase- defaults tofalse
-
setConvertToLowerCase
public void setConvertToLowerCase(boolean convertToLowerCase) Whether to convert the authority value to lower case in the mapping.- Parameters:
convertToLowerCase- defaults tofalse
-
setDefaultAuthority
Sets a default authority to be assigned to all users- Parameters:
authority- the name of the authority to be assigned to all users.
-