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
TlsConnectionHandler
creates a newLdapContext
using environment properties obtained fromLdapConfig.getEnvironment()
and then invokes the startTLS extended operation on the context.SSLSocketFactory
andHostnameVerifier
properties 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 newTlsConnectionHandler
with the supplied ldap config.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close a connection to an LDAP.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)
Create the initial ldap context and prepare the connection for use.javax.naming.ldap.StartTlsResponse
getStartTlsResponse()
This returns the startTLS response created by a call toAbstractConnectionHandler.connect(String, Object)
.boolean
getStopTlsOnClose()
Returns whether to callStartTlsResponse.close()
whenclose()
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 callStartTlsResponse.close()
whenclose()
is called.javax.naming.ldap.StartTlsResponse
startTls(javax.naming.ldap.LdapContext ctx)
This will attempt to StartTLS with the suppliedLdapContext
.void
stopTls(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 newTlsConnectionHandler
with 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.NamingException
Create the initial ldap context and prepare the connection for use.- Overrides:
connectInternal
in 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.NamingException
Close a connection to an LDAP.- Specified by:
close
in interfaceConnectionHandler
- Overrides:
close
in 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.NamingException
This 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.NamingException
This 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:
newInstance
in interfaceConnectionHandler
- Overrides:
newInstance
in classDefaultConnectionHandler
- Returns:
- connection handler
-
-