@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class StartTLSPostConnectProcessor extends java.lang.Object implements PostConnectProcessor
SSLUtil
class for a more complete explanation
of the process for establishin secure connections.
// Configure an SSLUtil instance and use it to obtain an SSLContext. SSLUtil sslUtil = new SSLUtil(new TrustStoreTrustManager(trustStorePath)); SSLContext sslContext = sslUtil.createSSLContext(); // Establish an insecure connection to the directory server. LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions(); connectionOptions.setSSLSocketVerifier( new HostNameSSLSocketVerifier(true)); LDAPConnection connection = new LDAPConnection(connectionOptions, serverAddress, nonSSLPort); // Use the StartTLS extended operation to secure the connection. ExtendedResult startTLSResult = connection.processExtendedOperation( new StartTLSExtendedRequest(sslContext)); // Create a connection pool that will secure its connections with StartTLS. BindResult bindResult = connection.bind( "uid=john.doe,ou=People,dc=example,dc=com", "password"); StartTLSPostConnectProcessor startTLSProcessor = new StartTLSPostConnectProcessor(sslContext); LDAPConnectionPool pool = new LDAPConnectionPool(connection, 1, 10, startTLSProcessor); // Verify that we can use the pool to communicate with the directory server. RootDSE rootDSE = pool.getRootDSE(); // Close the connection pool. pool.close();
Constructor and Description |
---|
StartTLSPostConnectProcessor(javax.net.ssl.SSLContext sslContext)
Creates a new instance of this StartTLS post-connect processor that will
use the provided SSL context.
|
StartTLSPostConnectProcessor(javax.net.ssl.SSLSocketFactory sslSocketFactory)
Creates a new instance of this StartTLS post-connect processor that will
use the provided SSL context.
|
Modifier and Type | Method and Description |
---|---|
void |
processPostAuthenticatedConnection(LDAPConnection connection)
Performs any appropriate processing on the provided connection before
making it available for use in a connection pool.
|
void |
processPreAuthenticatedConnection(LDAPConnection connection)
Performs any appropriate processing on the provided connection before
making it available for use in a connection pool.
|
public StartTLSPostConnectProcessor(@NotNull javax.net.ssl.SSLContext sslContext)
sslContext
- The SSL context to use to perform the StartTLS
negotiation. It must not be null
.public StartTLSPostConnectProcessor(@NotNull javax.net.ssl.SSLSocketFactory sslSocketFactory)
sslSocketFactory
- The SSL socket factory to use to create the
TLS-secured socket. It must not be null
.public void processPreAuthenticatedConnection(@NotNull LDAPConnection connection) throws LDAPException
processPreAuthenticatedConnection
in interface PostConnectProcessor
connection
- The connection for which the processing is to be
performed.LDAPException
- If a problem occurs during processing. If an
exception is thrown, then the connection will be
terminated and not used in the pool.public void processPostAuthenticatedConnection(@NotNull LDAPConnection connection) throws LDAPException
processPostAuthenticatedConnection
in interface PostConnectProcessor
connection
- The connection for which the processing is to be
performed.LDAPException
- If a problem occurs during processing. If an
exception is thrown, then the connection will be
terminated and not used in the pool.