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 booleanFalse if the last connection attempt to this URL failed, which should result in updatingretryMetadata, otherwise true.private String[]Attributes of the ldap url.private StringBase DN of the ldap url.protected static final String[]Default return attributes, value is all user attributes.protected static final StringDefault base DN, value is "".protected static final StringDefault search filter value is '(objectClass=*)'.protected static final intDefault LDAP port, value is 389.protected static final intDefault LDAPS port, value is 636.protected static final SearchScopeDefault scope, value isSearchScope.OBJECT.private StringSearch filter of the ldap url.private static final inthash code seed.private StringHostname of the ldap url.private InetAddressIP address resolved for this URL.private intPort of the ldap url.private LdapURLRetryMetadataMetadata that describes connection failures on this URL.private StringScheme of the ldap url.private SearchScopeSearch scope of the ldap url.protected static final PatternPattern to match LDAP URL. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidactivate()Marks this URL as active.static LdapURLReturns a new ldap URL initialized with the supplied URL.(package private) voidMarks this URL as inactive.booleanString[]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.intgetPort()Returns the port.(package private) LdapURLRetryMetadataReturns the retry metadata.Returns the scheme.getScope()Returns the scope.getUrl()Returns the formatted URL as scheme://hostname:port/baseDn?attrs?scope?filter.inthashCode()(package private) booleanisActive()Returns whether this URL is currently active.booleanReturns whether attributes were supplied in this url.booleanReturns whether a base DN was supplied in this url.booleanReturns whether a filter was supplied in this url.booleanReturns false if a port was supplied in this url.booleanReturns whether a scope was supplied in this url.protected voidMatches the supplied url against a pattern and reads its components.(package private) voidsetInetAddress(InetAddress address) Sets the resolved IP address.(package private) voidsetRetryMetadata(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
-