Package org.ldaptive
Class LdapURL
java.lang.Object
org.ldaptive.LdapURL
Class for parsing LDAP URLs. See RFC 4516. Expects URLs of the form scheme://hostname:port/baseDn?attrs?scope?filter.
This implementation does not support URL extensions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
False if the last connection attempt to this URL failed, which should result in updatingretryMetadata
, otherwise true.private String[]
Attributes of the ldap url.private String
Base DN of the ldap url.protected static final String[]
Default return attributes, value is all user attributes.protected static final String
Default base DN, value is "".protected static final String
Default search filter value is '(objectClass=*)'.protected static final int
Default LDAP port, value is 389.protected static final int
Default LDAPS port, value is 636.protected static final SearchScope
Default scope, value isSearchScope.OBJECT
.private String
Search filter of the ldap url.private static final int
hash code seed.private String
Hostname of the ldap url.private InetAddress
IP address resolved for this URL.private int
Port of the ldap url.private LdapURLRetryMetadata
Metadata that describes connection failures on this URL.private String
Scheme of the ldap url.private SearchScope
Search scope of the ldap url.protected static final Pattern
Pattern to match LDAP URL. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
activate()
Marks this URL as active.static LdapURL
Returns a new ldap URL initialized with the supplied URL.(package private) void
Marks this URL as inactive.boolean
String[]
Returns the attributes.Returns the base DN.Returns the filter.Returns the hostname.Returns the hostname:port.Returns the scheme://hostname:port.Returns the resolved IP address.int
getPort()
Returns the port.(package private) LdapURLRetryMetadata
Returns the retry metadata.Returns the scheme.getScope()
Returns the scope.getUrl()
Returns the formatted URL as scheme://hostname:port/baseDn?attrs?scope?filter.int
hashCode()
(package private) boolean
isActive()
Returns whether this URL is currently active.boolean
Returns whether attributes were supplied in this url.boolean
Returns whether a base DN was supplied in this url.boolean
Returns whether a filter was supplied in this url.boolean
Returns false if a port was supplied in this url.boolean
Returns whether a scope was supplied in this url.protected void
Matches the supplied url against a pattern and reads its components.(package private) void
setInetAddress
(InetAddress address) Sets the resolved IP address.(package private) void
setRetryMetadata
(LdapURLRetryMetadata metadata) Sets the retry metadata.toString()
-
Field Details
-
URL_PATTERN
Pattern to match LDAP URL. -
DEFAULT_LDAP_PORT
protected static final int DEFAULT_LDAP_PORTDefault LDAP port, value is 389.- See Also:
-
DEFAULT_LDAPS_PORT
protected static final int DEFAULT_LDAPS_PORTDefault LDAPS port, value is 636.- See Also:
-
DEFAULT_BASE_DN
Default base DN, value is "".- See Also:
-
DEFAULT_FILTER
Default search filter value is '(objectClass=*)'.- See Also:
-
DEFAULT_SCOPE
Default scope, value isSearchScope.OBJECT
. -
DEFAULT_ATTRIBUTES
Default return attributes, value is all user attributes. -
HASH_CODE_SEED
private static final int HASH_CODE_SEEDhash code seed.- See Also:
-
scheme
Scheme of the ldap url. -
hostname
Hostname of the ldap url. -
port
private int portPort of the ldap url. -
baseDn
Base DN of the ldap url. -
attributes
Attributes of the ldap url. -
scope
Search scope of the ldap url. -
filter
Search filter of the ldap url. -
retryMetadata
Metadata that describes connection failures on this URL. -
active
private boolean activeFalse if the last connection attempt to this URL failed, which should result in updatingretryMetadata
, otherwise true. -
inetAddress
IP address resolved for this URL.
-
-
Constructor Details
-
LdapURL
private LdapURL()Private constructor. -
LdapURL
Creates a new ldap url.- Parameters:
hostname
- LDAP server hostnameport
- TCP port the LDAP server is listening on
-
LdapURL
Creates a new ldap url.- Parameters:
url
- LDAP url
-
LdapURL
protected LdapURL(String scheme, String hostname, int port, String baseDn, String[] attributes, SearchScope scope, String filter) Creates a new ldap url.- Parameters:
scheme
- url schemehostname
- url hostnameport
- url portbaseDn
- base DNattributes
- attributesscope
- search scopefilter
- search filter
-
-
Method Details
-
getScheme
Returns the scheme.- Returns:
- scheme
-
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
Returns the base DN.- Returns:
- 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
Returns the attributes.- Returns:
- attributes
-
isDefaultAttributes
public boolean isDefaultAttributes()Returns whether attributes were supplied in this url.- Returns:
- whether a attributes were supplied in this url
-
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
Returns the filter.- Returns:
- filter
-
isDefaultFilter
public boolean isDefaultFilter()Returns whether a filter was supplied in this url.- Returns:
- whether a filter was supplied in this url
-
getUrl
Returns the formatted URL as scheme://hostname:port/baseDn?attrs?scope?filter.- Returns:
- url
-
getHostnameWithPort
Returns the hostname:port.- Returns:
- hostname:port
-
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
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
Returns the resolved IP address.- Returns:
- resolved IP address for this URL.
-
setInetAddress
Sets the resolved IP address.- Parameters:
address
- IP address for this URL
-
copy
Returns a new ldap URL initialized with the supplied URL.- Parameters:
ldapURL
- ldap URL to read properties from- Returns:
- ldap URL
-
equals
-
hashCode
public int hashCode() -
toString
-
parseURL
Matches the supplied url against a pattern and reads its components.- Parameters:
url
- to parse
-