Package edu.vt.middleware.ldap.handler
Class TlsConnectionHandler
- java.lang.Object
-
- edu.vt.middleware.ldap.handler.AbstractConnectionHandler
-
- edu.vt.middleware.ldap.handler.DefaultConnectionHandler
-
- edu.vt.middleware.ldap.handler.TlsConnectionHandler
-
- All Implemented Interfaces:
ConnectionHandler
public class TlsConnectionHandler extends DefaultConnectionHandler
TlsConnectionHandlercreates a newLdapContextusing environment properties obtained fromLdapConfig.getEnvironment()and then invokes the startTLS extended operation on the context.SSLSocketFactoryandHostnameVerifierproperties are used from theLdapContext.- Version:
- $Revision: 1616 $
- Author:
- Middleware Services
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface edu.vt.middleware.ldap.handler.ConnectionHandler
ConnectionHandler.ConnectionStrategy
-
-
Field Summary
-
Fields inherited from class edu.vt.middleware.ldap.handler.AbstractConnectionHandler
config, connectionRetryExceptions, connectionStrategy, context, logger
-
-
Constructor Summary
Constructors Constructor Description TlsConnectionHandler()Default constructor.TlsConnectionHandler(TlsConnectionHandler ch)Copy constructor forTlsConnectionHandler.TlsConnectionHandler(LdapConfig lc)Creates a newTlsConnectionHandlerwith the supplied ldap config.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close a connection to an LDAP.protected voidconnectInternal(java.lang.String authtype, java.lang.String dn, java.lang.Object credential, java.util.Hashtable<java.lang.String,java.lang.Object> env)Create the initial ldap context and prepare the connection for use.javax.naming.ldap.StartTlsResponsegetStartTlsResponse()This returns the startTLS response created by a call toAbstractConnectionHandler.connect(String, Object).booleangetStopTlsOnClose()Returns whether to callStartTlsResponse.close()whenclose()is called.TlsConnectionHandlernewInstance()Returns a separate instance of this connection handler with the same underlying ldap configuration.voidsetStopTlsOnClose(boolean b)Sets whether to callStartTlsResponse.close()whenclose()is called.javax.naming.ldap.StartTlsResponsestartTls(javax.naming.ldap.LdapContext ctx)This will attempt to StartTLS with the suppliedLdapContext.voidstopTls(javax.naming.ldap.StartTlsResponse tls)This will attempt to StopTLS with the suppliedStartTlsResponse.-
Methods inherited from class edu.vt.middleware.ldap.handler.AbstractConnectionHandler
connect, getConnectionCount, getConnectionRetryExceptions, getConnectionStrategy, getLdapConfig, getLdapContext, isConnected, parseLdapUrl, setConnectionCount, setConnectionRetryExceptions, setConnectionStrategy, setLdapConfig
-
-
-
-
Constructor Detail
-
TlsConnectionHandler
public TlsConnectionHandler()
Default constructor.
-
TlsConnectionHandler
public TlsConnectionHandler(LdapConfig lc)
Creates a newTlsConnectionHandlerwith the supplied ldap config.- Parameters:
lc- ldap config
-
TlsConnectionHandler
public TlsConnectionHandler(TlsConnectionHandler ch)
Copy constructor forTlsConnectionHandler.- Parameters:
ch- to copy properties from
-
-
Method Detail
-
getStopTlsOnClose
public boolean getStopTlsOnClose()
Returns whether to callStartTlsResponse.close()whenclose()is called.- Returns:
- stop TLS on close
-
setStopTlsOnClose
public void setStopTlsOnClose(boolean b)
Sets whether to callStartTlsResponse.close()whenclose()is called.- Parameters:
b- stop TLS on close
-
getStartTlsResponse
public javax.naming.ldap.StartTlsResponse getStartTlsResponse()
This returns the startTLS response created by a call toAbstractConnectionHandler.connect(String, Object).- Returns:
- start tls response
-
connectInternal
protected void connectInternal(java.lang.String authtype, java.lang.String dn, java.lang.Object credential, java.util.Hashtable<java.lang.String,java.lang.Object> env) throws javax.naming.NamingExceptionCreate the initial ldap context and prepare the connection for use.- Overrides:
connectInternalin classDefaultConnectionHandler- Parameters:
authtype- security mechanism to bind withdn- to bind ascredential- to bind with in conjunction with dnenv- to pass to the initial ldap context- Throws:
javax.naming.NamingException- if a connection cannot be established
-
close
public void close() throws javax.naming.NamingExceptionClose a connection to an LDAP.- Specified by:
closein interfaceConnectionHandler- Overrides:
closein classAbstractConnectionHandler- Throws:
javax.naming.NamingException- if an LDAP error occurs
-
startTls
public javax.naming.ldap.StartTlsResponse startTls(javax.naming.ldap.LdapContext ctx) throws javax.naming.NamingExceptionThis will attempt to StartTLS with the suppliedLdapContext.- Parameters:
ctx-LdapContext- Returns:
StartTlsResponse- Throws:
javax.naming.NamingException- if an error occurs while requesting an extended operation
-
stopTls
public void stopTls(javax.naming.ldap.StartTlsResponse tls) throws javax.naming.NamingExceptionThis will attempt to StopTLS with the suppliedStartTlsResponse.- Parameters:
tls-StartTlsResponse- Throws:
javax.naming.NamingException- if an error occurs while closing the TLS connection
-
newInstance
public TlsConnectionHandler newInstance()
Returns a separate instance of this connection handler with the same underlying ldap configuration.- Specified by:
newInstancein interfaceConnectionHandler- Overrides:
newInstancein classDefaultConnectionHandler- Returns:
- connection handler
-
-