public abstract class AbstractConnectionHandler extends Object implements ConnectionHandler
AbstractConnectionHandler
provides a basic implementation for
other connection handlers to inherit.ConnectionHandler.ConnectionStrategy
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
AbstractConnectionHandler() |
Modifier and Type | Method and Description |
---|---|
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.
|
protected final org.apache.commons.logging.Log logger
protected LdapConfig config
protected LdapContext context
protected ConnectionHandler.ConnectionStrategy connectionStrategy
protected Class<?>[] connectionRetryExceptions
protected edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount getConnectionCount()
protected void setConnectionCount(edu.vt.middleware.ldap.handler.AbstractConnectionHandler.ConnectionCount cc)
cc
- connection countpublic ConnectionHandler.ConnectionStrategy getConnectionStrategy()
getConnectionStrategy
in interface ConnectionHandler
public void setConnectionStrategy(ConnectionHandler.ConnectionStrategy strategy)
setConnectionStrategy
in interface ConnectionHandler
strategy
- for making connectionspublic Class<?>[] getConnectionRetryExceptions()
getConnectionRetryExceptions
in interface ConnectionHandler
Class[]
public void setConnectionRetryExceptions(Class<?>[] exceptions)
setConnectionRetryExceptions
in interface ConnectionHandler
exceptions
- Class[]
public LdapConfig getLdapConfig()
getLdapConfig
in interface ConnectionHandler
public void setLdapConfig(LdapConfig lc)
setLdapConfig
in interface ConnectionHandler
lc
- ldap configpublic LdapContext getLdapContext()
ConnectionHandler.connect(String,
Object)
must be called prior to invoking this.getLdapContext
in interface ConnectionHandler
public void connect(String dn, Object credential) throws NamingException
connect
in interface ConnectionHandler
dn
- to attempt bind withcredential
- to attempt bind withNamingException
- if an LDAP error occursprotected abstract void connectInternal(String authtype, String dn, Object credential, Hashtable<String,Object> env) throws NamingException
authtype
- security mechanism to bind withdn
- to bind ascredential
- to bind with in conjunction with dnenv
- to pass to the initial ldap contextNamingException
- if a connection cannot be establishedpublic boolean isConnected()
isConnected
in interface ConnectionHandler
public void close() throws NamingException
close
in interface ConnectionHandler
NamingException
- if an LDAP error occurspublic abstract ConnectionHandler newInstance()
newInstance
in interface ConnectionHandler
protected String[] parseLdapUrl(String ldapUrl, ConnectionHandler.ConnectionStrategy strategy)
ldapUrl
- to parsestrategy
- of ordered array to returnCopyright © 2018. All rights reserved.