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 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 Details

    • SimpleAttributes2GrantedAuthoritiesMapper

      public SimpleAttributes2GrantedAuthoritiesMapper()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Check whether all properties have been set to correct values.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • getGrantedAuthorities

      public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes)
      Map the given list of string attributes one-to-one to Spring Security GrantedAuthorities.
      Specified by:
      getGrantedAuthorities in interface Attributes2GrantedAuthoritiesMapper
      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(String string)
    • setAddPrefixIfAlreadyExisting

      public void setAddPrefixIfAlreadyExisting(boolean b)