diff --git a/base/server/src/main/java/com/netscape/certsrv/ldap/LdapConnFactory.java b/base/server/src/main/java/com/netscape/certsrv/ldap/LdapConnFactory.java index c28121698de..b971f49b661 100644 --- a/base/server/src/main/java/com/netscape/certsrv/ldap/LdapConnFactory.java +++ b/base/server/src/main/java/com/netscape/certsrv/ldap/LdapConnFactory.java @@ -21,6 +21,8 @@ import org.mozilla.jss.ssl.SSLSocketListener; import com.netscape.cmscore.apps.CMSEngine; +import com.netscape.cmscore.ldapconn.LdapConnInfo; +import com.netscape.cmscore.ldapconn.PKISocketConfig; import com.netscape.cmscore.logging.Auditor; import netscape.ldap.LDAPConnection; @@ -32,11 +34,54 @@ */ public abstract class LdapConnFactory { + public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LdapConnFactory.class); + + public static final String PROP_MINCONNS = "minConns"; + public static final String PROP_MAXCONNS = "maxConns"; + public static final String PROP_MAXRESULTS = "maxResults"; + public static final String PROP_ERROR_IF_DOWN = "errorIfDown"; + + protected String id; + + protected PKISocketConfig config; + protected LdapConnInfo mConnInfo; + + protected int mMinConns = 5; + protected int mMaxConns = 1000; + protected int mMaxResults = 0; + + /** + * number of available conns in array + */ + protected int mNumConns = 0; + + /** + * total num conns + */ + protected int mTotal = 0; + + /** + * return error if server is down at creation time. + */ + protected boolean mErrorIfDown; + + /** + * default value for the above at init time. + */ + protected boolean mDefErrorIfDown; + protected CMSEngine engine; protected Auditor auditor; protected SSLSocketListener socketListener; protected SSLCertificateApprovalCallback approvalCallback; + /** + * returns connection info. + */ + public LdapConnInfo getConnInfo() { + return mConnInfo; + } + public CMSEngine getCMSEngine() { return engine; } @@ -65,8 +110,9 @@ public void setCMSEngine(CMSEngine engine) { * * @return Integer number of free connections. */ - - public abstract int freeConn(); + public synchronized int freeConn() { + return mNumConns; + } /** * Returns the number of total connections available from this pool. @@ -74,14 +120,18 @@ public void setCMSEngine(CMSEngine engine) { * * @return Integer number of total connections. */ - public abstract int totalConn(); + public int totalConn() { + return mTotal; + } /** * Returns the maximum number of connections available from this pool. * * @return Integer maximum number of connections. */ - public abstract int maxConn(); + public int maxConn() { + return mMaxConns; + } /** * Request access to a Ldap connection from the pool. @@ -99,4 +149,9 @@ public void setCMSEngine(CMSEngine engine) { * @exception ELdapException On any failure to return the connection. */ public abstract void returnConn(LDAPConnection conn) throws ELdapException; + + @Override + protected void finalize() throws Exception { + reset(); + } } diff --git a/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java b/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java index e639e959979..dc248ba6928 100644 --- a/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java +++ b/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapAnonConnFactory.java @@ -34,31 +34,8 @@ */ public class LdapAnonConnFactory extends LdapConnFactory { - public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LdapAnonConnFactory.class); - - protected String id; - - PKISocketConfig config; - - protected int mMinConns = 5; - protected int mMaxConns = 1000; - protected int mMaxResults = 0; - protected LdapConnInfo mConnInfo = null; - - public static final String PROP_MINCONNS = "minConns"; - public static final String PROP_MAXCONNS = "maxConns"; - public static final String PROP_MAXRESULTS = "maxResults"; - - public static final String PROP_ERROR_IF_DOWN = "errorIfDown"; - - private int mNumConns = 0; // number of available conns in array - private int mTotal = 0; // total num conns - private AnonConnection mConns[] = null; - - private boolean mInited = false; - - private boolean mErrorIfDown; - private boolean mDefErrorIfDown = false; + AnonConnection[] mConns; + boolean mInited; /** * Constructor for initializing from the config store. @@ -128,22 +105,6 @@ public LdapAnonConnFactory( this.mConnInfo = connInfo; } - - @Override - public int totalConn() { - return mTotal; - } - - @Override - public int freeConn() { - return mNumConns; - } - - @Override - public int maxConn() { - return mMaxConns; - } - public void init(PKISocketConfig config) throws ELdapException { logger.debug("LdapAnonConnFactory: initialization"); @@ -455,19 +416,6 @@ public synchronized void returnConn(LDAPConnection conn) { logger.debug(method + " final values. Total: " + mTotal + ", pool: " + mNumConns); } - @Override - protected void finalize() - throws Exception { - reset(); - } - - /** - * returns connection info. - */ - public LdapConnInfo getConnInfo() { - return mConnInfo; - } - /** * resets this factory - if no connections outstanding, * disconnections all connections and resets everything to 0 as if diff --git a/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java b/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java index 71d50a7a232..16f06cd1ada 100644 --- a/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java +++ b/base/server/src/main/java/com/netscape/cmscore/ldapconn/LdapBoundConnFactory.java @@ -44,44 +44,15 @@ */ public class LdapBoundConnFactory extends LdapConnFactory { - public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LdapBoundConnFactory.class); - - protected String id; - - PKISocketConfig config; - - protected int mMinConns = 5; - protected int mMaxConns = 1000; - protected int mMaxResults = 0; - - protected LdapConnInfo mConnInfo = null; - protected LdapAuthInfo mAuthInfo = null; - PasswordStore passwordStore; - - public static final String PROP_MINCONNS = "minConns"; - public static final String PROP_MAXCONNS = "maxConns"; - public static final String PROP_MAXRESULTS = "maxResults"; public static final String PROP_LDAPCONNINFO = "ldapconn"; public static final String PROP_LDAPAUTHINFO = "ldapauth"; - public static final String PROP_ERROR_IF_DOWN = "errorIfDown"; - - private int mNumConns = 0; // number of available conns in array - private int mTotal = 0; // total num conns - - private boolean doCloning = true; - private LdapBoundConnection mMasterConn = null; // master connection object. - private LdapBoundConnection[] mConns; + LdapAuthInfo mAuthInfo; + PasswordStore passwordStore; - /** - * return error if server is down at creation time. - */ - private boolean mErrorIfDown; - - /** - * default value for the above at init time. - */ - private boolean mDefErrorIfDown = false; + boolean doCloning = true; + LdapBoundConnection mMasterConn; // master connection object. + LdapBoundConnection[] mConns; /** * Constructor for initializing from the config store. @@ -154,21 +125,6 @@ public LdapBoundConnFactory( this.mAuthInfo = authInfo; } - @Override - public int totalConn() { - return mTotal; - } - - @Override - public synchronized int freeConn() { - return mNumConns; - } - - @Override - public int maxConn() { - return mMaxConns; - } - public void init( PKISocketConfig config, PasswordStore passwordStore @@ -562,12 +518,6 @@ public synchronized void returnConn(LDAPConnection conn) { } - @Override - protected void finalize() - throws Exception { - reset(); - } - /** * used for disconnecting all connections and reset everything to 0 * as if connections were never made. used just before a subsystem @@ -636,13 +586,6 @@ public synchronized void shutdown() throws ELdapException { } } - /** - * return ldap connection info - */ - public LdapConnInfo getConnInfo() { - return mConnInfo; - } - /** * return ldap authentication info */