public class SearchExecutingLdapConnectionLivenessValidator extends Object implements LdapConnectionLivenessValidator
LDAPConnection liveness by executing a search filter
and verifying that the result contains at least one entry. This
strategy is appropriate when LDAPConnection.isConnectionAlive()
is not reliable, e.g. when running against a non-OpenLDAP service
provider.
This particular implementation makes an effort to generate
filters which will be easily traceable in LDAP logs. Generally,
filters take the form
(|(objectclass=*)({attr}={unique-string})). The
search itself is limited by LDAPConnection.SCOPE_BASE,
where "BASE" is specified by baseDn. Often,
baseDn corresponds to the DN of the "system user"
as whom JLDAPDirectoryProvider binds when running
in "autoBind" mode.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_HOST_NAME |
static com.novell.ldap.LDAPSearchConstraints |
DEFAULT_LDAP_CONSTRAINTS |
static String |
DEFAULT_SEARCH_ATTRIBUTE_NAME |
| Constructor and Description |
|---|
SearchExecutingLdapConnectionLivenessValidator() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
formatSearchFilter()
Generates an executable search filter string by injecting
the result of
generateUniqueSearchFilterTerm() into
the current searchFilter. |
protected Object |
generateUniqueSearchFilterTerm()
Generates a portion of the search filter which will (likely) uniquely
identify an execution of that filter.
|
protected String |
generateUniqueToken()
Just returns the current system time in millis.
|
String |
getBaseDn() |
String |
getHostName() |
protected String |
getLocalhostName()
Returns localhost's name as reported by
InetAddress#getLocalHost()#toString(). |
String |
getSearchAttributeName() |
com.novell.ldap.LDAPSearchConstraints |
getSearchConstraints() |
String |
getSearchFilter() |
String |
getSearchStamp() |
ServerConfigurationService |
getServerConfigService() |
void |
init()
Invoke prior to testing any connections.
|
boolean |
isConnectionAlive(com.novell.ldap.LDAPConnection connectionToTest) |
protected String |
newUnformattedSearchFilter() |
void |
setBaseDn(String baseDn) |
void |
setHostName(String hostName)
Assign the host name to be appended to (semi) invocation-unique
search terms.
|
void |
setSearchAttributeName(String searchAttributeName) |
void |
setSearchConstraints(com.novell.ldap.LDAPSearchConstraints searchConstraints) |
void |
setSearchFilter(String searchFilter) |
void |
setSearchStamp(String searchStamp) |
void |
setServerConfigService(ServerConfigurationService serverConfigService) |
public static final String DEFAULT_SEARCH_ATTRIBUTE_NAME
public static final com.novell.ldap.LDAPSearchConstraints DEFAULT_LDAP_CONSTRAINTS
public static final String DEFAULT_HOST_NAME
public SearchExecutingLdapConnectionLivenessValidator()
public void init()
protected String getLocalhostName() throws UnknownHostException
InetAddress#getLocalHost()#toString(). Factored
into a method to enable override during testing.UnknownHostExceptionpublic boolean isConnectionAlive(com.novell.ldap.LDAPConnection connectionToTest)
isConnectionAlive in interface LdapConnectionLivenessValidatorprotected String newUnformattedSearchFilter()
protected String formatSearchFilter()
generateUniqueSearchFilterTerm() into
the current searchFilter. This term is usually
treated as a portion of the value to match against
searchAttributeNameprotected Object generateUniqueSearchFilterTerm()
generateUniqueToken() and the local host
name, separated by a dash ("-").protected String generateUniqueToken()
System.currentTimeMillis()public String getSearchStamp()
public void setSearchStamp(String searchStamp)
public String getSearchAttributeName()
public void setSearchAttributeName(String searchAttributeName)
public String getBaseDn()
public void setBaseDn(String baseDn)
public com.novell.ldap.LDAPSearchConstraints getSearchConstraints()
public void setSearchConstraints(com.novell.ldap.LDAPSearchConstraints searchConstraints)
public String getSearchFilter()
public void setSearchFilter(String searchFilter)
public ServerConfigurationService getServerConfigService()
public void setServerConfigService(ServerConfigurationService serverConfigService)
public String getHostName()
public void setHostName(String hostName)
DEFAULT_HOST_NAME if
argument is null. If this setter is not ivoked,
init() will control the default value.hostName - init()Copyright © 2003–2022 Sakai Project. All rights reserved.