Class Url

java.lang.Object
org.ldaptive.url.Url

public final class Url extends Object
Class to represent an LDAP URL. See RFC 4516. Expects URLs of the form scheme://hostname:port/baseDn?attrs?scope?filter. This implementation does not support URL extensions.
  • Field Details

    • DEFAULT_LDAP_PORT

      static final int DEFAULT_LDAP_PORT
      Default LDAP port, value is 389.
      See Also:
    • DEFAULT_LDAPS_PORT

      static final int DEFAULT_LDAPS_PORT
      Default LDAPS port, value is 636.
      See Also:
    • DEFAULT_LDAPI_PORT

      static final int DEFAULT_LDAPI_PORT
      Default LDAPI port, value is 0.
      See Also:
    • DEFAULT_BASE_DN

      static final String DEFAULT_BASE_DN
      Default base DN, value is "".
      See Also:
    • DEFAULT_PARSED_BASE_DN

      static final Dn DEFAULT_PARSED_BASE_DN
      Default parsed base DN.
    • DEFAULT_FILTER

      static final String DEFAULT_FILTER
      Default attribute filter value is '(objectClass=*)'.
      See Also:
    • DEFAULT_PARSED_FILTER

      static final Filter DEFAULT_PARSED_FILTER
      Default parsed attribute filter.
    • DEFAULT_SCOPE

      static final SearchScope DEFAULT_SCOPE
      Default scope, value is SearchScope.OBJECT.
    • DEFAULT_ATTRIBUTES

      static final String[] DEFAULT_ATTRIBUTES
      Default return attributes, value is all user attributes.
    • HASH_CODE_SEED

      private static final int HASH_CODE_SEED
      hash code seed.
      See Also:
    • DN_PARSER

      private static final DnParser DN_PARSER
      For parsing DNs.
    • FILTER_FUNCTION

      private static final FilterFunction FILTER_FUNCTION
      For parsing filters.
    • LDAP_SCHEME

      private static final String LDAP_SCHEME
      LDAP scheme.
      See Also:
    • LDAPS_SCHEME

      private static final String LDAPS_SCHEME
      LDAPS scheme.
      See Also:
    • LDAPI_SCHEME

      private static final String LDAPI_SCHEME
      LDAPI scheme.
      See Also:
    • scheme

      private final String scheme
      Scheme of the ldap url.
    • hostname

      private final String hostname
      Hostname of the ldap url.
    • port

      private final int port
      Port of the ldap url.
    • baseDn

      private final String baseDn
      Base DN of the ldap url.
    • parsedBaseDn

      private final Dn parsedBaseDn
      Parsed base DN of the ldap url.
    • attributes

      private final String[] attributes
      Attributes of the ldap url.
    • scope

      private final SearchScope scope
      Search scope of the ldap url.
    • filter

      private final String filter
      Search filter of the ldap url.
    • parsedFilter

      private final Filter parsedFilter
      Parsed filter of the ldap url.
  • Constructor Details

    • Url

      private Url(Url ldapURL)
      Copy constructor.
      Parameters:
      ldapURL - to copy properties from
    • Url

      Url(String scheme, String hostname, int port, String baseDn, String[] attributes, SearchScope scope, String filter)
      Creates a new ldap url.
      Parameters:
      scheme - url scheme
      hostname - url hostname
      port - url port
      baseDn - base DN
      attributes - attributes
      scope - search scope
      filter - search filter
    • Url

      public Url(String url)
      Creates a new ldap url.
      Parameters:
      url - LDAP url
    • Url

      public Url(String url, UrlParser parser)
      Creates a new ldap url.
      Parameters:
      url - LDAP url
      parser - to parse the url
  • Method Details

    • getScheme

      public String getScheme()
      Returns the scheme.
      Returns:
      scheme
    • isSchemeLdaps

      public boolean isSchemeLdaps()
      Returns whether the scheme is 'ldaps'.
      Returns:
      whether the scheme is 'ldaps'
    • getHostname

      public String getHostname()
      Returns the hostname.
      Returns:
      hostname
    • getPort

      public int getPort()
      Returns the port. If no port was supplied, returns the default port for the scheme.
      Returns:
      port
    • isDefaultPort

      public boolean isDefaultPort()
      Returns false if a port was supplied in this url.
      Returns:
      false if a port was supplied in this url
    • getBaseDn

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

      public Dn getParsedBaseDn()
      Returns the parsed base DN.
      Returns:
      parsed baseDn
    • isDefaultBaseDn

      public boolean isDefaultBaseDn()
      Returns whether a base DN was supplied in this url.
      Returns:
      whether a base DN was supplied in this url
    • getAttributes

      public String[] getAttributes()
      Returns the attributes.
      Returns:
      attributes
    • isDefaultAttributes

      public boolean isDefaultAttributes()
      Returns whether attributes were supplied in this url.
      Returns:
      whether an attributes were supplied in this url
    • getScope

      public SearchScope getScope()
      Returns the scope.
      Returns:
      scope
    • isDefaultScope

      public boolean isDefaultScope()
      Returns whether a scope was supplied in this url.
      Returns:
      whether a scope was supplied in this url
    • getFilter

      public String getFilter()
      Returns the filter.
      Returns:
      filter
    • getParsedFilter

      public Filter getParsedFilter()
      Returns the parsed filter.
      Returns:
      parsed filter
    • isDefaultFilter

      public boolean isDefaultFilter()
      Returns whether a filter was supplied in this url.
      Returns:
      whether a filter was supplied in this url
    • format

      public String format()
      Returns a string representation of this LDAP URL. Uses a MinimalUrlFormatter by default.
      Returns:
      string form of the LDAP URL
    • format

      public String format(UrlFormatter formatter)
      Returns a string representation of this LDAP URL.
      Parameters:
      formatter - to produce the string
      Returns:
      string form of the LDAP URL
    • validateScheme

      static void validateScheme(String scheme)
      Determines whether the supplied scheme is valid. Must be one of 'ldap', 'ldaps' or 'ldapi'.
      Parameters:
      scheme - to validate
    • validatePort

      static void validatePort(int port, boolean allowDefault)
      Determines whether the supplied port is valid.
      Parameters:
      port - to validate
      allowDefault - whether to allow default port of -1
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object