Package com.unboundid.ldap.sdk
Class StartTLSPostConnectProcessor
java.lang.Object
com.unboundid.ldap.sdk.StartTLSPostConnectProcessor
- All Implemented Interfaces:
PostConnectProcessor
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class StartTLSPostConnectProcessor
extends Object
implements PostConnectProcessor
This class provides an implementation of a post-connect processor that can
be used to perform StartTLS negotiation on an LDAP connection that is
intended to be used in a connection pool.
Example
The following example demonstrates the use of the StartTLS post-connect processor to create an LDAP connection pool whose connections are secured using StartTLS. See the Javadoc documentation for theSSLUtil 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 Summary
ConstructorsConstructorDescriptionStartTLSPostConnectProcessor(SSLContext sslContext) Creates a new instance of this StartTLS post-connect processor that will use the provided SSL context.StartTLSPostConnectProcessor(SSLSocketFactory sslSocketFactory) Creates a new instance of this StartTLS post-connect processor that will use the provided SSL context. -
Method Summary
Modifier and TypeMethodDescriptionvoidprocessPostAuthenticatedConnection(LDAPConnection connection) Performs any appropriate processing on the provided connection before making it available for use in a connection pool.voidprocessPreAuthenticatedConnection(LDAPConnection connection) Performs any appropriate processing on the provided connection before making it available for use in a connection pool.
-
Constructor Details
-
StartTLSPostConnectProcessor
Creates a new instance of this StartTLS post-connect processor that will use the provided SSL context.- Parameters:
sslContext- The SSL context to use to perform the StartTLS negotiation. It must not benull.
-
StartTLSPostConnectProcessor
Creates a new instance of this StartTLS post-connect processor that will use the provided SSL context.- Parameters:
sslSocketFactory- The SSL socket factory to use to create the TLS-secured socket. It must not benull.
-
-
Method Details
-
processPreAuthenticatedConnection
public void processPreAuthenticatedConnection(@NotNull LDAPConnection connection) throws LDAPException Performs any appropriate processing on the provided connection before making it available for use in a connection pool. This method will be invoked immediately after the connection has been established but before any attempt has been made to perform any authentication.- Specified by:
processPreAuthenticatedConnectionin interfacePostConnectProcessor- Parameters:
connection- The connection for which the processing is to be performed.- Throws:
LDAPException- If a problem occurs during processing. If an exception is thrown, then the connection will be terminated and not used in the pool.
-
processPostAuthenticatedConnection
public void processPostAuthenticatedConnection(@NotNull LDAPConnection connection) throws LDAPException Performs any appropriate processing on the provided connection before making it available for use in a connection pool. This method will be invoked immediately after any appropriate authentication has been performed on the connection.- Specified by:
processPostAuthenticatedConnectionin interfacePostConnectProcessor- Parameters:
connection- The connection for which the processing is to be performed.- Throws:
LDAPException- If a problem occurs during processing. If an exception is thrown, then the connection will be terminated and not used in the pool.
-