Package edu.vt.middleware.ldap.handler
Class AbstractConnectionHandler
- java.lang.Object
-
- edu.vt.middleware.ldap.handler.AbstractConnectionHandler
-
- All Implemented Interfaces:
ConnectionHandler
- Direct Known Subclasses:
DefaultConnectionHandler
public abstract class AbstractConnectionHandler extends java.lang.Object implements ConnectionHandler
AbstractConnectionHandlerprovides a basic implementation for other connection handlers to inherit.- Version:
- $Revision: 2397 $
- Author:
- Middleware Services
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface edu.vt.middleware.ldap.handler.ConnectionHandler
ConnectionHandler.ConnectionStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected LdapConfigconfigLdap configuration.protected java.lang.Class<?>[]connectionRetryExceptionsException types to retry connections on.protected ConnectionHandler.ConnectionStrategyconnectionStrategyLdap connection strategy.protected javax.naming.ldap.LdapContextcontextLdap context.protected org.apache.commons.logging.LogloggerLog for this class.
-
Constructor Summary
Constructors Constructor Description AbstractConnectionHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Close a connection to an LDAP.voidconnect(java.lang.String dn, java.lang.Object credential)Open a connection to an LDAP.protected abstract 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.protected edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCountgetConnectionCount()Returns the connection count.java.lang.Class<?>[]getConnectionRetryExceptions()This returns the exception types to retry connections on.ConnectionHandler.ConnectionStrategygetConnectionStrategy()Returns the connection strategy.LdapConfiggetLdapConfig()Returns the ldap configuration.javax.naming.ldap.LdapContextgetLdapContext()Returns an ldap context to use for ldap operations.booleanisConnected()Returns whether the underlying context has been established.abstract ConnectionHandlernewInstance()Returns a separate instance of this connection handler with the same underlying ldap configuration.protected java.lang.String[]parseLdapUrl(java.lang.String ldapUrl, ConnectionHandler.ConnectionStrategy strategy)Parses the supplied ldap url and splits it into separate URLs if it is space delimited.protected voidsetConnectionCount(edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount cc)Sets the connection count.voidsetConnectionRetryExceptions(java.lang.Class<?>[] exceptions)This sets the exception types to retry connections on.voidsetConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)Sets the connection strategy.voidsetLdapConfig(LdapConfig lc)Sets the ldap configuration.
-
-
-
Field Detail
-
logger
protected final org.apache.commons.logging.Log logger
Log for this class.
-
config
protected LdapConfig config
Ldap configuration.
-
context
protected javax.naming.ldap.LdapContext context
Ldap context.
-
connectionStrategy
protected ConnectionHandler.ConnectionStrategy connectionStrategy
Ldap connection strategy.
-
connectionRetryExceptions
protected java.lang.Class<?>[] connectionRetryExceptions
Exception types to retry connections on.
-
-
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:
getConnectionStrategyin interfaceConnectionHandler- Returns:
- strategy for making connections
-
setConnectionStrategy
public void setConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)
Sets the connection strategy.- Specified by:
setConnectionStrategyin interfaceConnectionHandler- Parameters:
strategy- for making connections
-
getConnectionRetryExceptions
public java.lang.Class<?>[] getConnectionRetryExceptions()
This returns the exception types to retry connections on.- Specified by:
getConnectionRetryExceptionsin interfaceConnectionHandler- Returns:
Class[]
-
setConnectionRetryExceptions
public void setConnectionRetryExceptions(java.lang.Class<?>[] exceptions)
This sets the exception types to retry connections on.- Specified by:
setConnectionRetryExceptionsin interfaceConnectionHandler- Parameters:
exceptions-Class[]
-
getLdapConfig
public LdapConfig getLdapConfig()
Returns the ldap configuration.- Specified by:
getLdapConfigin interfaceConnectionHandler- Returns:
- ldap config
-
setLdapConfig
public void setLdapConfig(LdapConfig lc)
Sets the ldap configuration.- Specified by:
setLdapConfigin interfaceConnectionHandler- Parameters:
lc- ldap config
-
getLdapContext
public javax.naming.ldap.LdapContext getLdapContext()
Returns an ldap context to use for ldap operations.ConnectionHandler.connect(String, Object)must be called prior to invoking this.- Specified by:
getLdapContextin interfaceConnectionHandler- Returns:
- ldap context
-
connect
public void connect(java.lang.String dn, java.lang.Object credential) throws javax.naming.NamingExceptionOpen a connection to an LDAP.- Specified by:
connectin interfaceConnectionHandler- Parameters:
dn- to attempt bind withcredential- to attempt bind with- Throws:
javax.naming.NamingException- if an LDAP error occurs
-
connectInternal
protected abstract 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.- 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
-
isConnected
public boolean isConnected()
Returns whether the underlying context has been established.- Specified by:
isConnectedin interfaceConnectionHandler- Returns:
- whether a connection has been made
-
close
public void close() throws javax.naming.NamingExceptionClose a connection to an LDAP.- Specified by:
closein interfaceConnectionHandler- Throws:
javax.naming.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:
newInstancein interfaceConnectionHandler- Returns:
- connection handler
-
parseLdapUrl
protected java.lang.String[] parseLdapUrl(java.lang.String ldapUrl, ConnectionHandler.ConnectionStrategy strategy)Parses the supplied ldap url and splits it into separate URLs if it is space delimited.- Parameters:
ldapUrl- to parsestrategy- of ordered array to return- Returns:
- array of ldap URLs
-
-