Class 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.

    • Constructor Detail

      • SimpleAttributes2GrantedAuthoritiesMapper

        public SimpleAttributes2GrantedAuthoritiesMapper()
    • Method Detail

      • 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 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:
        getGrantedAuthorities in interface Attributes2GrantedAuthoritiesMapper
        attributes - the attributes to be mapped
        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)