Package org.ldaptive
Class LdapURL
- java.lang.Object
-
- org.ldaptive.LdapURL
-
public class LdapURL extends java.lang.Object
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.- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String[]
DEFAULT_ATTRIBUTES
Default return attributes, value is all user attributes.protected static java.lang.String
DEFAULT_BASE_DN
Default base DN, value is "".protected static java.lang.String
DEFAULT_FILTER
Default search filter value is '(objectClass=*)'.protected static int
DEFAULT_LDAP_PORT
Default LDAP port, value is 389.protected static int
DEFAULT_LDAPS_PORT
Default LDAPS port, value is 636.protected static SearchScope
DEFAULT_SCOPE
Default scope, value isSearchScope.OBJECT
.protected static java.util.regex.Pattern
URL_PATTERN
Pattern to match LDAP URL.
-
Constructor Summary
Constructors Modifier Constructor Description LdapURL(java.lang.String url)
Creates a new ldap url.LdapURL(java.lang.String hostname, int port)
Creates a new ldap url.protected
LdapURL(java.lang.String scheme, java.lang.String hostname, int port, java.lang.String baseDn, java.lang.String[] attributes, SearchScope scope, java.lang.String filter)
Creates a new ldap url.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LdapURL
copy(LdapURL ldapURL)
Returns a new ldap URL initialized with the supplied URL.boolean
equals(java.lang.Object o)
java.lang.String[]
getAttributes()
Returns the attributes.java.lang.String
getBaseDn()
Returns the base DN.java.lang.String
getFilter()
Returns the filter.java.lang.String
getHostname()
Returns the hostname.java.lang.String
getHostnameWithPort()
Returns the hostname:port.java.lang.String
getHostnameWithSchemeAndPort()
Returns the scheme://hostname:port.java.net.InetAddress
getInetAddress()
Returns the resolved IP address.int
getPort()
Returns the port.java.lang.String
getScheme()
Returns the scheme.SearchScope
getScope()
Returns the scope.java.lang.String
getUrl()
Returns the formatted URL as scheme://hostname:port/baseDn?attrs?scope?filter.int
hashCode()
boolean
isDefaultAttributes()
Returns whether attributes were supplied in this url.boolean
isDefaultBaseDn()
Returns whether a base DN was supplied in this url.boolean
isDefaultFilter()
Returns whether a filter was supplied in this url.boolean
isDefaultPort()
Returns false if a port was supplied in this url.boolean
isDefaultScope()
Returns whether a scope was supplied in this url.protected void
parseURL(java.lang.String url)
Matches the supplied url against a pattern and reads its components.java.lang.String
toString()
-
-
-
Field Detail
-
URL_PATTERN
protected static final java.util.regex.Pattern URL_PATTERN
Pattern to match LDAP URL.
-
DEFAULT_LDAP_PORT
protected static final int DEFAULT_LDAP_PORT
Default LDAP port, value is 389.- See Also:
- Constant Field Values
-
DEFAULT_LDAPS_PORT
protected static final int DEFAULT_LDAPS_PORT
Default LDAPS port, value is 636.- See Also:
- Constant Field Values
-
DEFAULT_BASE_DN
protected static final java.lang.String DEFAULT_BASE_DN
Default base DN, value is "".- See Also:
- Constant Field Values
-
DEFAULT_FILTER
protected static final java.lang.String DEFAULT_FILTER
Default search filter value is '(objectClass=*)'.- See Also:
- Constant Field Values
-
DEFAULT_SCOPE
protected static final SearchScope DEFAULT_SCOPE
Default scope, value isSearchScope.OBJECT
.
-
DEFAULT_ATTRIBUTES
protected static final java.lang.String[] DEFAULT_ATTRIBUTES
Default return attributes, value is all user attributes.
-
-
Constructor Detail
-
LdapURL
public LdapURL(java.lang.String hostname, int port)
Creates a new ldap url.- Parameters:
hostname
- LDAP server hostnameport
- TCP port the LDAP server is listening on
-
LdapURL
public LdapURL(java.lang.String url)
Creates a new ldap url.- Parameters:
url
- LDAP url
-
LdapURL
protected LdapURL(java.lang.String scheme, java.lang.String hostname, int port, java.lang.String baseDn, java.lang.String[] attributes, SearchScope scope, java.lang.String filter)
Creates a new ldap url.- Parameters:
scheme
- url schemehostname
- url hostnameport
- url portbaseDn
- base DNattributes
- attributesscope
- search scopefilter
- search filter
-
-
Method Detail
-
getScheme
public java.lang.String getScheme()
Returns the scheme.- Returns:
- scheme
-
getHostname
public java.lang.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 java.lang.String 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
public java.lang.String[] 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
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 java.lang.String 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
public java.lang.String getUrl()
Returns the formatted URL as scheme://hostname:port/baseDn?attrs?scope?filter.- Returns:
- url
-
getHostnameWithPort
public java.lang.String getHostnameWithPort()
Returns the hostname:port.- Returns:
- hostname:port
-
getHostnameWithSchemeAndPort
public java.lang.String getHostnameWithSchemeAndPort()
Returns the scheme://hostname:port.- Returns:
- scheme://hostname:port
-
getInetAddress
public java.net.InetAddress getInetAddress()
Returns the resolved IP address.- Returns:
- resolved IP address 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
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
parseURL
protected void parseURL(java.lang.String url)
Matches the supplied url against a pattern and reads its components.- Parameters:
url
- to parse
-
-