Class UserGroupLdapAuthoritiesPopulator

  • All Implemented Interfaces:
    org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator

    public class UserGroupLdapAuthoritiesPopulator
    extends org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator
    implements org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator
    This class adds the ability to provide a concrete map of associations between specific group values and roles. These associations can be provided by setting the groupToRoleMap property either in a Spring context file or by calling setGroupToRoleMap(Map).
    • Constructor Detail

      • UserGroupLdapAuthoritiesPopulator

        public UserGroupLdapAuthoritiesPopulator​(org.springframework.ldap.core.ContextSource contextSource,
                                                 String groupSearchBase)
    • Method Detail

      • getAdditionalRoles

        protected Set<org.springframework.security.core.GrantedAuthority> getAdditionalRoles​(org.springframework.ldap.core.DirContextOperations user,
                                                                                             String username)
        This function returns a list of roles from the given set of groups based on the value of the groupToRoleMap property.
        Overrides:
        getAdditionalRoles in class org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator
        Returns:
        a Set object.
      • setGroupRoleAttribute

        public void setGroupRoleAttribute​(String groupRoleAttribute)
        Overrides:
        setGroupRoleAttribute in class org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator
      • setGroupSearchFilter

        public void setGroupSearchFilter​(String groupSearchFilter)
        Overrides:
        setGroupSearchFilter in class org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator
      • setGroupToRoleMap

        public void setGroupToRoleMap​(Map<String,​List<String>> groupToRoleMap)

        This property contains a set of group to role mappings. Both values are specified as string values.

        An example Spring context that sets this property could be:

         
         <property xmlns="http://www.springframework.org/schema/beans" name="groupToRoleMap">
           <map>
             <entry>
               <key><value>CompanyX_OpenNMS_User_Group</value></key>
               <list>
                 <value>ROLE_USER</value>
               </list>
             </entry>
           </map> 
         </property>
         
         
      • setSearchSubtree

        public void setSearchSubtree​(boolean searchSubtree)
        Overrides:
        setSearchSubtree in class org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator