Class SearchDnResolver

    • Field Detail

      • baseDn

        private String baseDn
        DN to search.
      • userFilter

        private String userFilter
        Filter for searching for the user.
      • userFilterParameters

        private Object[] userFilterParameters
        Filter parameters for searching for the user.
      • allowMultipleDns

        private boolean allowMultipleDns
        Whether to throw an exception if multiple DNs are found.
      • subtreeSearch

        private boolean subtreeSearch
        Whether to use a subtree search when resolving DNs.
      • derefAliases

        private DerefAliases derefAliases
        How to handle aliases.
      • resolveFromAttribute

        private String resolveFromAttribute
        Resolve DN from alternative attribute name
    • Constructor Detail

      • SearchDnResolver

        public SearchDnResolver()
        Default constructor.
      • SearchDnResolver

        public SearchDnResolver​(ConnectionFactory cf)
        Creates a new search dn resolver.
        Parameters:
        cf - connection factory
    • Method Detail

      • getBaseDn

        public String getBaseDn()
        Returns the base DN.
        Returns:
        base DN
      • setBaseDn

        public void setBaseDn​(String dn)
        Sets the base DN.
        Parameters:
        dn - base DN
      • getUserFilter

        public String getUserFilter()
        Returns the filter used to search for the user.
        Returns:
        filter for searching
      • setUserFilter

        public void setUserFilter​(String filter)
        Sets the filter used to search for the user.
        Parameters:
        filter - user filter
      • getUserFilterParameters

        public Object[] getUserFilterParameters()
        Returns the filter parameters used to search for the user.
        Returns:
        filter parameters
      • setUserFilterParameters

        public void setUserFilterParameters​(Object[] filterParams)
        Sets the filter parameters used to search for the user.
        Parameters:
        filterParams - filter parameters
      • getAllowMultipleDns

        public boolean getAllowMultipleDns()
        Returns whether DN resolution should fail if multiple DNs are found.
        Returns:
        whether an exception will be thrown if multiple DNs are found
      • setAllowMultipleDns

        public void setAllowMultipleDns​(boolean b)
        Sets whether DN resolution should fail if multiple DNs are found. If false an exception will be thrown if resolve(User) finds more than one DN matching its filter. Otherwise, the first DN found is returned.
        Parameters:
        b - whether multiple DNs are allowed
      • getSubtreeSearch

        public boolean getSubtreeSearch()
        Returns whether subtree searching will be used.
        Returns:
        whether the DN will be searched for over the entire base
      • setSubtreeSearch

        public void setSubtreeSearch​(boolean b)
        Sets whether subtree searching will be used. If true, the DN used for authenticating will be searched for over the entire getBaseDn(). Otherwise, the DN will be searched for in the getBaseDn() context.
        Parameters:
        b - whether the DN will be searched for over the entire base
      • getDerefAliases

        public DerefAliases getDerefAliases()
        Returns how to dereference aliases.
        Returns:
        how to dereference aliases
      • setDerefAliases

        public void setDerefAliases​(DerefAliases da)
        Sets how to dereference aliases.
        Parameters:
        da - how to dereference aliases
      • getResolveFromAttribute

        public String getResolveFromAttribute()
        Gets an attribute to use to resolve the DN, if the attribute is not present the resolution fails back on the entry's DN.
        Returns:
        the attribute name
      • setResolveFromAttribute

        public void setResolveFromAttribute​(String attributeName)
        Sets the attribute to use to resolve the DN. If null, the resolver will use the entry's DN.
        Parameters:
        attributeName - attribute name
      • resolveDn

        protected String resolveDn​(LdapEntry entry)
        Returns the DN for the supplied ldap entry.
        Parameters:
        entry - to retrieve the DN from
        Returns:
        dn
      • performResolveFromAttribute

        protected String performResolveFromAttribute​(LdapEntry entry)
        Resolve DN from attribute in the resolveFromAttribute property.
        Parameters:
        entry - containing an attribute with the DN
        Returns:
        first and singled value in resolveFromAttribute, or null if not valid
      • createFilterTemplate

        protected FilterTemplate createFilterTemplate​(User user)
        Returns a filter template using userFilter and userFilterParameters. The user parameter is injected as a named parameter of 'user'.
        Parameters:
        user - to resolve DN
        Returns:
        filter template
      • createSearchRequest

        protected SearchRequest createSearchRequest​(FilterTemplate template)
        Returns a search request for searching for a single entry in an LDAP, returning no attributes.
        Parameters:
        template - to execute
        Returns:
        search request
      • performLdapSearch

        protected SearchResponse performLdapSearch​(FilterTemplate template)
                                            throws LdapException
        Executes the ldap search operation with the supplied filter.
        Parameters:
        template - to execute
        Returns:
        ldap search result
        Throws:
        LdapException - if an error occurs