You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by tr...@apache.org on 2014/10/21 19:16:59 UTC
svn commit: r1633415 -
/jackrabbit/oak/branches/1.0/oak-auth-ldap/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/PoolableUnboundConnectionFactory.java
Author: tripod
Date: Tue Oct 21 17:16:59 2014
New Revision: 1633415
URL: http://svn.apache.org/r1633415
Log:
OAK-2213 The unbound connection pool does not verify if the connection is still alive
Modified:
jackrabbit/oak/branches/1.0/oak-auth-ldap/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/PoolableUnboundConnectionFactory.java
Modified: jackrabbit/oak/branches/1.0/oak-auth-ldap/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/PoolableUnboundConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-auth-ldap/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/PoolableUnboundConnectionFactory.java?rev=1633415&r1=1633414&r2=1633415&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-auth-ldap/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/PoolableUnboundConnectionFactory.java (original)
+++ jackrabbit/oak/branches/1.0/oak-auth-ldap/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/PoolableUnboundConnectionFactory.java Tue Oct 21 17:16:59 2014
@@ -19,10 +19,14 @@ package org.apache.jackrabbit.oak.securi
import org.apache.commons.pool.PoolableObjectFactory;
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.LdapConnectionConfig;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -31,6 +35,11 @@ import org.apache.directory.ldap.client.
public class PoolableUnboundConnectionFactory implements PoolableObjectFactory<LdapConnection> {
/**
+ * default logger
+ */
+ private static final Logger log = LoggerFactory.getLogger(PoolableUnboundConnectionFactory.class);
+
+ /**
* configuration object for the connection
*/
private LdapConnectionConfig config;
@@ -49,6 +58,7 @@ public class PoolableUnboundConnectionFa
* {@inheritDoc}
*/
public void activateObject(LdapConnection connection) throws Exception {
+ log.debug("activate connection: {}", connection);
}
@@ -56,6 +66,7 @@ public class PoolableUnboundConnectionFa
* {@inheritDoc}
*/
public void destroyObject(LdapConnection connection) throws Exception {
+ log.debug("destroy connection: {}", connection);
connection.close();
}
@@ -68,6 +79,7 @@ public class PoolableUnboundConnectionFa
? new TlsGuardingConnection(config)
: new LdapNetworkConnection(config);
connection.connect();
+ log.debug("creating new connection: {}", connection);
return connection;
}
@@ -76,6 +88,7 @@ public class PoolableUnboundConnectionFa
* {@inheritDoc}
*/
public void passivateObject(LdapConnection connection) throws Exception {
+ log.debug("passivate connection: {}", connection);
}
@@ -83,7 +96,16 @@ public class PoolableUnboundConnectionFa
* {@inheritDoc}
*/
public boolean validateObject(LdapConnection connection) {
- return connection.isConnected();
+ boolean valid = false;
+ if (connection.isConnected()) {
+ try {
+ valid = connection.lookup(Dn.ROOT_DSE, SchemaConstants.NO_ATTRIBUTE) != null;
+ } catch (LdapException le) {
+ log.debug("error during connection validation: {}", le.toString());
+ }
+ }
+ log.debug("validating connection {}: {}", connection, valid);
+ return valid;
}
/**