Skip to content
Permalink
Browse files
FC-290 - Pool connection validation switch, properly handle defaults …
…by catching conversion exceptions in Config (when property is not set)
  • Loading branch information
shawnmckinney committed Mar 21, 2021
1 parent 88d965c commit 359a5f448a93aa740ae9ff5b4593a2187587d6c6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 18 deletions.
@@ -84,6 +84,18 @@ This section describes the properties needed to control fortress core.
# This is min/max settings for LDAP connections. For testing and low-volume instances this will work:
min.admin.conn=1
max.admin.conn=10
# This speicifes the number of user LDAP connections (used for user authentication operations only) to maintain in the pool:
# User Pool:
user.min.conn=1
user.max.conn=10
# Used for slapd logger connection pool (OpenLDAP with access log enabled only)
min.log.conn=1
max.log.conn=3
# Applies to all pools, connection validated on retrieval with dummy ldapsearch. (default is false)
all.validate.conn=false
```

5. Give coordinates to the Config node that contains all of the other Fortress properties. This will match your LDAP's server's config node per Fortress Core setup.
@@ -329,4 +341,4 @@ This section describes the properties needed to control fortress core.
```

____________________________________________________________________________________
#### END OF README
#### END OF README
@@ -309,7 +309,7 @@
<replace file="${dst.bootstrap.conf}" token="@LOG_MAX_CONN@" value="${log.max.conn}"/>
<replace file="${dst.bootstrap.conf}" token="@USR_MIN_CONN@" value="${user.min.conn}"/>
<replace file="${dst.bootstrap.conf}" token="@USR_MAX_CONN@" value="${user.max.conn}"/>
<replace file="${dst.bootstrap.conf}" token="@VALIDATE_CONN@" value="${validate.conn}"/>
<replace file="${dst.bootstrap.conf}" token="@VALIDATE_CONN@" value="${all.validate.conn}"/>
<replace file="${dst.bootstrap.conf}" token="@CFG_CRYPTO_PROP@" value="${crypto.prop}"/>
<replace file="${dst.bootstrap.conf}" token="@SERVER_TYPE@" value="${ldap.server.type}"/>
<replace file="${dst.bootstrap.conf}" token="@ROLE_OCCUPANTS@" value="${role.occupants}"/>
@@ -347,7 +347,7 @@
<replace file="${dst.remote.conf}" token="@LOG_MIN_CONN@" value="${log.min.conn}"/>
<replace file="${dst.remote.conf}" token="@LOG_MAX_CONN@" value="${log.max.conn}"/>
<replace file="${dst.remote.conf}" token="@USR_MIN_CONN@" value="${user.min.conn}"/>
<replace file="${dst.remote.conf}" token="@VALIDATE_CONN@" value="${validate.conn}"/>
<replace file="${dst.remote.conf}" token="@VALIDATE_CONN@" value="${all.validate.conn}"/>
<replace file="${dst.remote.conf}" token="@USR_MAX_CONN@" value="${user.max.conn}"/>
<replace file="${dst.remote.conf}" token="@CFG_CRYPTO_PROP@" value="${crypto.prop}"/>
<replace file="${dst.remote.conf}" token="@ENABLE_REST@" value="${enable.mgr.impl.rest}"/>
@@ -82,7 +82,7 @@ cfg.root.pw=secret
# This is the default:
ldap.client.type=apache

# A value of 'false' disables storing user membership on role object, default is 'true':
# A value of 'false' disables storing user membership on role object, default is 'false':
#role.occupants=false

# These are used to construct suffix for DIT, i.e. dc=example,dc=com.
@@ -115,12 +115,12 @@ admin.max.conn=10
user.min.conn=1
user.max.conn=10

# Used for slapd logger connection pool. Leave zeros when using apacheds:
# Used for slapd logger connection pool.
min.log.conn=1
max.log.conn=3

# Applies to all pools, connection validated on retrieval with dummy ldapsearch. (default is true)
validate.conn=true
# Applies to all pools, connection validated on retrieval with dummy ldapsearch. (default is false)
all.validate.conn=false

########################################################################
# 3. GROUP OBJECT CLASS DEFINITIONS
@@ -68,12 +68,12 @@ admin.max.conn=10
user.min.conn=1
user.max.conn=10

# Used for slapd logger connection pool. Leave zeros when using apacheds:
# Used for slapd logger connection pool.
log.min.conn=1
log.max.conn=3

# Applies to all pools, connection validated on retrieval with dummy ldapsearch. (default is true)
validate.conn=true
# Applies to all pools, connection validated on retrieval with dummy ldapsearch. (default is false)
all.validate.conn=false

#These are passwords used for LDAP audit log service accounts:
# Audit Pool:
@@ -125,7 +125,7 @@ private void init()
int max = Config.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
int logmin = Config.getInstance().getInt( GlobalIds.LDAP_LOG_POOL_MIN, 1 );
int logmax = Config.getInstance().getInt( GlobalIds.LDAP_LOG_POOL_MAX, 10 );
boolean validate = Config.getInstance().getBoolean( GlobalIds.LDAP_VALIDATE_CONN, true );
boolean validate = Config.getInstance().getBoolean( GlobalIds.LDAP_VALIDATE_CONN, false );
boolean testWhileIdle = Config.getInstance().getBoolean( GlobalIds.LDAP_ADMIN_POOL_TEST_IDLE, true );
boolean logTestWhileIdle = Config.getInstance().getBoolean( GlobalIds.LDAP_LOG_POOL_TEST_IDLE, true );

@@ -274,15 +274,22 @@ public int getInt( String key, int defaultValue )
int value = defaultValue;
try
{

if ( config != null )
{
value = config.getInt( key, defaultValue );
LOG.debug( "getInt name [{}] value [{}]", key, value );
try
{
value = config.getInt( key, defaultValue );
LOG.debug( "getInt name [{}] value [{}]", key, value );
}
catch (org.apache.commons.configuration.ConversionException e )
{
LOG.debug( "getInt name [{}], conversion exception using default [{}]", key, defaultValue );
}
}
else
{
LOG.warn( "getInt invalid config, can't read prop [{}], using default [{}]", key, defaultValue );

}
}
catch (org.apache.commons.configuration.ConversionException e)
@@ -335,15 +342,22 @@ public boolean getBoolean( String key, boolean defaultValue )
{
if ( config != null )
{
value = config.getBoolean( key, defaultValue );
LOG.debug( "getBoolean name [{}] value [{}]", key, value );
try
{
value = config.getBoolean( key, defaultValue );
LOG.debug( "getBoolean name [{}] value [{}]", key, value );
}
catch (org.apache.commons.configuration.ConversionException e )
{
LOG.debug( "getBoolean name [{}], conversion exception using default [{}]", key, defaultValue );
}
}
else
{
LOG.warn( "getBoolean - invalid config, can't read prop [{}], using default [{}]", key, defaultValue );
}
}
catch (java.util.NoSuchElementException e )
catch (java.util.NoSuchElementException nse )
{
LOG.debug( "getBoolean - no such element [{}], using default [{}]", key, defaultValue );
}
@@ -833,4 +847,4 @@ public synchronized Configuration getIncrementReplacePosixIds(List<String> props
}
return inConfig;
}
}
}

0 comments on commit 359a5f4

Please sign in to comment.