Class SimpleDirContextFactoryBuilder
- java.lang.Object
-
- org.wildfly.security.auth.realm.ldap.SimpleDirContextFactoryBuilder
-
public class SimpleDirContextFactoryBuilder extends Object
A simple builder for aDirContextFactory
which creates new contexts on demand and disposes of them as soon as they are returned.- Author:
- Darran Lofthouse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SimpleDirContextFactoryBuilder.SimpleDirContextFactory
-
Field Summary
Fields Modifier and Type Field Description private static AuthenticationContextConfigurationClient
authClient
private AuthenticationContext
authenticationContext
private boolean
built
private static String
CONNECT_TIMEOUT
private Properties
connectionProperties
private int
connectTimeout
private CredentialSource
credentialSource
private static int
DEFAULT_CONNECT_TIMEOUT
private static int
DEFAULT_READ_TIMEOUT
private String
initialContextFactory
private static String
LDAPS_SCHEME
private String
providerUrl
private static String
READ_TIMEOUT
private int
readTimeout
private String
securityAuthentication
private String
securityCredential
private String
securityPrincipal
private static String
SOCKET_FACTORY
private SocketFactory
socketFactory
private ClassLoader
targetClassLoader
private org.jboss.modules.Module
targetModule
-
Constructor Summary
Constructors Modifier Constructor Description private
SimpleDirContextFactoryBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
assertNotBuilt()
DirContextFactory
build()
Build this context factory.static SimpleDirContextFactoryBuilder
builder()
Construct a new instance.private static <T> T
doPrivileged(PrivilegedAction<T> action)
SimpleDirContextFactoryBuilder
setAuthenticationContext(AuthenticationContext authenticationContext)
Set the authentication context as source of security credential.SimpleDirContextFactoryBuilder
setConnectionProperties(Properties connectionProperties)
Set additional connection properties.SimpleDirContextFactoryBuilder
setConnectTimeout(int connectTimeout)
Set the timeout for connecting to the server.SimpleDirContextFactoryBuilder
setCredentialSource(CredentialSource credentialSource)
Set the authentication credential source.SimpleDirContextFactoryBuilder
setInitialContextFactory(String initialContextFactory)
Set the initial context factory class name.SimpleDirContextFactoryBuilder
setModule(org.jboss.modules.Module module)
Set module which will be used to load context factory and context.SimpleDirContextFactoryBuilder
setProviderUrl(String providerUrl)
Set the provider URL.SimpleDirContextFactoryBuilder
setReadTimeout(int readTimeout)
Set the read timeout for an LDAP operation.SimpleDirContextFactoryBuilder
setSecurityAuthentication(String securityAuthentication)
Set the security authentication method.SimpleDirContextFactoryBuilder
setSecurityCredential(String securityCredential)
Set the authentication credential.SimpleDirContextFactoryBuilder
setSecurityPrincipal(String securityPrincipal)
Set the authentication principal.SimpleDirContextFactoryBuilder
setSocketFactory(SocketFactory socketFactory)
Set the socket factory to be used by LDAP context.
-
-
-
Field Detail
-
CONNECT_TIMEOUT
private static final String CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
READ_TIMEOUT
private static final String READ_TIMEOUT
- See Also:
- Constant Field Values
-
SOCKET_FACTORY
private static final String SOCKET_FACTORY
- See Also:
- Constant Field Values
-
DEFAULT_CONNECT_TIMEOUT
private static final int DEFAULT_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_READ_TIMEOUT
private static final int DEFAULT_READ_TIMEOUT
- See Also:
- Constant Field Values
-
LDAPS_SCHEME
private static final String LDAPS_SCHEME
- See Also:
- Constant Field Values
-
built
private boolean built
-
initialContextFactory
private String initialContextFactory
-
providerUrl
private String providerUrl
-
securityAuthentication
private String securityAuthentication
-
securityPrincipal
private String securityPrincipal
-
securityCredential
private String securityCredential
-
credentialSource
private CredentialSource credentialSource
-
authenticationContext
private AuthenticationContext authenticationContext
-
socketFactory
private SocketFactory socketFactory
-
connectionProperties
private Properties connectionProperties
-
connectTimeout
private int connectTimeout
-
readTimeout
private int readTimeout
-
targetModule
private org.jboss.modules.Module targetModule
-
targetClassLoader
private ClassLoader targetClassLoader
-
authClient
private static final AuthenticationContextConfigurationClient authClient
-
-
Method Detail
-
builder
public static SimpleDirContextFactoryBuilder builder()
Construct a new instance.- Returns:
- the new builder
-
setInitialContextFactory
public SimpleDirContextFactoryBuilder setInitialContextFactory(String initialContextFactory)
Set the initial context factory class name.- Parameters:
initialContextFactory
- the class name- Returns:
- this builder
-
setProviderUrl
public SimpleDirContextFactoryBuilder setProviderUrl(String providerUrl)
Set the provider URL.- Parameters:
providerUrl
- the provider URL- Returns:
- this builder
-
setSecurityAuthentication
public SimpleDirContextFactoryBuilder setSecurityAuthentication(String securityAuthentication)
Set the security authentication method.- Parameters:
securityAuthentication
- the authentication method- Returns:
- this builder
-
setSecurityPrincipal
public SimpleDirContextFactoryBuilder setSecurityPrincipal(String securityPrincipal)
Set the authentication principal.- Parameters:
securityPrincipal
- the principal- Returns:
- this builder
-
setSecurityCredential
public SimpleDirContextFactoryBuilder setSecurityCredential(String securityCredential)
Set the authentication credential. If not set, factory try to obtain it fromCredentialSource
specified bysetCredentialSource(org.wildfly.security.credential.source.CredentialSource)
of fromAuthenticationContext
specified bysetAuthenticationContext(AuthenticationContext)
.- Parameters:
securityCredential
- the credential- Returns:
- this builder
-
setCredentialSource
public SimpleDirContextFactoryBuilder setCredentialSource(CredentialSource credentialSource)
Set the authentication credential source. Alternative tosetSecurityCredential(String)
.- Parameters:
credentialSource
- the credential source- Returns:
- this builder
-
setAuthenticationContext
public SimpleDirContextFactoryBuilder setAuthenticationContext(AuthenticationContext authenticationContext)
Set the authentication context as source of security credential. Alternative tosetSecurityCredential(String)
.- Parameters:
authenticationContext
- the credential source- Returns:
- this builder
-
setSocketFactory
public SimpleDirContextFactoryBuilder setSocketFactory(SocketFactory socketFactory)
Set the socket factory to be used by LDAP context. Used primarily for SSL connections. If not set, factory try to obtain it fromAuthenticationContext
specified bysetAuthenticationContext(AuthenticationContext)
.- Parameters:
socketFactory
- the socket factory- Returns:
- this builder
-
setConnectTimeout
public SimpleDirContextFactoryBuilder setConnectTimeout(int connectTimeout)
Set the timeout for connecting to the server. Set to 0 to ensure waiting for the response infinitely. If not set, 5000 ms will be used.- Parameters:
connectTimeout
- the timeout for connecting to the server in microseconds- Returns:
- this builder
-
setReadTimeout
public SimpleDirContextFactoryBuilder setReadTimeout(int readTimeout)
Set the read timeout for an LDAP operation. Set to 0 to ensure waiting for the response infinitely. If not set, 60000 ms will be used.- Parameters:
readTimeout
- the read timeout for an LDAP operation in microseconds- Returns:
- this builder
-
setConnectionProperties
public SimpleDirContextFactoryBuilder setConnectionProperties(Properties connectionProperties)
Set additional connection properties.
- Parameters:
connectionProperties
- the additional connection properties.- Returns:
- this builder
-
setModule
public SimpleDirContextFactoryBuilder setModule(org.jboss.modules.Module module)
Set module which will be used to load context factory and context.- Parameters:
module
- - module that will be used.- Returns:
- this builder
-
build
public DirContextFactory build()
Build this context factory.- Returns:
- the context factory
-
assertNotBuilt
private void assertNotBuilt()
-
doPrivileged
private static <T> T doPrivileged(PrivilegedAction<T> action)
-
-