Package org.ldaptive.url
Class Url
- java.lang.Object
-
- org.ldaptive.url.Url
-
public final class Url extends Object
Class to represent an LDAP URL. See RFC 4516. Expects URLs of the form scheme://hostname:port/baseDn?attrs?scope?filter. This implementation does not support URL extensions.
-
-
Field Summary
Fields Modifier and Type Field Description private String[]
attributes
Attributes of the ldap url.private String
baseDn
Base DN of the ldap url.(package private) static String[]
DEFAULT_ATTRIBUTES
Default return attributes, value is all user attributes.(package private) static String
DEFAULT_BASE_DN
Default base DN, value is "".(package private) static String
DEFAULT_FILTER
Default attribute filter value is '(objectClass=*)'.(package private) static int
DEFAULT_LDAP_PORT
Default LDAP port, value is 389.(package private) static int
DEFAULT_LDAPI_PORT
Default LDAPI port, value is 0.(package private) static int
DEFAULT_LDAPS_PORT
Default LDAPS port, value is 636.(package private) static Dn
DEFAULT_PARSED_BASE_DN
Default parsed base DN.(package private) static Filter
DEFAULT_PARSED_FILTER
Default parsed attribute filter.(package private) static SearchScope
DEFAULT_SCOPE
Default scope, value isSearchScope.OBJECT
.private static DnParser
DN_PARSER
For parsing DNs.private String
filter
Search filter of the ldap url.private static FilterFunction
FILTER_FUNCTION
For parsing filters.private static int
HASH_CODE_SEED
hash code seed.private String
hostname
Hostname of the ldap url.private static String
LDAP_SCHEME
LDAP scheme.private static String
LDAPI_SCHEME
LDAPI scheme.private static String
LDAPS_SCHEME
LDAPS scheme.private Dn
parsedBaseDn
Parsed base DN of the ldap url.private Filter
parsedFilter
Parsed filter of the ldap url.private int
port
Port of the ldap url.private String
scheme
Scheme of the ldap url.private SearchScope
scope
Search scope of the ldap url.
-
Constructor Summary
Constructors Modifier Constructor Description Url(String url)
Creates a new ldap url.(package private)
Url(String scheme, String hostname, int port, String baseDn, String[] attributes, SearchScope scope, String filter)
Creates a new ldap url.Url(String url, UrlParser parser)
Creates a new ldap url.private
Url(Url ldapURL)
Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
String
format()
Returns a string representation of this LDAP URL.String
format(UrlFormatter formatter)
Returns a string representation of this LDAP URL.String[]
getAttributes()
Returns the attributes.String
getBaseDn()
Returns the base DN.String
getFilter()
Returns the filter.String
getHostname()
Returns the hostname.Dn
getParsedBaseDn()
Returns the parsed base DN.Filter
getParsedFilter()
Returns the parsed filter.int
getPort()
Returns the port.String
getScheme()
Returns the scheme.SearchScope
getScope()
Returns the scope.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.boolean
isSchemeLdaps()
Returns whether the scheme is 'ldaps'.String
toString()
(package private) static void
validatePort(int port, boolean allowDefault)
Determines whether the supplied port is valid.(package private) static void
validateScheme(String scheme)
Determines whether the supplied scheme is valid.
-
-
-
Field Detail
-
DEFAULT_LDAP_PORT
static final int DEFAULT_LDAP_PORT
Default LDAP port, value is 389.- See Also:
- Constant Field Values
-
DEFAULT_LDAPS_PORT
static final int DEFAULT_LDAPS_PORT
Default LDAPS port, value is 636.- See Also:
- Constant Field Values
-
DEFAULT_LDAPI_PORT
static final int DEFAULT_LDAPI_PORT
Default LDAPI port, value is 0.- See Also:
- Constant Field Values
-
DEFAULT_BASE_DN
static final String DEFAULT_BASE_DN
Default base DN, value is "".- See Also:
- Constant Field Values
-
DEFAULT_PARSED_BASE_DN
static final Dn DEFAULT_PARSED_BASE_DN
Default parsed base DN.
-
DEFAULT_FILTER
static final String DEFAULT_FILTER
Default attribute filter value is '(objectClass=*)'.- See Also:
- Constant Field Values
-
DEFAULT_PARSED_FILTER
static final Filter DEFAULT_PARSED_FILTER
Default parsed attribute filter.
-
DEFAULT_SCOPE
static final SearchScope DEFAULT_SCOPE
Default scope, value isSearchScope.OBJECT
.
-
DEFAULT_ATTRIBUTES
static final String[] DEFAULT_ATTRIBUTES
Default return attributes, value is all user attributes.
-
HASH_CODE_SEED
private static final int HASH_CODE_SEED
hash code seed.- See Also:
- Constant Field Values
-
DN_PARSER
private static final DnParser DN_PARSER
For parsing DNs.
-
FILTER_FUNCTION
private static final FilterFunction FILTER_FUNCTION
For parsing filters.
-
LDAP_SCHEME
private static final String LDAP_SCHEME
LDAP scheme.- See Also:
- Constant Field Values
-
LDAPS_SCHEME
private static final String LDAPS_SCHEME
LDAPS scheme.- See Also:
- Constant Field Values
-
LDAPI_SCHEME
private static final String LDAPI_SCHEME
LDAPI scheme.- See Also:
- Constant Field Values
-
scheme
private final String scheme
Scheme of the ldap url.
-
hostname
private final String hostname
Hostname of the ldap url.
-
port
private final int port
Port of the ldap url.
-
baseDn
private final String baseDn
Base DN of the ldap url.
-
parsedBaseDn
private final Dn parsedBaseDn
Parsed base DN of the ldap url.
-
attributes
private final String[] attributes
Attributes of the ldap url.
-
scope
private final SearchScope scope
Search scope of the ldap url.
-
filter
private final String filter
Search filter of the ldap url.
-
parsedFilter
private final Filter parsedFilter
Parsed filter of the ldap url.
-
-
Constructor Detail
-
Url
private Url(Url ldapURL)
Copy constructor.- Parameters:
ldapURL
- to copy properties from
-
Url
Url(String scheme, String hostname, int port, String baseDn, String[] attributes, SearchScope scope, String filter)
Creates a new ldap url.- Parameters:
scheme
- url schemehostname
- url hostnameport
- url portbaseDn
- base DNattributes
- attributesscope
- search scopefilter
- search filter
-
Url
public Url(String url)
Creates a new ldap url.- Parameters:
url
- LDAP url
-
-
Method Detail
-
getScheme
public String getScheme()
Returns the scheme.- Returns:
- scheme
-
isSchemeLdaps
public boolean isSchemeLdaps()
Returns whether the scheme is 'ldaps'.- Returns:
- whether the scheme is 'ldaps'
-
getHostname
public 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 String getBaseDn()
Returns the base DN.- Returns:
- baseDn
-
getParsedBaseDn
public Dn getParsedBaseDn()
Returns the parsed base DN.- Returns:
- parsed 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 String[] getAttributes()
Returns the attributes.- Returns:
- attributes
-
isDefaultAttributes
public boolean isDefaultAttributes()
Returns whether attributes were supplied in this url.- Returns:
- whether an 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 String getFilter()
Returns the filter.- Returns:
- filter
-
getParsedFilter
public Filter getParsedFilter()
Returns the parsed filter.- Returns:
- parsed filter
-
isDefaultFilter
public boolean isDefaultFilter()
Returns whether a filter was supplied in this url.- Returns:
- whether a filter was supplied in this url
-
format
public String format()
Returns a string representation of this LDAP URL. Uses aMinimalUrlFormatter
by default.- Returns:
- string form of the LDAP URL
-
format
public String format(UrlFormatter formatter)
Returns a string representation of this LDAP URL.- Parameters:
formatter
- to produce the string- Returns:
- string form of the LDAP URL
-
validateScheme
static void validateScheme(String scheme)
Determines whether the supplied scheme is valid. Must be one of 'ldap', 'ldaps' or 'ldapi'.- Parameters:
scheme
- to validate
-
validatePort
static void validatePort(int port, boolean allowDefault)
Determines whether the supplied port is valid.- Parameters:
port
- to validateallowDefault
- whether to allow default port of -1
-
-