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[]attributesAttributes of the ldap url.private StringbaseDnBase DN of the ldap url.(package private) static String[]DEFAULT_ATTRIBUTESDefault return attributes, value is all user attributes.(package private) static StringDEFAULT_BASE_DNDefault base DN, value is "".(package private) static StringDEFAULT_FILTERDefault attribute filter value is '(objectClass=*)'.(package private) static intDEFAULT_LDAP_PORTDefault LDAP port, value is 389.(package private) static intDEFAULT_LDAPI_PORTDefault LDAPI port, value is 0.(package private) static intDEFAULT_LDAPS_PORTDefault LDAPS port, value is 636.(package private) static DnDEFAULT_PARSED_BASE_DNDefault parsed base DN.(package private) static FilterDEFAULT_PARSED_FILTERDefault parsed attribute filter.(package private) static SearchScopeDEFAULT_SCOPEDefault scope, value isSearchScope.OBJECT.private static DnParserDN_PARSERFor parsing DNs.private StringfilterSearch filter of the ldap url.private static FilterFunctionFILTER_FUNCTIONFor parsing filters.private static intHASH_CODE_SEEDhash code seed.private StringhostnameHostname of the ldap url.private static StringLDAP_SCHEMELDAP scheme.private static StringLDAPI_SCHEMELDAPI scheme.private static StringLDAPS_SCHEMELDAPS scheme.private DnparsedBaseDnParsed base DN of the ldap url.private FilterparsedFilterParsed filter of the ldap url.private intportPort of the ldap url.private StringschemeScheme of the ldap url.private SearchScopescopeSearch 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.privateUrl(Url ldapURL)Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Stringformat()Returns a string representation of this LDAP URL.Stringformat(UrlFormatter formatter)Returns a string representation of this LDAP URL.String[]getAttributes()Returns the attributes.StringgetBaseDn()Returns the base DN.StringgetFilter()Returns the filter.StringgetHostname()Returns the hostname.DngetParsedBaseDn()Returns the parsed base DN.FiltergetParsedFilter()Returns the parsed filter.intgetPort()Returns the port.StringgetScheme()Returns the scheme.SearchScopegetScope()Returns the scope.inthashCode()booleanisDefaultAttributes()Returns whether attributes were supplied in this url.booleanisDefaultBaseDn()Returns whether a base DN was supplied in this url.booleanisDefaultFilter()Returns whether a filter was supplied in this url.booleanisDefaultPort()Returns false if a port was supplied in this url.booleanisDefaultScope()Returns whether a scope was supplied in this url.booleanisSchemeLdaps()Returns whether the scheme is 'ldaps'.StringtoString()(package private) static voidvalidatePort(int port, boolean allowDefault)Determines whether the supplied port is valid.(package private) static voidvalidateScheme(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 aMinimalUrlFormatterby 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
-
-