Class SimpleAttributes2GrantedAuthoritiesMapper
- java.lang.Object
-
- org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper
-
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean,Attributes2GrantedAuthoritiesMapper
public class SimpleAttributes2GrantedAuthoritiesMapper extends java.lang.Object implements Attributes2GrantedAuthoritiesMapper, org.springframework.beans.factory.InitializingBean
This class implements the Attributes2GrantedAuthoritiesMapper interface by doing a one-to-one mapping from roles to Spring Security GrantedAuthorities. Optionally a prefix can be added, and the attribute name can be converted to upper or lower case.
By default, the attribute is prefixed with "ROLE_" unless it already starts with "ROLE_", and no case conversion is done.
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description SimpleAttributes2GrantedAuthoritiesMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Check whether all properties have been set to correct values.java.util.List<GrantedAuthority>getGrantedAuthorities(java.util.Collection<java.lang.String> attributes)Map the given list of string attributes one-to-one to Spring Security GrantedAuthorities.voidsetAddPrefixIfAlreadyExisting(boolean b)voidsetAttributePrefix(java.lang.String string)voidsetConvertAttributeToLowerCase(boolean b)voidsetConvertAttributeToUpperCase(boolean b)
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet()
Check whether all properties have been set to correct values.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
getGrantedAuthorities
public java.util.List<GrantedAuthority> getGrantedAuthorities(java.util.Collection<java.lang.String> attributes)
Map the given list of string attributes one-to-one to Spring Security GrantedAuthorities.- Specified by:
getGrantedAuthoritiesin interfaceAttributes2GrantedAuthoritiesMapper- Parameters:
attributes- the attributes to be mapped- Returns:
- the collection of authorities created from the attributes
-
setConvertAttributeToLowerCase
public void setConvertAttributeToLowerCase(boolean b)
-
setConvertAttributeToUpperCase
public void setConvertAttributeToUpperCase(boolean b)
-
setAttributePrefix
public void setAttributePrefix(java.lang.String string)
-
setAddPrefixIfAlreadyExisting
public void setAddPrefixIfAlreadyExisting(boolean b)
-
-