public class LDAPUrl
extends java.lang.Object
implements java.io.Serializable
"ldap[s]://" [ hostName [":" portNumber] ] "/" distinguishedName ["?" attributeList ["?" scope "?" filterString ] ]where
hostName
and portNumber
identify the location of the LDAP server.
distinguishedName
is the name of an entry
within the given directory (the entry represents the starting point
of the search)
attributeList
contains a list of attributes
to retrieve (if null, fetch all attributes). This is a comma-delimited
list of attribute names.
scope
is one of the following:
base
indicates that this is a search only for the
specified entry
one
indicates that this is a search for matching entries
one level under the specified entry (and not including the entry itself)
sub
indicates that this is a search for matching entries
at all levels under the specified entry (including the entry itself)
If not specified, scope
is base
by
default.
filterString
is a human-readable representation
of the search criteria. This value is used only for one-level or subtree
searches.
Note that if scope
and filterString
are not specified, an LDAP URL identifies exactly one entry in the
directory.
The same encoding rules for other URLs (e.g. HTTP) apply for LDAP
URLs. Specifically, any "illegal" characters are escaped with
%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.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SECURE_PORT
The default port number for secure LDAP connections.
|
static java.lang.String |
defaultFilter |
Constructor and Description |
---|
LDAPUrl(java.lang.String url)
Constructs a URL object with the specified string as URL.
|
LDAPUrl(java.lang.String host,
int port,
java.lang.String DN)
Constructs with the specified host, port, and DN.
|
LDAPUrl(java.lang.String host,
int port,
java.lang.String DN,
java.util.Enumeration attributes,
int scope,
java.lang.String filter)
Constructs a full-blown LDAP URL to specify an LDAP search operation.
|
LDAPUrl(java.lang.String host,
int port,
java.lang.String DN,
java.lang.String[] attributes,
int scope,
java.lang.String filter)
Constructs a full-blown LDAP URL to specify an LDAP search operation.
|
LDAPUrl(java.lang.String host,
int port,
java.lang.String DN,
java.lang.String[] attributes,
int scope,
java.lang.String filter,
boolean secure)
Constructs a full-blown LDAP URL to specify an LDAP search operation.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decode(java.lang.String URLEncoded)
Decodes a URL-encoded string.
|
static java.lang.String |
encode(java.lang.String toEncode)
Encodes an arbitrary string.
|
boolean |
equals(LDAPUrl url)
Reports if the two objects represent the same URL
|
java.lang.String[] |
getAttributeArray()
Return the collection of attributes specified in the URL, or null
for "every attribute"
|
java.util.Enumeration |
getAttributes()
Return the collection of attributes specified in the URL, or null
for "every attribute"
|
java.lang.String |
getDN()
Return the distinguished name encapsulated in the URL
|
java.lang.String |
getFilter()
Returns the search filter (RFC 1558), or the default if none was
specified.
|
java.lang.String |
getHost()
Return the host name of the LDAP server
|
int |
getPort()
Return the port number for the LDAP server
|
int |
getScope()
Returns the scope of the search, according to the values
SCOPE_BASE, SCOPE_ONE, SCOPE_SUB as defined in LDAPv2.
|
static LDAPSocketFactory |
getSocketFactory()
Gets the socket factory to be used for ldaps:// URLs.
|
java.lang.String |
getUrl()
Returns a valid string representation of this LDAP URL.
|
boolean |
isSecure()
Returns true if the secure ldap protocol is used.
|
static void |
setSocketFactory(LDAPSocketFactory factory)
Sets the socket factory to be used for ldaps:// URLs.
|
java.lang.String |
toString()
Returns the URL in String format
|
public static java.lang.String defaultFilter
public static final int DEFAULT_SECURE_PORT
public LDAPUrl(java.lang.String url) throws java.net.MalformedURLException
url
- LDAP search expression in URL formjava.net.MalformedURLException
- failed to parse URLpublic LDAPUrl(java.lang.String host, int port, java.lang.String DN)
host
- host name of the LDAP server, or null for "nearest X.500/LDAP"port
- port number of the LDAP server (use LDAPv2.DEFAULT_PORT for
the default port)DN
- distinguished name of the objectpublic LDAPUrl(java.lang.String host, int port, java.lang.String DN, java.lang.String[] attributes, int scope, java.lang.String filter)
host
- host name of the LDAP server, or null for "nearest X.500/LDAP"port
- port number of the LDAP server (use LDAPv2.DEFAULT_PORT for
the default port)DN
- distinguished name of the objectattributes
- list of attributes to return. Use null for "all
attributes."scope
- depth of search (in DN namespace). Use one of the LDAPv2 scopes:
SCOPE_BASE, SCOPE_ONE, or SCOPE_SUB.filter
- LDAP filter string (as defined in RFC 1558). Use null for
no filter (this effectively makes the URL reference a single object).public LDAPUrl(java.lang.String host, int port, java.lang.String DN, java.util.Enumeration attributes, int scope, java.lang.String filter)
host
- host name of the LDAP server, or null for "nearest X.500/LDAP"port
- port number of the LDAP server (use LDAPv2.DEFAULT_PORT for
the default port)DN
- distinguished name of the objectattributes
- list of the attributes to return. Use null for "all
attributes."scope
- depth of the search (in DN namespace). Use one of the LDAPv2 scopes:
SCOPE_BASE, SCOPE_ONE, or SCOPE_SUB.filter
- LDAP filter string (as defined in RFC 1558). Use null for
no filter (this effectively makes the URL reference a single object).public LDAPUrl(java.lang.String host, int port, java.lang.String DN, java.lang.String[] attributes, int scope, java.lang.String filter, boolean secure)
host
- host name of the LDAP server, or null for "nearest X.500/LDAP"port
- port number of the LDAP server (use LDAPv2.DEFAULT_PORT for
the default non-secure port or LDAPUrl.DEFAULT_SECURE_PORT for the default
secure port)DN
- distinguished name of the objectattributes
- list of the attributes to return. Use null for "all
attributes."scope
- depth of the search (in DN namespace). Use one of the LDAPv2 scopes:
SCOPE_BASE, SCOPE_ONE, or SCOPE_SUB.filter
- LDAP filter string (as defined in RFC 1558). Use null for
no filter (this effectively makes the URL reference a single object).secure
- flag if secure ldap protocol (ldaps) is to be used.public java.lang.String getHost()
public int getPort()
public java.lang.String getDN()
public java.util.Enumeration getAttributes()
public java.lang.String[] getAttributeArray()
public int getScope()
public java.lang.String getFilter()
public java.lang.String getUrl()
public boolean isSecure()
public static LDAPSocketFactory getSocketFactory()
If the factory is not explicitly specified with
LDAPUrl.setSocketFactory
, the method will
attempt the determine the default factory based on the
available factories in the netscape.ldap.factory package.
public static void setSocketFactory(LDAPSocketFactory factory)
factory
- the socket factory to be used for ldaps:// URLsgetSocketFactory()
public static java.lang.String decode(java.lang.String URLEncoded) throws java.net.MalformedURLException
URLEncoded
- a segment of a URL which was encoded using the URL
encoding rulesjava.net.MalformedURLException
- failed to parse URLpublic static java.lang.String encode(java.lang.String toEncode)
toEncode
- an arbitrary string to encode for embedding within a URLpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(LDAPUrl url)
url
- the object to be compared totrue
if the two are equivalent