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_SEARCH_FILTER

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

      • valueOf

        public static LDAPURL valueOf​(String url)
                               throws LdapException
        Decodes the provided string as an LDAP URL. This method also decodes the DN.
        Parameters:
        url - The URL string to be decoded.
        Returns:
        The LDAP URL decoded from the provided string.
        Throws:
        LdapException - If a problem occurs while attempting to decode the provided string as an LDAP URL.
      • partiallyDecode

        public static LDAPURL partiallyDecode​(String url)
                                       throws LdapException
        Decodes the provided string as an LDAP URL, but do not decode the base DN and only keep it as a string instead (it can be retrieved by calling getRawBaseDN()).
        Parameters:
        url - The URL string to be decoded.
        Returns:
        The LDAP URL decoded from the provided string.
        Throws:
        LdapException - If a problem occurs while attempting to decode the provided string as an LDAP URL.
      • isSecure

        public boolean isSecure()
        Returns true if this LDAP URL should use LDAPS or false if it should use LDAP.
        Returns:
        true if this LDAP URL should use LDAPS or false if it should use LDAP.
      • getHost

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

        public int getPort()
        Retrieves the port for this LDAP URL.
        Returns:
        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).
      • getName

        public Dn getName()
                   throws LdapException
        Retrieves the processed DN for this LDAP URL.
        Returns:
        The processed DN for this LDAP URL.
        Throws:
        LdapException - If the raw base DN cannot be decoded as a valid DN.
      • 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).
      • getFilter

        public Filter getFilter()
        Retrieves the processed search filter for this LDAP URL.
        Returns:
        The processed search filter 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.