edu.vt.middleware.ldap.handler
Class TlsConnectionHandler

java.lang.Object
  extended by edu.vt.middleware.ldap.handler.AbstractConnectionHandler
      extended by edu.vt.middleware.ldap.handler.DefaultConnectionHandler
          extended by edu.vt.middleware.ldap.handler.TlsConnectionHandler
All Implemented Interfaces:
ConnectionHandler

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.

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
TlsConnectionHandler()
          Default constructor.
TlsConnectionHandler(LdapConfig lc)
          Creates a new TlsConnectionHandler with the supplied ldap config.
TlsConnectionHandler(TlsConnectionHandler ch)
          Copy constructor for TlsConnectionHandler.
 
Method Summary
 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.
 
Methods inherited from class edu.vt.middleware.ldap.handler.AbstractConnectionHandler
connect, getConnectionCount, getConnectionRetryExceptions, getConnectionStrategy, getLdapConfig, getLdapContext, isConnected, parseLdapUrl, setConnectionCount, setConnectionRetryExceptions, setConnectionStrategy, setLdapConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TlsConnectionHandler

public TlsConnectionHandler()
Default constructor.


TlsConnectionHandler

public TlsConnectionHandler(LdapConfig lc)
Creates a new TlsConnectionHandler with the supplied ldap config.

Parameters:
lc - ldap config

TlsConnectionHandler

public TlsConnectionHandler(TlsConnectionHandler ch)
Copy constructor for TlsConnectionHandler.

Parameters:
ch - to copy properties from
Method Detail

getStopTlsOnClose

public boolean getStopTlsOnClose()
Returns whether to call StartTlsResponse.close() when close() is called.

Returns:
stop TLS on close

setStopTlsOnClose

public void setStopTlsOnClose(boolean b)
Sets whether to call StartTlsResponse.close() when close() is called.

Parameters:
b - stop TLS on close

getStartTlsResponse

public StartTlsResponse getStartTlsResponse()
This returns the startTLS response created by a call to AbstractConnectionHandler.connect(String, Object).

Returns:
start tls response

connectInternal

protected void connectInternal(String authtype,
                               String dn,
                               Object credential,
                               Hashtable<String,Object> env)
                        throws NamingException
Create the initial ldap context and prepare the connection for use.

Overrides:
connectInternal in class DefaultConnectionHandler
Parameters:
authtype - security mechanism to bind with
dn - to bind as
credential - to bind with in conjunction with dn
env - to pass to the initial ldap context
Throws:
NamingException - if a connection cannot be established

close

public void close()
           throws NamingException
Close a connection to an LDAP.

Specified by:
close in interface ConnectionHandler
Overrides:
close in class AbstractConnectionHandler
Throws:
NamingException - if an LDAP error occurs

startTls

public StartTlsResponse startTls(LdapContext ctx)
                          throws NamingException
This will attempt to StartTLS with the supplied LdapContext.

Parameters:
ctx - LdapContext
Returns:
StartTlsResponse
Throws:
NamingException - if an error occurs while requesting an extended operation

stopTls

public void stopTls(StartTlsResponse tls)
             throws NamingException
This will attempt to StopTLS with the supplied StartTlsResponse.

Parameters:
tls - StartTlsResponse
Throws:
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 interface ConnectionHandler
Overrides:
newInstance in class DefaultConnectionHandler
Returns:
connection handler


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.