Class LDAPURL


  • @PublicAPI(stability=UNCOMMITTED,
               mayInstantiate=true,
               mayExtend=false,
               mayInvoke=true)
    public final class LDAPURL
    extends Object
    This class defines a data structure that represents the components of an LDAP URL, including the scheme, host, port, base DN, attributes, scope, filter, and extensions. It has the ability to create an LDAP URL based on all of these individual components, as well as parsing them from their string representations.
    • Field Detail

      • DEFAULT_SCHEME

        public static final String DEFAULT_SCHEME
        The default scheme that will be used if none is provided.
        See Also:
        Constant Field Values
      • DEFAULT_SEARCH_FILTER

        public static final SearchFilter DEFAULT_SEARCH_FILTER
        The default search filter that will be used if none is provided.
    • Constructor Detail

      • LDAPURL

        public LDAPURL​(String scheme,
                       String host,
                       int port,
                       String rawBaseDN,
                       LinkedHashSet<String> attributes,
                       SearchScope scope,
                       String rawFilter,
                       List<String> extensions)
        Creates a new LDAP URL with the provided information.
        Parameters:
        scheme - The scheme (i.e., protocol) for this LDAP URL.
        host - The address for this LDAP URL.
        port - The port number for this LDAP URL.
        rawBaseDN - The raw base DN for this LDAP URL.
        attributes - The set of requested attributes for this LDAP URL.
        scope - The search scope for this LDAP URL.
        rawFilter - The string representation of the search filter for this LDAP URL.
        extensions - The set of extensions for this LDAP URL.
      • LDAPURL

        public LDAPURL​(String scheme,
                       String host,
                       int port,
                       DN baseDN,
                       LinkedHashSet<String> attributes,
                       SearchScope scope,
                       SearchFilter filter,
                       List<String> extensions)
        Creates a new LDAP URL with the provided information.
        Parameters:
        scheme - The scheme (i.e., protocol) for this LDAP URL.
        host - The address for this LDAP URL.
        port - The port number for this LDAP URL.
        baseDN - The base DN for this LDAP URL.
        attributes - The set of requested attributes for this LDAP URL.
        scope - The search scope for this LDAP URL.
        filter - The search filter for this LDAP URL.
        extensions - The set of extensions for this LDAP URL.
    • Method Detail

      • decode

        public static LDAPURL decode​(String url,
                                     boolean fullyDecode)
                              throws DirectoryException
        Decodes the provided string as an LDAP URL.
        Parameters:
        url - The URL string to be decoded.
        fullyDecode - Indicates whether the URL should be fully decoded (e.g., parsing the base DN and search filter) or just leaving them in their string representations. The latter may be required for client-side use.
        Returns:
        The LDAP URL decoded from the provided string.
        Throws:
        DirectoryException - If a problem occurs while attempting to decode the provided string as an LDAP URL.
      • getScheme

        public String getScheme()
        Retrieves the scheme for this LDAP URL.
        Returns:
        The scheme for this LDAP URL.
      • setScheme

        public void setScheme​(String scheme)
        Specifies the scheme for this LDAP URL.
        Parameters:
        scheme - The scheme for this LDAP URL.
      • getHost

        public String getHost()
        Retrieves the host for this LDAP URL.
        Returns:
        The host for this LDAP URL, or null if none was provided.
      • setHost

        public void setHost​(String host)
        Specifies the host for this LDAP URL.
        Parameters:
        host - The host for this LDAP URL.
      • getPort

        public int getPort()
        Retrieves the port for this LDAP URL.
        Returns:
        The port for this LDAP URL.
      • setPort

        public void setPort​(int port)
        Specifies the port for this LDAP URL.
        Parameters:
        port - The port for this LDAP URL.
      • getRawBaseDN

        public String getRawBaseDN()
        Retrieve the raw, unprocessed base DN for this LDAP URL.
        Returns:
        The raw, unprocessed base DN for this LDAP URL, or null if none was given (in which case a default of the null DN "" should be assumed).
      • setRawBaseDN

        public void setRawBaseDN​(String rawBaseDN)
        Specifies the raw, unprocessed base DN for this LDAP URL.
        Parameters:
        rawBaseDN - The raw, unprocessed base DN for this LDAP URL.
      • getBaseDN

        public DN getBaseDN()
                     throws DirectoryException
        Retrieves the processed DN for this LDAP URL.
        Returns:
        The processed DN for this LDAP URL.
        Throws:
        DirectoryException - If the raw base DN cannot be decoded as a valid DN.
      • setBaseDN

        public void setBaseDN​(DN baseDN)
        Specifies the base DN for this LDAP URL.
        Parameters:
        baseDN - The base DN for this LDAP URL.
      • getAttributes

        public LinkedHashSet<String> getAttributes()
        Retrieves the set of attributes for this LDAP URL. The contents of the returned set may be altered by the caller.
        Returns:
        The set of attributes for this LDAP URL.
      • getScope

        public SearchScope getScope()
        Retrieves the search scope for this LDAP URL.
        Returns:
        The search scope for this LDAP URL, or null if none was given (in which case the base-level scope should be assumed).
      • setScope

        public void setScope​(SearchScope scope)
        Specifies the search scope for this LDAP URL.
        Parameters:
        scope - The search scope for this LDAP URL.
      • getRawFilter

        public String getRawFilter()
        Retrieves the raw, unprocessed search filter for this LDAP URL.
        Returns:
        The raw, unprocessed search filter for this LDAP URL, or null if none was given (in which case a default filter of "(objectClass=*)" should be assumed).
      • setRawFilter

        public void setRawFilter​(String rawFilter)
        Specifies the raw, unprocessed search filter for this LDAP URL.
        Parameters:
        rawFilter - The raw, unprocessed search filter for this LDAP URL.
      • getFilter

        public SearchFilter getFilter()
                               throws DirectoryException
        Retrieves the processed search filter for this LDAP URL.
        Returns:
        The processed search filter for this LDAP URL.
        Throws:
        DirectoryException - If a problem occurs while attempting to decode the raw filter.
      • setFilter

        public void setFilter​(SearchFilter filter)
        Specifies the search filter for this LDAP URL.
        Parameters:
        filter - The search filter for this LDAP URL.
      • getExtensions

        public List<String> getExtensions()
        Retrieves the set of extensions for this LDAP URL. The contents of the returned list may be altered by the caller.
        Returns:
        The set of extensions for this LDAP URL.
      • matchesEntry

        public boolean matchesEntry​(Entry entry)
                             throws DirectoryException
        Indicates whether the provided entry matches the criteria defined in this LDAP URL.
        Parameters:
        entry - The entry for which to make the determination.
        Returns:
        true if the provided entry does match the criteria specified in this LDAP URL, or false if it does not.
        Throws:
        DirectoryException - If a problem occurs while attempting to make the determination.
      • equals

        public boolean equals​(Object o)
        Indicates whether the provided object is equal to this LDAP URL.
        Overrides:
        equals in class Object
        Parameters:
        o - The object for which to make the determination.
        Returns:
        true if the object is equal to this LDAP URL, or false if not.
      • hashCode

        public int hashCode()
        Retrieves the hash code for this LDAP URL.
        Overrides:
        hashCode in class Object
        Returns:
        The hash code for this LDAP URL.
      • toString

        public String toString()
        Retrieves a string representation of this LDAP URL.
        Overrides:
        toString in class Object
        Returns:
        A string representation of this LDAP URL.
      • toString

        public void toString​(StringBuilder buffer,
                             boolean baseOnly)
        Appends a string representation of this LDAP URL to the provided buffer.
        Parameters:
        buffer - The buffer to which the information is to be appended.
        baseOnly - Indicates whether the resulting URL string should only include the portion up to the base DN, omitting the attributes, scope, filter, and extensions.