Package org.ldaptive

Class LdapURL


  • public final class LdapURL
    extends Object
    Class to represent an LDAP URL in order to make connections to an LDAP server. URL components are parsed according to RFC 4516. See Url
    • Field Detail

      • HASH_CODE_SEED

        private static final int HASH_CODE_SEED
        hash code seed.
        See Also:
        Constant Field Values
      • url

        private Url url
        Parsed URL properties.
      • retryMetadata

        private LdapURLRetryMetadata retryMetadata
        Metadata that describes connection failures on this URL.
      • active

        private boolean active
        False if the last connection attempt to this URL failed, which should result in updating retryMetadata, otherwise true.
      • inetAddress

        private InetAddress inetAddress
        IP address resolved for this URL.
      • priority

        private long priority
        Priority of this URL. Lower numbers indicate higher priority.
    • Constructor Detail

      • LdapURL

        private LdapURL()
        Private constructor.
      • LdapURL

        private LdapURL​(Url ldapURL)
        Creates a new LDAP URL with the supplied Url.
        Parameters:
        ldapURL - to set
      • LdapURL

        public LdapURL​(String hostname,
                       int port)
        Creates a new ldap url.
        Parameters:
        hostname - LDAP server hostname
        port - TCP port the LDAP server is listening on
      • LdapURL

        public LdapURL​(String ldapUrl)
        Creates a new ldap url.
        Parameters:
        ldapUrl - string representation of LDAP URL
      • LdapURL

        public LdapURL​(String ldapUrl,
                       UrlParser parser)
        Creates a new ldap url.
        Parameters:
        ldapUrl - string representation of LDAP URL
        parser - to parse the url
    • Method Detail

      • 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
      • getUrl

        public Url getUrl()
      • getHostnameWithPort

        public String getHostnameWithPort()
        Returns the hostname:port.
        Returns:
        hostname:port
      • getHostnameWithSchemeAndPort

        public String getHostnameWithSchemeAndPort()
        Returns the scheme://hostname:port.
        Returns:
        scheme://hostname:port
      • getRetryMetadata

        LdapURLRetryMetadata getRetryMetadata()
        Returns the retry metadata.
        Returns:
        metadata describing retry attempts for connections made this URL.
      • setRetryMetadata

        void setRetryMetadata​(LdapURLRetryMetadata metadata)
        Sets the retry metadata.
        Parameters:
        metadata - retry metadata
      • isActive

        boolean isActive()
        Returns whether this URL is currently active.
        Returns:
        true if this URL can be connected to, false otherwise.
      • activate

        void activate()
        Marks this URL as active.
      • deactivate

        void deactivate()
        Marks this URL as inactive.
      • getInetAddress

        public InetAddress getInetAddress()
        Returns the resolved IP address.
        Returns:
        resolved IP address for this URL.
      • setInetAddress

        void setInetAddress​(InetAddress address)
        Sets the resolved IP address.
        Parameters:
        address - IP address for this URL
      • getPriority

        public long getPriority()
        Returns the priority of this URL. Lower numbers indicate a higher priority.
        Returns:
        priority for this URL.
      • setPriority

        void setPriority​(long p)
        Sets the priority of this URL.
        Parameters:
        p - priority for this URL
      • copy

        public static LdapURL copy​(LdapURL ldapURL)
        Returns a new ldap URL initialized with the supplied URL.
        Parameters:
        ldapURL - ldap URL to read properties from
        Returns:
        ldap URL
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object