public class TlsConnectionHandler extends DefaultConnectionHandler
TlsConnectionHandler
creates a new LdapContext
using environment properties obtained from LdapConfig.getEnvironment()
and then invokes the startTLS extended operation
on the context. SSLSocketFactory
and
HostnameVerifier
properties are used from the
LdapContext
.ConnectionHandler.ConnectionStrategy
config, connectionRetryExceptions, connectionStrategy, context, logger
Constructor and Description |
---|
TlsConnectionHandler()
Default constructor.
|
TlsConnectionHandler(LdapConfig lc)
Creates a new
TlsConnectionHandler with the supplied ldap
config. |
TlsConnectionHandler(TlsConnectionHandler ch)
Copy constructor for
TlsConnectionHandler . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close a connection to an LDAP.
|
protected void |
connectInternal(String authtype,
String dn,
Object credential,
Hashtable<String,Object> env)
Create the initial ldap context and prepare the connection for use.
|
StartTlsResponse |
getStartTlsResponse()
This returns the startTLS response created by a call to
AbstractConnectionHandler.connect(String, Object) . |
boolean |
getStopTlsOnClose()
Returns whether to call
StartTlsResponse.close() when close() is called. |
TlsConnectionHandler |
newInstance()
Returns a separate instance of this connection handler with the same
underlying ldap configuration.
|
void |
setStopTlsOnClose(boolean b)
Sets whether to call
StartTlsResponse.close() when close()
is called. |
StartTlsResponse |
startTls(LdapContext ctx)
This will attempt to StartTLS with the supplied
LdapContext . |
void |
stopTls(StartTlsResponse tls)
This will attempt to StopTLS with the supplied
StartTlsResponse . |
connect, getConnectionCount, getConnectionRetryExceptions, getConnectionStrategy, getLdapConfig, getLdapContext, isConnected, parseLdapUrl, setConnectionCount, setConnectionRetryExceptions, setConnectionStrategy, setLdapConfig
public TlsConnectionHandler()
public TlsConnectionHandler(LdapConfig lc)
TlsConnectionHandler
with the supplied ldap
config.lc
- ldap configpublic TlsConnectionHandler(TlsConnectionHandler ch)
TlsConnectionHandler
.ch
- to copy properties frompublic boolean getStopTlsOnClose()
StartTlsResponse.close()
when close()
is called.public void setStopTlsOnClose(boolean b)
StartTlsResponse.close()
when close()
is called.b
- stop TLS on closepublic StartTlsResponse getStartTlsResponse()
AbstractConnectionHandler.connect(String, Object)
.protected void connectInternal(String authtype, String dn, Object credential, Hashtable<String,Object> env) throws NamingException
connectInternal
in class DefaultConnectionHandler
authtype
- security mechanism to bind withdn
- to bind ascredential
- to bind with in conjunction with dnenv
- to pass to the initial ldap contextNamingException
- if a connection cannot be establishedpublic void close() throws NamingException
close
in interface ConnectionHandler
close
in class AbstractConnectionHandler
NamingException
- if an LDAP error occurspublic StartTlsResponse startTls(LdapContext ctx) throws NamingException
LdapContext
.ctx
- LdapContext
StartTlsResponse
NamingException
- if an error occurs while requesting an extended
operationpublic void stopTls(StartTlsResponse tls) throws NamingException
StartTlsResponse
.tls
- StartTlsResponse
NamingException
- if an error occurs while closing the TLS
connectionpublic TlsConnectionHandler newInstance()
newInstance
in interface ConnectionHandler
newInstance
in class DefaultConnectionHandler
Copyright © 2018. All rights reserved.