edu.vt.middleware.ldap.handler
Class AbstractConnectionHandler

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

public abstract class AbstractConnectionHandler
extends Object
implements ConnectionHandler

AbstractConnectionHandler provides a basic implementation for other connection handlers to inherit.

Version:
$Revision: 1786 $
Author:
Middleware Services

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.vt.middleware.ldap.handler.ConnectionHandler
ConnectionHandler.ConnectionStrategy
 
Field Summary
protected  LdapConfig config
          Ldap configuration.
protected  Class<?>[] connectionRetryExceptions
          Exception types to retry connections on.
protected  ConnectionHandler.ConnectionStrategy connectionStrategy
          Ldap connection strategy.
protected  LdapContext context
          Ldap context.
protected  org.apache.commons.logging.Log logger
          Log for this class.
 
Constructor Summary
AbstractConnectionHandler()
           
 
Method Summary
 void close()
          Close a connection to an LDAP.
 void connect(String dn, Object credential)
          Open a connection to an LDAP.
protected abstract  void connectInternal(String authtype, String dn, Object credential, Hashtable<String,Object> env)
          Create the initial ldap context and prepare the connection for use.
protected  edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount getConnectionCount()
          Returns the connection count.
 Class<?>[] getConnectionRetryExceptions()
          This returns the exception types to retry connections on.
 ConnectionHandler.ConnectionStrategy getConnectionStrategy()
          Returns the connection strategy.
 LdapConfig getLdapConfig()
          Returns the ldap configuration.
 LdapContext getLdapContext()
          Returns an ldap context to use for ldap operations.
 boolean isConnected()
          Returns whether the underlying context has been established.
abstract  ConnectionHandler newInstance()
          Returns a separate instance of this connection handler with the same underlying ldap configuration.
protected  String[] parseLdapUrl(String ldapUrl, ConnectionHandler.ConnectionStrategy strategy)
          Parses the supplied ldap url and splits it into separate URLs if it is space delimited.
protected  void setConnectionCount(edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount cc)
          Sets the connection count.
 void setConnectionRetryExceptions(Class<?>[] exceptions)
          This sets the exception types to retry connections on.
 void setConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)
          Sets the connection strategy.
 void setLdapConfig(LdapConfig lc)
          Sets the ldap configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Log for this class.


config

protected LdapConfig config
Ldap configuration.


context

protected LdapContext context
Ldap context.


connectionStrategy

protected ConnectionHandler.ConnectionStrategy connectionStrategy
Ldap connection strategy.


connectionRetryExceptions

protected Class<?>[] connectionRetryExceptions
Exception types to retry connections on.

Constructor Detail

AbstractConnectionHandler

public AbstractConnectionHandler()
Method Detail

getConnectionCount

protected edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount getConnectionCount()
Returns the connection count.

Returns:
connection count

setConnectionCount

protected void setConnectionCount(edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount cc)
Sets the connection count.

Parameters:
cc - connection count

getConnectionStrategy

public ConnectionHandler.ConnectionStrategy getConnectionStrategy()
Returns the connection strategy.

Specified by:
getConnectionStrategy in interface ConnectionHandler
Returns:
strategy for making connections

setConnectionStrategy

public void setConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)
Sets the connection strategy.

Specified by:
setConnectionStrategy in interface ConnectionHandler
Parameters:
strategy - for making connections

getConnectionRetryExceptions

public Class<?>[] getConnectionRetryExceptions()
This returns the exception types to retry connections on.

Specified by:
getConnectionRetryExceptions in interface ConnectionHandler
Returns:
Class[]

setConnectionRetryExceptions

public void setConnectionRetryExceptions(Class<?>[] exceptions)
This sets the exception types to retry connections on.

Specified by:
setConnectionRetryExceptions in interface ConnectionHandler
Parameters:
exceptions - Class[]

getLdapConfig

public LdapConfig getLdapConfig()
Returns the ldap configuration.

Specified by:
getLdapConfig in interface ConnectionHandler
Returns:
ldap config

setLdapConfig

public void setLdapConfig(LdapConfig lc)
Sets the ldap configuration.

Specified by:
setLdapConfig in interface ConnectionHandler
Parameters:
lc - ldap config

getLdapContext

public LdapContext getLdapContext()
Returns an ldap context to use for ldap operations. ConnectionHandler.connect(String, Object) must be called prior to invoking this.

Specified by:
getLdapContext in interface ConnectionHandler
Returns:
ldap context

connect

public void connect(String dn,
                    Object credential)
             throws NamingException
Open a connection to an LDAP.

Specified by:
connect in interface ConnectionHandler
Parameters:
dn - to attempt bind with
credential - to attempt bind with
Throws:
NamingException - if an LDAP error occurs

connectInternal

protected abstract 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.

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

isConnected

public boolean isConnected()
Returns whether the underlying context has been established.

Specified by:
isConnected in interface ConnectionHandler
Returns:
whether a connection has been made

close

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

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

newInstance

public abstract ConnectionHandler newInstance()
Returns a separate instance of this connection handler with the same underlying ldap configuration.

Specified by:
newInstance in interface ConnectionHandler
Returns:
connection handler

parseLdapUrl

protected String[] parseLdapUrl(String ldapUrl,
                                ConnectionHandler.ConnectionStrategy strategy)
Parses the supplied ldap url and splits it into separate URLs if it is space delimited.

Parameters:
ldapUrl - to parse
strategy - of ordered array to return
Returns:
array of ldap URLs


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