Package org.forgerock.opendj.ldap
Class LdapUrl
java.lang.Object
org.forgerock.opendj.ldap.LdapUrl
An LDAP URL as defined in RFC 4516. In addition, the secure ldap (ldaps://)
is also supported. LDAP URLs have the following format:
"ldap[s]://" [ hostName [":" portNumber] ]
"/" distinguishedName
["?" attributeList
["?" scope "?" filterString ] ]
Where:
- all text within double-quotes are literal
hostNameandportNumberidentify the location of the LDAP server.distinguishedNameis the name of an entry within the given directory (the entry represents the starting point of the search).attributeListcontains a list of attributes to retrieve (if null, fetch all attributes). This is a comma-delimited list of attribute names.scopeis one of the following:baseindicates that this is a search only for the specified entryoneindicates that this is a search for matching entries one level under the specified entry (and not including the entry itself)subindicates that this is a search for matching entries at all levels under the specified entry (including the entry itself)subordinatesindicates that this is a search for matching entries all levels under the specified entry (excluding the entry itself)
scopeisbaseby default.filterStringis a human-readable representation of the search criteria. If no filter is provided, then a default of "(objectClass=*)" should be assumed.
%HH, where HH represent the two hex
digits which correspond to the ASCII value of the character. This encoding is
only legal (or necessary) on the DN and filter portions of the URL.
Note that this class does not implement extensions.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new LDAP URL referring to a single entry on the specified server.LdapUrl(boolean isSecured, String host, Integer port, Dn name, SearchScope scope, Filter filter, String... attributes) Creates a new LDAP URL including the full set of parameters for a search request. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new search request containing the parameters of this LDAP URL.booleanReturns an unmodifiable list containing the attributes to be included with each entry that matches the search criteria.Returns the search filter associated with this LDAP URL.getHost()Returns the name or IP address in dotted format of the LDAP server referenced by this LDAP URL.getName()Returns the distinguished name of the base entry relative to which the search is to be performed.intgetPort()Returns the port number of the LDAP server referenced by this LDAP URL.getScope()Returns the search scope associated with this LDAP URL.inthashCode()booleanisSecure()Returnstrueif this LDAP URL should use LDAPS orfalseif it should use LDAP.toString()static LdapUrlParses the provided LDAP string representation of an LDAP URL using the default schema.static LdapUrlParses the provided LDAP string representation of an LDAP URL using the provided schema.
-
Constructor Details
-
LdapUrl
Creates a new LDAP URL referring to a single entry on the specified server. The LDAP URL with have base object scope and the filter(objectClass=*).- Parameters:
isSecured-trueif this LDAP URL should use LDAPS orfalseif it should use LDAP.host- The name or IP address in dotted format of the LDAP server. For example,ldap.server1.comor192.202.185.90. Usenullfor the local host.port- The port number of the LDAP server, ornullto use the default port (389 for LDAP and 636 for LDAPS).name- The distinguished name of the base entry relative to which the search is to be performed, ornullto specify the root DSE.- Throws:
LocalizedIllegalArgumentException- Ifportwas less than 1 or greater than 65535.
-
LdapUrl
public LdapUrl(boolean isSecured, String host, Integer port, Dn name, SearchScope scope, Filter filter, String... attributes) Creates a new LDAP URL including the full set of parameters for a search request.- Parameters:
isSecured-trueif this LDAP URL should use LDAPS orfalseif it should use LDAP.host- The name or IP address in dotted format of the LDAP server. For example,ldap.server1.comor192.202.185.90. Usenullfor the local host.port- The port number of the LDAP server, ornullto use the default port (389 for LDAP and 636 for LDAPS).name- The distinguished name of the base entry relative to which the search is to be performed, ornullto specify the root DSE.scope- The search scope, ornullto specify base scope.filter- The search filter, ornullto specify the filter(objectClass=*).attributes- The list of attributes to be included in the search results.- Throws:
LocalizedIllegalArgumentException- Ifportwas less than 1 or greater than 65535.
-
-
Method Details
-
valueOf
Parses the provided LDAP string representation of an LDAP URL using the default schema.- Parameters:
url- The LDAP string representation of an LDAP URL.- Returns:
- The parsed LDAP URL.
- Throws:
LocalizedIllegalArgumentException- Ifurlis not a valid LDAP string representation of an LDAP URL.NullPointerException- Ifurlwasnull.
-
valueOf
Parses the provided LDAP string representation of an LDAP URL using the provided schema.- Parameters:
url- The LDAP string representation of an LDAP URL.schema- The schema to use when parsing the LDAP URL.- Returns:
- The parsed LDAP URL.
- Throws:
LocalizedIllegalArgumentException- Ifurlis not a valid LDAP string representation of an LDAP URL.NullPointerException- Ifurlorschemawasnull.
-
asSearchRequest
Creates a new search request containing the parameters of this LDAP URL.- Returns:
- A new search request containing the parameters of this LDAP URL.
-
equals
-
getAttributes
Returns an unmodifiable list containing the attributes to be included with each entry that matches the search criteria. Attributes that are sub-types of listed attributes are implicitly included. If the returned list is empty then all user attributes will be included by default.- Returns:
- An unmodifiable list containing the attributes to be included with each entry that matches the search criteria.
-
getFilter
Returns the search filter associated with this LDAP URL.- Returns:
- The search filter associated with this LDAP URL.
-
getHost
Returns the name or IP address in dotted format of the LDAP server referenced by this LDAP URL. For example,ldap.server1.comor192.202.185.90. Usenullfor the local host.- Returns:
- A name or IP address in dotted format of the LDAP server referenced by this LDAP URL.
-
getName
Returns the distinguished name of the base entry relative to which the search is to be performed.- Returns:
- The distinguished name of the base entry relative to which the search is to be performed.
-
getPort
public int getPort()Returns the port number of the LDAP server referenced by this LDAP URL.- Returns:
- The port number of the LDAP server referenced by this LDAP URL.
-
getScope
Returns the search scope associated with this LDAP URL.- Returns:
- The search scope associated with this LDAP URL.
-
hashCode
public int hashCode() -
isSecure
public boolean isSecure()Returnstrueif this LDAP URL should use LDAPS orfalseif it should use LDAP.- Returns:
trueif this LDAP URL should use LDAPS orfalseif it should use LDAP.
-
toString
-