public class LdapURLParser
extends java.lang.Object
String
representation of an LDAP URL in accordance with
RFC 2255.
This class can be used for converting an RFC 2255 String
representation of an LDAP URL into a
com.entrust.toolkit.util.LdapURL
object. The RFC2255 representation of an LDAP URL is defined using
the following grammar:
ldapurl = scheme "://" [hostport] ["/"
[dn ["?" [attributes] ["?" [scope]
["?" [filter] ["?" extensions]]]]]]
scheme = "ldap"
attributes = attrdesc *("," attrdesc)
scope = "base" / "one" / "sub"
dn = distinguishedName
hostport = hostport
attrdesc = AttributeDescription
filter = filter
extensions = extension *("," extension)
extension = ["!"] extype ["=" exvalue]
extype = token / xtoken
exvalue = LDAPString
token = oid
xtoken = ("X-" / "x-") token
Refer to RFC 2255 for the complete definition of an LDAP URL.
To convert an RFC 2255 String into an LDAP URL, create
a new LdapURLParser object
specifying the String to be converted. To retrieve
components of the LDAP URL, call the corresponding method. For
example:
String url = "ldap://ldap.entrust.com:389/CN=Regular User,O=Entrust,C=CA";
LdapURLParser ldapURLParser = new LdapURLParser(url);
String host = ldapURLParser.getHost();
iaik.asn1.structures.Name dn = ldapURLParser.getDN();
To construct an LdapURL object from the URL string, use the
LdapURL constructor:
LdapURL ldapURL = new LdapURL(url);
| Constructor and Description |
|---|
LdapURLParser(java.lang.String ldapurl)
Standard constructor initializes a new parser using the
String to be parsed. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isLdapURL()
Determines whether the
String in this
LdapURLParser object is an LDAP URL. |
java.lang.String |
parseAttributes()
Parses the LDAP URL to return its
attributes component. |
Name |
parseDN()
Parses the LDAP URL to return its distinguished name (DN) value.
|
java.lang.String |
parseExtensions()
Parses the LDAP URL to return its
extensions component. |
java.lang.String |
parseFilter()
Parses the LDAP URL to return its
filter component. |
java.lang.String |
parseHost()
Parses the LDAP URL to return its
host component. |
int |
parsePort()
Parses the LDAP URL to return its
port component. |
java.lang.String |
parseScheme()
Parses the LDAP URL to return its
scheme component. |
int |
parseScope()
Parses the LDAP URL to return its
scope component. |
public LdapURLParser(java.lang.String ldapurl)
throws LdapURLException
String to be parsed.
ldapurl - the LDAP URL String to be parsedLdapURLException - if the URL String could not
be parsed successfullypublic java.lang.String parseScheme()
scheme component.
String representing the
scheme component of the LDAP URL, or
null if this is not an LDAP URL.public java.lang.String parseHost()
host component.
String representing the host
value of the LDAP URL, or null if the
host component does not exist.public int parsePort()
port component.
int representing the port
value of the LDAP URL if it is specified. Returns the
default port component of 389 if a
port component is not specified.public Name parseDN()
aik.asn1.structures.Name representing
the distinguished name in the LDAP URL
null if the DN does not exist.public java.lang.String parseAttributes()
attributes component.
String representing the
attributes component
of the LDAP URL. If the attributes component
does not exist, the method returns null.public int parseScope()
scope component.
int representing the scope
value of the LDAP URL. If the scope component
does not exist, the method returns the default value,
base.public java.lang.String parseFilter()
filter component.
String representing the
filter component of the LDAP URL. If the
filter component does not exist, the method
returns the default value (objectclass=*).public java.lang.String parseExtensions()
extensions component.
String representing the
extensions component of the LDAP URL, or
null if the component does not exist.public boolean isLdapURL()
String in this
LdapURLParser object is an LDAP URL.
According to RFC 2255,
an LDAP URL must start with "ldap://". However, the toolkit
will also allow the scheme to be case insensitive as recommended by
RFC 1738:
'For resiliency, programs interpreting URLs should treat upper case letters as equivalent to lower case in scheme names (e.g., allow "HTTP" as well as "http")'.
true, if the String in this
LdapURLParser object is an LDAP URL,
false otherwise.