Class SimpleDirContextFactoryBuilder
- java.lang.Object
-
- org.wildfly.security.auth.realm.ldap.SimpleDirContextFactoryBuilder
-
public class SimpleDirContextFactoryBuilder extends Object
A simple builder for aDirContextFactorywhich 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 classSimpleDirContextFactoryBuilder.SimpleDirContextFactory
-
Field Summary
Fields Modifier and Type Field Description private static AuthenticationContextConfigurationClientauthClientprivate AuthenticationContextauthenticationContextprivate booleanbuiltprivate static StringCONNECT_TIMEOUTprivate PropertiesconnectionPropertiesprivate intconnectTimeoutprivate CredentialSourcecredentialSourceprivate static intDEFAULT_CONNECT_TIMEOUTprivate static intDEFAULT_READ_TIMEOUTprivate StringinitialContextFactoryprivate static StringLDAPS_SCHEMEprivate StringproviderUrlprivate static StringREAD_TIMEOUTprivate intreadTimeoutprivate StringsecurityAuthenticationprivate StringsecurityCredentialprivate StringsecurityPrincipalprivate static StringSOCKET_FACTORYprivate SocketFactorysocketFactoryprivate ClassLoadertargetClassLoaderprivate org.jboss.modules.ModuletargetModule
-
Constructor Summary
Constructors Modifier Constructor Description privateSimpleDirContextFactoryBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidassertNotBuilt()DirContextFactorybuild()Build this context factory.static SimpleDirContextFactoryBuilderbuilder()Construct a new instance.private static <T> TdoPrivileged(PrivilegedAction<T> action)SimpleDirContextFactoryBuildersetAuthenticationContext(AuthenticationContext authenticationContext)Set the authentication context as source of security credential.SimpleDirContextFactoryBuildersetConnectionProperties(Properties connectionProperties)Set additional connection properties.SimpleDirContextFactoryBuildersetConnectTimeout(int connectTimeout)Set the timeout for connecting to the server.SimpleDirContextFactoryBuildersetCredentialSource(CredentialSource credentialSource)Set the authentication credential source.SimpleDirContextFactoryBuildersetInitialContextFactory(String initialContextFactory)Set the initial context factory class name.SimpleDirContextFactoryBuildersetModule(org.jboss.modules.Module module)Set module which will be used to load context factory and context.SimpleDirContextFactoryBuildersetProviderUrl(String providerUrl)Set the provider URL.SimpleDirContextFactoryBuildersetReadTimeout(int readTimeout)Set the read timeout for an LDAP operation.SimpleDirContextFactoryBuildersetSecurityAuthentication(String securityAuthentication)Set the security authentication method.SimpleDirContextFactoryBuildersetSecurityCredential(String securityCredential)Set the authentication credential.SimpleDirContextFactoryBuildersetSecurityPrincipal(String securityPrincipal)Set the authentication principal.SimpleDirContextFactoryBuildersetSocketFactory(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 fromCredentialSourcespecified bysetCredentialSource(org.wildfly.security.credential.source.CredentialSource)of fromAuthenticationContextspecified 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 fromAuthenticationContextspecified 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)
-
-