public class LdapUrl extends Object
ldapurl = scheme "://" [host [ ":" port]] ["/" dn ["?" [attributes] ["?" [scope] ["?" [filter] ["?" extensions]]]]] scheme = "ldap" dn = Dn attributes = attrdesc ["," attrdesc]* attrdesc = selector ["," selector]* selector = attributeSelector (from Section 4.5.1 of RFC4511) scope = "base" / "one" / "sub" extensions = extension ["," extension]* extension = ["!"] extype ["=" exvalue] extype = oid (from Section 1.4 of RFC4512) exvalue = LDAPString (from Section 4.1.2 of RFC4511) host = host from Section 3.2.2 of RFC3986 port = port from Section 3.2.3 of RFC3986 filter = filter from Section 3 of RFC 4515From Section 3.2.1/2 of RFC3986
host = IP-literal / IPv4address / reg-name port = *DIGIT IP-literal = "[" ( IPv6address / IPvFuture ) "]" IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) IPv6address = 6( h16 ":" ) ls32 | "::" 5( h16 ":" ) ls32 | [ h16 ] "::" 4( h16 ":" ) ls32 | [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 | [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 | [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 | [ *4( h16 ":" ) h16 ] "::" ls32 | [ *5( h16 ":" ) h16 ] "::" h16 | [ *6( h16 ":" ) h16 ] "::" IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet dec-octet = DIGIT | [1-9] DIGIT | "1" 2DIGIT | "2" [0-4] DIGIT | "25" [0-5] reg-name = *( unreserved / pct-encoded / sub-delims ) unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" pct-encoded = "%" HEXDIG HEXDIG sub-delims = "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" h16 = 1*4HEXDIG ls32 = ( h16 ":" h16 ) / IPv4address DIGIT = 0..9 ALPHA = A-Z / a-z HEXDIG = DIGIT / A-F / a-f
Modifier and Type | Class and Description |
---|---|
static class |
LdapUrl.Extension
An inner bean to hold extension information.
|
Modifier and Type | Field and Description |
---|---|
static LdapUrl |
EMPTY_URL
A null LdapUrl
|
static String |
LDAP_SCHEME
The constant for "ldap://" scheme.
|
static String |
LDAPS_SCHEME
The constant for "ldaps://" scheme.
|
Constructor and Description |
---|
LdapUrl()
Construct an empty LdapUrl
|
LdapUrl(String string)
Create a new LdapUrl from a String after having parsed it.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
List<String> |
getAttributes() |
byte[] |
getBytesCopy() |
byte[] |
getBytesReference() |
Dn |
getDn() |
LdapUrl.Extension |
getExtension(String type)
Gets the extension.
|
List<LdapUrl.Extension> |
getExtensions() |
String |
getExtensionValue(String type)
Gets the extension value.
|
String |
getFilter() |
String |
getHost() |
int |
getNbBytes() |
int |
getPort() |
String |
getScheme() |
SearchScope |
getScope()
|
String |
getString() |
int |
hashCode() |
boolean |
isValidInet4Address(String inet4Address)
Validates an IPv4 address.
|
boolean |
isValidInet6Address(String inet6Address)
This code source was taken from commons.validator 1.5.0
Validates an IPv6 address.
|
void |
setAttributes(List<String> attributes)
Sets the attributes, null removes all existing attributes.
|
void |
setDn(Dn dn)
Sets the dn.
|
void |
setFilter(String filter)
Sets the filter.
|
void |
setForceScopeRendering(boolean forceScopeRendering)
If set to true forces the toString method to render the scope
regardless of optional nature.
|
void |
setHost(String host)
Sets the host.
|
void |
setPort(int port)
Sets the port.
|
void |
setScheme(String scheme)
Sets the scheme.
|
void |
setScope(int scope)
Sets the scope.
|
void |
setScope(SearchScope scope)
Sets the scope.
|
String |
toString()
Get a string representation of a LdapUrl.
|
static String |
urlEncode(String url,
boolean doubleEncode)
Encode a String to avoid special characters.
|
public static final String LDAPS_SCHEME
public static final String LDAP_SCHEME
public LdapUrl()
public LdapUrl(String string) throws LdapURLEncodingException
string
- TheString that contains the LdapUrlLdapURLEncodingException
- If the String does not comply with RFC 2255public boolean isValidInet4Address(String inet4Address)
inet4Address
- the IPv4 address to validatepublic boolean isValidInet6Address(String inet6Address)
inet6Address
- the IPv6 address to validatepublic static String urlEncode(String url, boolean doubleEncode)
RFC 4516, section 2.1. (Percent-Encoding) A generated LDAP URL MUST consist only of the restricted set of characters included in one of the following three productions defined in [RFC3986]: <reserved> <unreserved> <pct-encoded> Implementations SHOULD accept other valid UTF-8 strings [RFC3629] as input. An octet MUST be encoded using the percent-encoding mechanism described in section 2.1 of [RFC3986] in any of these situations: The octet is not in the reserved set defined in section 2.2 of [RFC3986] or in the unreserved set defined in section 2.3 of [RFC3986]. It is the single Reserved character '?' and occurs inside a <dn>, <filter>, or other element of an LDAP URL. It is a comma character ',' that occurs inside an <exvalue>. RFC 3986, section 2.2 (Reserved Characters) reserved = gen-delims / sub-delims gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" RFC 3986, section 2.3 (Unreserved Characters) unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
url
- The String to encodedoubleEncode
- Set if we need to encode the commapublic List<String> getAttributes()
public List<LdapUrl.Extension> getExtensions()
public LdapUrl.Extension getExtension(String type)
type
- the extension type, case-insensitivepublic String getExtensionValue(String type)
type
- the extension type, case-insensitivepublic int getPort()
public SearchScope getScope()
public int getNbBytes()
public byte[] getBytesReference()
public byte[] getBytesCopy()
public void setScheme(String scheme)
scheme
- the new schemepublic void setPort(int port)
port
- the new portpublic void setAttributes(List<String> attributes)
attributes
- the new attributespublic void setScope(int scope)
SearchScope.OBJECT
,
SearchScope.ONELEVEL
or SearchScope.SUBTREE
,
otherwise SearchScope.OBJECT
is assumed as default.scope
- the new scopepublic void setScope(SearchScope scope)
SearchScope.OBJECT
,
SearchScope.ONELEVEL
or SearchScope.SUBTREE
,
otherwise SearchScope.OBJECT
is assumed as default.scope
- the new scopepublic void setForceScopeRendering(boolean forceScopeRendering)
forceScopeRendering
- the forceScopeRendering to setCopyright © 2003–2018 The Apache Software Foundation. All rights reserved.