public static final class DirContextSource.Builder extends Object
DirContextSource with a fluent interface.
Notes:
IllegalStateException is thrown if a property is modified after this builder has already been
used to build a DirContextSource, simply create a new builder in this case.
| Constructor and Description |
|---|
Builder(String... urls)
Constructs a new builder for
DirContextSource with anonymous authentication. |
| Modifier and Type | Method and Description |
|---|---|
DirContextSource.Builder |
additionalProperty(String name,
Object value)
Sets an additional property not available through the builder interface.
|
DirContextSource.Builder |
anonymousAuth()
Enables anonymous authentication.
|
DirContextSource.Builder |
auth(DirContextSource.Auth auth)
Sets the authentication scheme.
|
DirContextSource.Builder |
binaryAttributes(String... attributes)
Sets those attributes which will be returned as
byte[] instead of String. |
DirContextSource |
build()
Builds a
DirContextSource and marks this builder as non-modifiable for future use. |
DirContextSource.Builder |
connectTimeout(int connectTimeout)
Sets the connect timeout in milliseconds.
|
DirContextSource.Builder |
contextFactory(String contextFactory)
Sets the context factory for this directory context.
|
DirContextSource.Builder |
debug()
Enables the redirection of the LDAP debug output to
System.err. |
DirContextSource.Builder |
debug(boolean debug)
Enables or disables the redirection of the LDAP debug output to
System.err. |
DirContextSource.Builder |
debug(OutputStream stream)
Redirects the LDAP debug output to an
OutputStream. |
DirContextSource.Builder |
derefAliases(String derefAliases)
Sets how aliases are dereferenced.
|
DirContextSource.Builder |
gssApiAuth()
Enables GSS-API authentication with a default login entry name.
|
DirContextSource.Builder |
gssApiAuth(String loginEntryName)
Enables GSS-API authentication with a custom login entry name.
|
DirContextSource.Builder |
loginEntryName(String loginEntryName)
Sets the login entry name for GSS-API authentication.
|
DirContextSource.Builder |
mutualAuth()
Enables the mutual authentication between client and directory server.
|
DirContextSource.Builder |
mutualAuth(boolean mutualAuth)
Enables or disables the mutual authentication between client and directory server.
|
DirContextSource.Builder |
objectFactories(String... objectFactories)
Sets the object factories for this directory context.
|
DirContextSource.Builder |
qop(String... qop)
Sets the quality of protection in preference order with which the connection to the directory server is
secured.
|
DirContextSource.Builder |
readTimeout(int readTimeout)
Sets the read timeout in milliseconds.
|
DirContextSource.Builder |
referral(String referral)
Sets the referral handling strategy.
|
DirContextSource.Builder |
retries(int retries)
Sets the number or connection retries.
|
DirContextSource.Builder |
retryWait(int retryWait)
Sets the wait interval between reconnections.
|
DirContextSource.Builder |
version(int version)
Sets the LDAP version.
|
public Builder(String... urls)
DirContextSource with anonymous authentication.
Note: The default context factory com.sun.jndi.ldap.LdapCtxFactory will iterate
through all URLs/servers until the first one is reachable/available.
urls - The URL(s) of a directory server. It/they may contain root DNs.NullPointerException - if urls is nullIllegalArgumentException - if urls is emptypublic DirContextSource.Builder contextFactory(String contextFactory)
contextFactory - the context factory class nameNullPointerException - if contextFactory is nullIllegalArgumentException - if contextFactory is emptypublic DirContextSource.Builder auth(DirContextSource.Auth auth)
auth - the auth to be usedNullPointerException - if auth is nullpublic DirContextSource.Builder loginEntryName(String loginEntryName)
loginEntryName - the login entry name which retrieves the GSS-API credentialNullPointerException - if loginEntryName is nullIllegalArgumentException - if loginEntryName is emptypublic DirContextSource.Builder anonymousAuth()
public DirContextSource.Builder gssApiAuth()
public DirContextSource.Builder gssApiAuth(String loginEntryName)
loginEntryName - the login entry name which retrieves the GSS-API credentialNullPointerException - if loginEntryName is nullIllegalArgumentException - if loginEntryName is emptyloginEntryName(String)public DirContextSource.Builder objectFactories(String... objectFactories)
objectFactories - the objectFactories class namesNullPointerException - if objectFactories is nullIllegalArgumentException - if objectFactories is emptypublic DirContextSource.Builder mutualAuth()
public DirContextSource.Builder mutualAuth(boolean mutualAuth)
mutualAuth - the mutual authentication flagpublic DirContextSource.Builder qop(String... qop)
auth, auth-int, and
auth-conf. This only works with SASL mechanisms which support this feature, e.g., Digest MD5 or
GSS-API. See here for
details.qop - the quality of protection for this directory context connectionNullPointerException - if qop is nullIllegalArgumentException - if qop is emptypublic DirContextSource.Builder debug()
System.err. This only works if the
contextFactory(String) is com.sun.jndi.ldap.LdapCtxFactory.debug(boolean)public DirContextSource.Builder debug(boolean debug)
System.err. This only works if the
contextFactory(String) is com.sun.jndi.ldap.LdapCtxFactory.debug - the debug flagpublic DirContextSource.Builder debug(OutputStream stream)
OutputStream. This only works if the
contextFactory(String) is com.sun.jndi.ldap.LdapCtxFactory.stream - an OutputStream where debug output will be written toNullPointerException - if stream is nullpublic DirContextSource.Builder retries(int retries)
retries - The number of retries. This value must be a positive integer.IllegalArgumentException - if retries is not a positive integerpublic DirContextSource.Builder retryWait(int retryWait)
retryWait - The wait time in milliseconds. This value must be a positive integer.IllegalArgumentException - if retryWait is not a positive integerpublic DirContextSource.Builder binaryAttributes(String... attributes)
attributes - the attributes to be returned as byte arrayNullPointerException - if attributes is nullIllegalArgumentException - if attributes is emptypublic DirContextSource.Builder referral(String referral)
ignore, follow, and throw. See
here for
details.referral - the referral handling strategyNullPointerException - if referral is nullIllegalArgumentException - if referral is emptypublic DirContextSource.Builder derefAliases(String derefAliases)
always, never, finding, and
searching. See here
for details.derefAliases - the aliases dereferencing strategyNullPointerException - if derefAliases is nullIllegalArgumentException - if derefAliases is emptypublic DirContextSource.Builder version(int version)
version - The LDAP version. This value must be a positive integer.IllegalArgumentException - if version is not a positive integerpublic DirContextSource.Builder connectTimeout(int connectTimeout)
contextFactory(String) is
com.sun.jndi.ldap.LdapCtxFactory.connectTimeout - The connect timeout in milliseconds. This value must be a positive integer.IllegalArgumentException - if connectTimeout is not a positive integerpublic DirContextSource.Builder readTimeout(int readTimeout)
contextFactory(String) is
com.sun.jndi.ldap.LdapCtxFactory. This value will be implicitly propagated to
ActiveDirectoryLdapDnsProvider.readTimeout - The read timeout in milliseconds. This value must be a positive integer.IllegalArgumentException - if readTimeout is not a positive integerpublic DirContextSource.Builder additionalProperty(String name, Object value)
name - name of the propertyvalue - value of the propertyNullPointerException - if name is nullIllegalArgumentException - if value is emptypublic DirContextSource build()
DirContextSource and marks this builder as non-modifiable for future use. You may call this
method as often as you like, it will return a new DirContextSource instance on every call.DirContextSource objectIllegalStateException - if a combination of necessary attributes is not setCopyright © 2012–2025 Michael Osipov. All rights reserved.