You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by cp...@apache.org on 2016/05/05 13:49:18 UTC
[01/15] directory-fortress-core git commit: changed singleton pattern
Repository: directory-fortress-core
Updated Branches:
refs/heads/master 7f7cd61f6 -> 2431eb886
changed singleton pattern
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/2ebaebb7
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/2ebaebb7
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/2ebaebb7
Branch: refs/heads/master
Commit: 2ebaebb733b5187889f39f02706a9f46c0abc364
Parents: b9fe1b9
Author: clp207 <cl...@psu.edu>
Authored: Wed Mar 16 08:45:18 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Tue Apr 19 13:22:52 2016 -0400
----------------------------------------------------------------------
.../directory/fortress/core/util/Config.java | 46 ++++++++++++--------
1 file changed, 28 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/2ebaebb7/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index a9e51d3..086811e 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -26,16 +26,15 @@ import java.util.Properties;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.ConfigMgr;
-import org.apache.directory.fortress.core.ConfigMgrFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.directory.fortress.core.CfgException;
import org.apache.directory.fortress.core.CfgRuntimeException;
+import org.apache.directory.fortress.core.ConfigMgr;
+import org.apache.directory.fortress.core.ConfigMgrFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class wraps <a href="http://commons.apache.org/cfg/">Apache Commons Config</a> utility and is used by internal components to retrieve name-value
@@ -68,11 +67,21 @@ public final class Config
private static final String EXT_CONFIG_REALM = "fortress.config.realm";
private static final String EXT_CONFIG_ROOT_DN = "fortress.config.root";
private static final String EXT_SERVER_TYPE = "fortress.ldap.server.type";
- private static final PropertiesConfiguration config;
+ private static PropertiesConfiguration config;
private static final String CLS_NM = Config.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- static
+ private static Config INSTANCE = null;
+
+ public static Config getInstance() {
+ if(INSTANCE == null) {
+ LOG.info("Creating new instance");
+ INSTANCE = new Config();
+ }
+ return INSTANCE;
+ }
+
+ private void init()
{
try
{
@@ -145,6 +154,7 @@ public final class Config
*/
private Config()
{
+ init();
}
/**
@@ -153,7 +163,7 @@ public final class Config
* @param name contains the name of the property.
* @return contains the value associated with the property or null if not not found.
*/
- public static String getProperty( String name )
+ public String getProperty( String name )
{
String value = null;
if ( config != null )
@@ -176,7 +186,7 @@ public final class Config
* @param defaultValue specified by client will be returned if property value is not found.
* @return contains the value for the property as a String.
*/
- public static String getProperty( String name, String defaultValue )
+ public String getProperty( String name, String defaultValue )
{
String value = null;
if ( config != null )
@@ -202,7 +212,7 @@ public final class Config
* @param name contains the name of the property.
* @return contains the value associated with the property or 0 if not not found.
*/
- public static char getChar( String name )
+ public char getChar( String name )
{
char value = 0;
if ( config != null )
@@ -225,7 +235,7 @@ public final class Config
* @param defaultValue specified by client will be returned if property value is not found.
* @return contains the value for the property as a char.
*/
- public static char getChar( String name, char defaultValue )
+ public char getChar( String name, char defaultValue )
{
char value = 0;
if ( config != null )
@@ -251,7 +261,7 @@ public final class Config
* @param key name of the property name.
* @return The int value or 0 if not found.
*/
- public static int getInt( String key )
+ public int getInt( String key )
{
int value = 0;
if ( config != null )
@@ -274,7 +284,7 @@ public final class Config
* @param defaultValue to use if property not found.
* @return The int value or default value if not found.
*/
- public static int getInt( String key, int defaultValue )
+ public int getInt( String key, int defaultValue )
{
int value = 0;
if ( config != null )
@@ -296,7 +306,7 @@ public final class Config
* @param key name of the property name.
* @return The boolean value or false if not found.
*/
- public static boolean getBoolean( String key )
+ public boolean getBoolean( String key )
{
boolean value = false;
if ( config != null )
@@ -319,7 +329,7 @@ public final class Config
* @param defaultValue specified by client will be returned if property value is not found.
* @return The boolean value or false if not found.
*/
- public static boolean getBoolean( String key, boolean defaultValue )
+ public boolean getBoolean( String key, boolean defaultValue )
{
boolean value = defaultValue;
if ( config != null )
@@ -341,7 +351,7 @@ public final class Config
* @param name contains the name of the property.
* @param value contains the String value of the property.
*/
- public static void setProperty( String name, String value )
+ public void setProperty( String name, String value )
{
if ( config != null )
{
@@ -363,7 +373,7 @@ public final class Config
* @throws org.apache.directory.fortress.core.SecurityException
* in the event of system or validation error.
*/
- private static Properties getRemoteConfig( String realmName ) throws SecurityException
+ private Properties getRemoteConfig( String realmName ) throws SecurityException
{
Properties props = null;
try
@@ -391,7 +401,7 @@ public final class Config
* This method is called during configuration initialization. It determines if
* the ldap connection coordinates have been overridden as system properties.
*/
- private static void getExternalConfig()
+ private void getExternalConfig()
{
String PREFIX = "getExternalConfig override name [{}] value [{}]";
// Check to see if the ldap host has been overridden by a system property:
[02/15] directory-fortress-core git commit: refactored to not use
static initialization blocks
Posted by cp...@apache.org.
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/PwPolicyMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/PwPolicyMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/PwPolicyMgrRestImpl.java
index 42c3bf9..a2a94b8 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/PwPolicyMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/PwPolicyMgrRestImpl.java
@@ -20,17 +20,17 @@
package org.apache.directory.fortress.core.rest;
+import java.util.List;
+
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.PwPolicyMgr;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
-import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.PwPolicy;
import org.apache.directory.fortress.core.util.VUtil;
-import java.util.List;
-
/**
* This class is used to perform administrative and review functions on the PWPOLICIES and USERS data sets using HTTP access to En Masse REST server.
@@ -82,7 +82,7 @@ public class PwPolicyMgrRestImpl extends Manageable implements PwPolicyMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PSWD_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PSWD_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -107,7 +107,7 @@ public class PwPolicyMgrRestImpl extends Manageable implements PwPolicyMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PSWD_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PSWD_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -132,7 +132,7 @@ public class PwPolicyMgrRestImpl extends Manageable implements PwPolicyMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PSWD_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PSWD_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -158,7 +158,7 @@ public class PwPolicyMgrRestImpl extends Manageable implements PwPolicyMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PSWD_READ );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PSWD_READ );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -189,7 +189,7 @@ public class PwPolicyMgrRestImpl extends Manageable implements PwPolicyMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PSWD_SEARCH );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PSWD_SEARCH );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -222,7 +222,7 @@ public class PwPolicyMgrRestImpl extends Manageable implements PwPolicyMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PSWD_USER_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PSWD_USER_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -247,7 +247,7 @@ public class PwPolicyMgrRestImpl extends Manageable implements PwPolicyMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PSWD_USER_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PSWD_USER_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
index af1ed59..0325b35 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
@@ -36,15 +36,24 @@ import javax.xml.bind.Unmarshaller;
import org.apache.cxf.common.util.Base64Utility;
import org.apache.cxf.helpers.IOUtils;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.RestException;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
+import org.apache.directory.fortress.core.model.ObjectFactory;
+import org.apache.directory.fortress.core.model.Props;
+import org.apache.directory.fortress.core.util.Config;
+import org.apache.directory.fortress.core.util.crypto.EncryptUtil;
import org.apache.http.HttpEntity;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.methods.*;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -52,13 +61,6 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
-import org.apache.directory.fortress.core.RestException;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.model.Props;
-import org.apache.directory.fortress.core.util.crypto.EncryptUtil;
-
/**
* This utility class provides methods that wrap Apache's HTTP Client APIs. This class is thread safe.
@@ -69,16 +71,15 @@ public class RestUtils
{
private static final String CLS_NM = RestUtils.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static final String HTTP_UID = Config.getProperty( "http.user" );
+ private String HTTP_UID;
private static final String HTTP_PW_PARAM = "http.pw";
- private static final String HTTP_PW = ( ( EncryptUtil.isEnabled() ) ? EncryptUtil.decrypt( Config
- .getProperty( HTTP_PW_PARAM ) ) : Config.getProperty( HTTP_PW_PARAM ) );
- private static final String HTTP_HOST = Config.getProperty( "http.host" );
- private static final String HTTP_PORT = Config.getProperty( "http.port" );
- private static final String HTTP_PROTOCOL = Config.getProperty( "http.protocol", "http" );
+ private String HTTP_PW;
+ private String HTTP_HOST;
+ private String HTTP_PORT;
+ private String HTTP_PROTOCOL;
private static final String VERSION = System.getProperty( "version" );
private static final String SERVICE = "fortress-rest-" + VERSION;
- private static final String URI = HTTP_PROTOCOL + "://" + HTTP_HOST + ":" + HTTP_PORT + "/" + SERVICE + "/";
+ private String URI = HTTP_PROTOCOL + "://" + HTTP_HOST + ":" + HTTP_PORT + "/" + SERVICE + "/";
private static final int HTTP_OK = 200;
private static final int HTTP_401_UNAUTHORIZED = 401;
private static final int HTTP_403_FORBIDDEN = 403;
@@ -89,15 +90,39 @@ public class RestUtils
* Used to manage trust store properties. If enabled, create SSL connection.
*
*/
- private static final String TRUST_STORE = Config.getProperty( "trust.store" );
- private static final String TRUST_STORE_PW = Config.getProperty( "trust.store.password" );
- private static final String SET_TRUST_STORE_PROP = "trust.store.set.prop";
- private static final boolean IS_SET_TRUST_STORE_PROP = (
- Config.getProperty( SET_TRUST_STORE_PROP ) != null &&
- Config.getProperty( SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
-
- static
+ private String TRUST_STORE;
+ private String TRUST_STORE_PW;
+ private static String SET_TRUST_STORE_PROP = "trust.store.set.prop";
+ private boolean IS_SET_TRUST_STORE_PROP;
+
+ private static volatile RestUtils INSTANCE = null;
+
+ public static RestUtils getInstance() {
+ if(INSTANCE == null) {
+ synchronized (RestUtils.class) {
+ if(INSTANCE == null){
+ INSTANCE = new RestUtils();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ private void init()
{
+ HTTP_UID = Config.getInstance().getProperty( "http.user" );
+ HTTP_PW = ( ( EncryptUtil.isEnabled() ) ? EncryptUtil.getInstance().decrypt( Config
+ .getInstance().getProperty( HTTP_PW_PARAM ) ) : Config.getInstance().getProperty( HTTP_PW_PARAM ) );
+ HTTP_HOST = Config.getInstance().getProperty( "http.host" );
+ HTTP_PORT = Config.getInstance().getProperty( "http.port" );
+ HTTP_PROTOCOL = Config.getInstance().getProperty( "http.protocol", "http" );
+ TRUST_STORE = Config.getInstance().getProperty( "trust.store" );
+ TRUST_STORE_PW = Config.getInstance().getProperty( "trust.store.password" );
+ IS_SET_TRUST_STORE_PROP = (
+ Config.getInstance().getProperty( SET_TRUST_STORE_PROP ) != null &&
+ Config.getInstance().getProperty( SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
+
+
if ( IS_SET_TRUST_STORE_PROP )
{
LOG.info( "Set JSSE truststore properties:" );
@@ -107,7 +132,10 @@ public class RestUtils
}
}
-
+ private RestUtils(){
+ init();
+ }
+
/**
* Marshall the request into an XML String.
*
@@ -182,7 +210,7 @@ public class RestUtils
* @return String containing response
* @throws RestException
*/
- public static String get( String userId, String password, String id, String id2, String id3, String function )
+ public String get( String userId, String password, String id, String id2, String id3, String function )
throws RestException
{
String url = URI + function + "/" + id;
@@ -212,7 +240,7 @@ public class RestUtils
* @return String containing response
* @throws RestException
*/
- public static String get( String id, String id2, String id3, String function ) throws RestException
+ public String get( String id, String id2, String id3, String function ) throws RestException
{
return get( null, null, id, id2, id3, function );
}
@@ -228,7 +256,7 @@ public class RestUtils
* @return String containing response
* @throws RestException
*/
- public static String post( String userId, String password, String szInput, String function ) throws RestException
+ public String post( String userId, String password, String szInput, String function ) throws RestException
{
LOG.debug( "post URI=[{}], function=[{}], request=[{}]", URI, function, szInput );
String szResponse = null;
@@ -309,12 +337,12 @@ public class RestUtils
* @return String containing response
* @throws RestException
*/
- public static String post( String szInput, String function ) throws RestException
+ public String post( String szInput, String function ) throws RestException
{
return post(null,null,szInput, function);
}
- private static CredentialsProvider getCredentialProvider(String uid, String password) {
+ private CredentialsProvider getCredentialProvider(String uid, String password) {
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials( new AuthScope(HTTP_HOST,Integer.valueOf(HTTP_PORT)),
new UsernamePasswordCredentials(uid==null?HTTP_UID:uid,password==null?HTTP_PW:password) );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
index 9edda65..39862bb 100755
--- a/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/ReviewMgrRestImpl.java
@@ -19,12 +19,17 @@
*/
package org.apache.directory.fortress.core.rest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.ReviewMgr;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
-import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.OrgUnit;
import org.apache.directory.fortress.core.model.PermObj;
import org.apache.directory.fortress.core.model.Permission;
@@ -34,11 +39,6 @@ import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
import org.apache.directory.fortress.core.util.VUtil;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
/**
* This class performs administrative review functions on already provisioned Fortress RBAC entities using HTTP access to En Masse REST server.
* These APIs map directly to similar named APIs specified by ANSI and NIST RBAC models.
@@ -96,7 +96,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -127,7 +127,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.OBJ_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -158,7 +158,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -189,7 +189,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_OBJ_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_OBJ_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -220,7 +220,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_SEARCH_ANY);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_SEARCH_ANY);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -251,7 +251,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.OBJ_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -284,7 +284,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.OBJ_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -315,7 +315,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -346,7 +346,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -378,7 +378,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -409,7 +409,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -440,7 +440,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -473,7 +473,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -505,7 +505,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -537,7 +537,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_ASGNED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -573,7 +573,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_ASGNED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -604,7 +604,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_ASGNED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -635,7 +635,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_ASGNED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -666,7 +666,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_AUTHZED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_AUTHZED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -701,7 +701,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_AUTHZED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_AUTHZED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -746,7 +746,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_PERMS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_PERMS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -777,7 +777,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_PERMS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_PERMS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -808,7 +808,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_ROLES);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -839,7 +839,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_ROLES_AUTHZED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ROLES_AUTHZED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -872,7 +872,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_USERS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_USERS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -903,7 +903,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_USERS_AUTHZED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_USERS_AUTHZED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -936,7 +936,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.SSD_ROLE_SETS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_ROLE_SETS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -971,7 +971,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.SSD_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1001,7 +1001,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.SSD_SETS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_SETS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1036,7 +1036,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.SSD_ROLES);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1069,7 +1069,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.SSD_CARD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_CARD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1100,7 +1100,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.DSD_ROLE_SETS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_ROLE_SETS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1135,7 +1135,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.DSD_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1165,7 +1165,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.DSD_SETS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_SETS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1200,7 +1200,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.DSD_ROLES);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -1233,7 +1233,7 @@ public class ReviewMgrRestImpl extends Manageable implements ReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.DSD_CARD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_CARD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index 086811e..d3d773d 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -71,12 +71,15 @@ public final class Config
private static final String CLS_NM = Config.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static Config INSTANCE = null;
+ private static volatile Config INSTANCE = null;
public static Config getInstance() {
if(INSTANCE == null) {
- LOG.info("Creating new instance");
- INSTANCE = new Config();
+ synchronized (Config.class) {
+ if(INSTANCE == null){
+ INSTANCE = new Config();
+ }
+ }
}
return INSTANCE;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/util/RegExUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/RegExUtil.java b/src/main/java/org/apache/directory/fortress/core/util/RegExUtil.java
index db57530..a4f0a65 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/RegExUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/RegExUtil.java
@@ -20,6 +20,9 @@
package org.apache.directory.fortress.core.util;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.apache.directory.api.util.Strings;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
@@ -27,9 +30,6 @@ import org.apache.directory.fortress.core.ValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
/**
* Regular expression utilities to perform data validations on Fortress attributes. These utils use the standard
@@ -41,11 +41,26 @@ final class RegExUtil
{
private static final String CLS_NM = RegExUtil.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static final String SAFE_TEXT_PATTERN_STRING = Config.getProperty( GlobalIds.REG_EX_SAFE_TEXT );
+ private String SAFE_TEXT_PATTERN_STRING;
private static Pattern safeTextPattern;
- static
+ private static volatile RegExUtil INSTANCE = null;
+
+ public static RegExUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (RegExUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new RegExUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ private void init()
{
+ SAFE_TEXT_PATTERN_STRING = Config.getInstance().getProperty( GlobalIds.REG_EX_SAFE_TEXT );
+
if ( ( SAFE_TEXT_PATTERN_STRING != null ) && ( SAFE_TEXT_PATTERN_STRING.length() != 0 ) )
{
safeTextPattern = Pattern.compile( SAFE_TEXT_PATTERN_STRING );
@@ -58,6 +73,7 @@ final class RegExUtil
*/
private RegExUtil()
{
+ init();
}
/**
@@ -66,7 +82,7 @@ final class RegExUtil
* @param value Contains the string to check.
* @exception org.apache.directory.fortress.core.ValidationException In the event the data validation fails.
*/
- static void safeText( String value ) throws ValidationException
+ void safeText( String value ) throws ValidationException
{
if ( Strings.isEmpty( SAFE_TEXT_PATTERN_STRING ) )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/VUtil.java b/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
index 6dbcd66..9092fca 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
@@ -31,8 +31,11 @@ import java.util.Properties;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.*;
+import org.apache.directory.fortress.core.CfgException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.ValidationException;
import org.apache.directory.fortress.core.model.Constraint;
import org.apache.directory.fortress.core.model.ConstraintValidator;
import org.apache.directory.fortress.core.model.ObjectFactory;
@@ -72,7 +75,7 @@ public final class VUtil implements ConstraintValidator
private static int maximumFieldLen = 130;
private static final String VALIDATE_LENGTH = "field.length";
private static List<Validator> validators;
- private static final String DSDVALIDATOR = Config.getProperty( GlobalIds.DSD_VALIDATOR_PROP );
+ private String DSDVALIDATOR;
private static final int MAXIMUM_FIELD_LEN = maximumFieldLen;
private static final int maxFieldLength = MAXIMUM_FIELD_LEN;
@@ -86,10 +89,23 @@ public final class VUtil implements ConstraintValidator
private static final SimpleDateFormat TIME_FORMATER = new SimpleDateFormat( TIME_FORMAT );
private static final SimpleDateFormat DATE_FORMATER = new SimpleDateFormat( DATE_FORMAT );
+ private static volatile VUtil INSTANCE = null;
+
+ public static VUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (VUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new VUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
/**
* static initializer retrieves Validators names from config and constructs for later processing.
*/
- static
+ private void init()
{
try
{
@@ -100,7 +116,8 @@ public final class VUtil implements ConstraintValidator
LOG.error( "static initialzier caught SecurityException=" + ex.getMessage(), ex );
}
- String lengthProp = Config.getProperty( VALIDATE_LENGTH );
+ Config.getInstance().getProperty( GlobalIds.DSD_VALIDATOR_PROP );
+ String lengthProp = Config.getInstance().getProperty( VALIDATE_LENGTH );
if ( lengthProp != null )
{
@@ -115,6 +132,7 @@ public final class VUtil implements ConstraintValidator
*/
private VUtil()
{
+ init();
}
/**
@@ -184,7 +202,7 @@ public final class VUtil implements ConstraintValidator
throw new ValidationException( GlobalErrIds.CONST_DESC_LEN_INVLD, error );
}
- RegExUtil.safeText( value );
+ RegExUtil.getInstance().safeText( value );
}
@@ -211,7 +229,7 @@ public final class VUtil implements ConstraintValidator
throw new ValidationException( GlobalErrIds.CONST_INVLD_FIELD_LEN, error );
}
- RegExUtil.safeText( value );
+ RegExUtil.getInstance().safeText( value );
}
@@ -539,7 +557,7 @@ public final class VUtil implements ConstraintValidator
* @param checkDsd will check DSD constraints if true
* @throws org.apache.directory.fortress.core.SecurityException in the event validation fails for User or system error occurs.
*/
- public static void validateConstraints( Session session, ConstraintType type, boolean checkDsd )
+ public void validateConstraints( Session session, ConstraintType type, boolean checkDsd )
throws SecurityException
{
String location = "validateConstraints";
@@ -640,14 +658,14 @@ public final class VUtil implements ConstraintValidator
* @return list of type {@link Validator} containing all active validation routines for entity constraint processing.
* @throws org.apache.directory.fortress.core.CfgException in the event validator cannot be instantiated.
*/
- private static List<Validator> getValidators()
+ private List<Validator> getValidators()
throws CfgException
{
List<Validator> validators = new ArrayList<>();
for ( int i = 0;; i++ )
{
String prop = GlobalIds.VALIDATOR_PROPS + i;
- String className = Config.getProperty( prop );
+ String className = Config.getInstance().getProperty( prop );
if ( className == null )
{
break;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
index 8a5091e..95dc7f3 100644
--- a/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
@@ -20,11 +20,12 @@
package org.apache.directory.fortress.core.util.cache;
import net.sf.ehcache.CacheManager;
+
import org.apache.directory.fortress.core.CfgException;
import org.apache.directory.fortress.core.CfgRuntimeException;
import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,13 +40,29 @@ public final class CacheMgr
{
private static final Logger LOG = LoggerFactory.getLogger( CacheMgr.class.getName() );
private static final String EHCACHE_CONFIG_FILE = "ehcache.config.file";
- private final CacheManager mEhCacheImpl;
- private static CacheMgr mFtCacheImpl;
-
- static
+ private CacheManager mEhCacheImpl;
+
+ private static volatile CacheMgr INSTANCE = null;
+
+ /**
+ * Create or return the fortress cache manager reference.
+ * @return handle to the cache manager in effect for process.
+ */
+ public static CacheMgr getInstance() {
+ if(INSTANCE == null) {
+ synchronized (CacheMgr.class) {
+ if(INSTANCE == null){
+ INSTANCE = new CacheMgr();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ private void init()
{
// Use default name of 'ehache.xml':
- String cacheConfig = Config.getProperty( EHCACHE_CONFIG_FILE, "ehcache.xml" );
+ String cacheConfig = Config.getInstance().getProperty( EHCACHE_CONFIG_FILE, "ehcache.xml" );
try
{
// This static block performs the following:
@@ -53,7 +70,7 @@ public final class CacheMgr
// 2. Requires location of ehcache's config file as parameter.
// 3. The CacheManager reference then gets passed to constructor of self.
// 4. Store the reference of self as a static member variable of this class.
- mFtCacheImpl = new CacheMgr( new CacheManager( ClassUtil.resourceAsStream( cacheConfig ) ) );
+ mEhCacheImpl = new CacheManager( ClassUtil.resourceAsStream( cacheConfig ) );
}
catch(CfgException ce)
{
@@ -68,18 +85,9 @@ public final class CacheMgr
*
* @param cacheMangerImpl contains a reference to cache implementation manager.
*/
- private CacheMgr( CacheManager cacheMangerImpl )
- {
- mEhCacheImpl = cacheMangerImpl;
- }
-
- /**
- * Create or return the fortress cache manager reference.
- * @return handle to the cache manager in effect for process.
- */
- public static CacheMgr getInstance()
+ private CacheMgr()
{
- return mFtCacheImpl;
+ init();
}
/**
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
index c638e3c..bf5d516 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
@@ -29,12 +29,26 @@ import org.jasypt.util.text.BasicTextEncryptor;
*/
public final class EncryptUtil
{
- private static final BasicTextEncryptor textEncryptor;
+ private BasicTextEncryptor textEncryptor;
private static final String CRYPTO_PROP = "crypto.prop";
- static
+
+ private static volatile EncryptUtil INSTANCE = null;
+
+ public static EncryptUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (EncryptUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new EncryptUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ private void init()
{
textEncryptor = new BasicTextEncryptor();
- textEncryptor.setPassword(Config.getProperty(CRYPTO_PROP, "adlfarerovcja;39 d"));
+ textEncryptor.setPassword(Config.getInstance().getProperty(CRYPTO_PROP, "adlfarerovcja;39 d"));
}
/**
@@ -43,6 +57,7 @@ public final class EncryptUtil
*/
private EncryptUtil()
{
+ init();
}
/**
@@ -54,7 +69,7 @@ public final class EncryptUtil
{
if(args[0] != null && args[0].length() > 0)
{
- String encryptedValue = textEncryptor.encrypt(args[0]);
+ String encryptedValue = EncryptUtil.getInstance().encrypt(args[0]);
System.out.println("Encrypted value=" + encryptedValue);
}
}
@@ -69,7 +84,7 @@ public final class EncryptUtil
public static boolean isEnabled()
{
boolean result = false;
- if(Config.getProperty(CRYPTO_PROP)!= null && !Config.getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
+ if(Config.getInstance().getProperty(CRYPTO_PROP)!= null && !Config.getInstance().getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
{
result = true;
}
@@ -83,7 +98,7 @@ public final class EncryptUtil
* @param clearText contains the text to be encrypted.
* @return String containing encrypted text.
*/
- public static String encrypt(String clearText)
+ public String encrypt(String clearText)
{
return textEncryptor.encrypt(clearText);
}
@@ -94,7 +109,7 @@ public final class EncryptUtil
* @param encryptedText contains the text to be decrypted.
* @return String containing decrypted text.
*/
- public static String decrypt(String encryptedText)
+ public String decrypt(String encryptedText)
{
return textEncryptor.decrypt(encryptedText);
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/test/java/org/apache/directory/fortress/core/AdminMgrConsole.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/AdminMgrConsole.java b/src/test/java/org/apache/directory/fortress/core/AdminMgrConsole.java
index 9020ac3..3e13735 100755
--- a/src/test/java/org/apache/directory/fortress/core/AdminMgrConsole.java
+++ b/src/test/java/org/apache/directory/fortress/core/AdminMgrConsole.java
@@ -19,38 +19,38 @@
*/
package org.apache.directory.fortress.core;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.example.Example;
import org.apache.directory.fortress.core.example.ExampleAdminMgr;
import org.apache.directory.fortress.core.example.ExampleAdminMgrFactory;
import org.apache.directory.fortress.core.impl.MyAnnotation;
import org.apache.directory.fortress.core.impl.PolicyTestData;
+import org.apache.directory.fortress.core.impl.TestUtils;
+import org.apache.directory.fortress.core.model.Constraint;
import org.apache.directory.fortress.core.model.Hier;
import org.apache.directory.fortress.core.model.PermObj;
+import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Relationship;
import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.SDSet;
import org.apache.directory.fortress.core.model.Session;
-import org.apache.directory.fortress.core.impl.TestUtils;
-import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
-import org.apache.directory.fortress.core.model.Constraint;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.fortress.core.util.Config;
import org.jgrapht.UndirectedGraph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.SimpleDirectedGraph;
import org.jgrapht.graph.SimpleGraph;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -584,7 +584,7 @@ class AdminMgrConsole
ReaderUtil.clearScreen();
System.out.println("Enter config name");
String name = ReaderUtil.readLn();
- String value = Config.getProperty(name);
+ String value = Config.getInstance().getProperty(name);
//ra.addUser(ue);
System.out.println("AdminMgrConsole.testConfig name [" + name + "] value [" + value + "]");
ReaderUtil.readChar();
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/test/java/org/apache/directory/fortress/core/EncryptMgrConsole.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/EncryptMgrConsole.java b/src/test/java/org/apache/directory/fortress/core/EncryptMgrConsole.java
index 4aa4ea8..11d50d0 100755
--- a/src/test/java/org/apache/directory/fortress/core/EncryptMgrConsole.java
+++ b/src/test/java/org/apache/directory/fortress/core/EncryptMgrConsole.java
@@ -34,7 +34,7 @@ class EncryptMgrConsole
ReaderUtil.clearScreen();
System.out.println("Enter text to encrypt:");
String text = ReaderUtil.readLn();
- String myEncryptedText = EncryptUtil.encrypt(text);
+ String myEncryptedText = EncryptUtil.getInstance().encrypt(text);
System.out.println("Encrypted value=" + myEncryptedText);
ReaderUtil.readChar();
}
@@ -45,7 +45,7 @@ class EncryptMgrConsole
ReaderUtil.clearScreen();
System.out.println("Enter text to decrypt:");
String text = ReaderUtil.readLn();
- String plainText = EncryptUtil.decrypt(text);
+ String plainText = EncryptUtil.getInstance().decrypt(text);
System.out.println("Unencrypted value=" + plainText);
ReaderUtil.readChar();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/test/java/org/apache/directory/fortress/core/example/ExampleAdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/example/ExampleAdminMgrFactory.java b/src/test/java/org/apache/directory/fortress/core/example/ExampleAdminMgrFactory.java
index 5228ba9..8c67de5 100755
--- a/src/test/java/org/apache/directory/fortress/core/example/ExampleAdminMgrFactory.java
+++ b/src/test/java/org/apache/directory/fortress/core/example/ExampleAdminMgrFactory.java
@@ -20,8 +20,8 @@
package org.apache.directory.fortress.core.example;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
/**
* Factory class used to instantiate the ExampleAdminMgrImpl.
@@ -31,7 +31,7 @@ import org.apache.directory.fortress.core.util.ClassUtil;
*/
public class ExampleAdminMgrFactory
{
- private static String exampleAdminClassName = Config.getProperty( EIds.EXAMPLE_ADMIN_IMPLEMENTATION );
+ private static String exampleAdminClassName = Config.getInstance().getProperty( EIds.EXAMPLE_ADMIN_IMPLEMENTATION );
public static ExampleAdminMgr createInstance()
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java b/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java
index fe4c226..e46d2d2 100755
--- a/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java
+++ b/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java
@@ -19,6 +19,10 @@
*/
package org.apache.directory.fortress.core.example;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.cursor.CursorException;
import org.apache.directory.api.ldap.model.cursor.SearchCursor;
@@ -31,21 +35,17 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.fortress.core.CreateException;
import org.apache.directory.fortress.core.FinderException;
import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
-import org.apache.directory.fortress.core.model.ConstraintUtil;
-import org.apache.directory.ldap.client.api.LdapConnection;
-import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.CreateException;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
+import org.apache.directory.fortress.core.model.ConstraintUtil;
import org.apache.directory.fortress.core.util.Config;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.slf4j.LoggerFactory;
public class ExampleDAO extends LdapDataProvider
@@ -66,7 +66,7 @@ public class ExampleDAO extends LdapDataProvider
throws CreateException
{
LdapConnection ld = null;
- String dn = SchemaConstants.CN_AT + "=" + entity.getName() + "," + Config.getProperty(EIds.EXAMPLE_ROOT);
+ String dn = SchemaConstants.CN_AT + "=" + entity.getName() + "," + Config.getInstance().getProperty(EIds.EXAMPLE_ROOT);
if (LOG.isDebugEnabled())
{
LOG.debug("create dn [" + dn + "]");
@@ -137,7 +137,7 @@ public class ExampleDAO extends LdapDataProvider
throws UpdateException
{
LdapConnection ld = null;
- String dn = SchemaConstants.CN_AT + "=" + entity.getName() + "," + Config.getProperty( EIds.EXAMPLE_ROOT );
+ String dn = SchemaConstants.CN_AT + "=" + entity.getName() + "," + Config.getInstance().getProperty( EIds.EXAMPLE_ROOT );
if (LOG.isDebugEnabled())
{
LOG.debug("update dn [" + dn + "]");
@@ -185,7 +185,7 @@ public class ExampleDAO extends LdapDataProvider
throws RemoveException
{
LdapConnection ld = null;
- String dn = SchemaConstants.CN_AT + "=" + name + "," + Config.getProperty(EIds.EXAMPLE_ROOT);
+ String dn = SchemaConstants.CN_AT + "=" + name + "," + Config.getInstance().getProperty(EIds.EXAMPLE_ROOT);
if (LOG.isDebugEnabled())
{
LOG.debug("remove dn [" + dn + "]");
@@ -219,7 +219,7 @@ public class ExampleDAO extends LdapDataProvider
{
Example entity = null;
LdapConnection ld = null;
- String dn = SchemaConstants.CN_AT + "=" + name + "," + Config.getProperty(EIds.EXAMPLE_ROOT);
+ String dn = SchemaConstants.CN_AT + "=" + name + "," + Config.getInstance().getProperty(EIds.EXAMPLE_ROOT);
if (LOG.isDebugEnabled())
{
LOG.debug("findByKey dn [" + dn + "]");
@@ -267,7 +267,7 @@ public class ExampleDAO extends LdapDataProvider
{
List<Example> exampleList = new ArrayList<>();
LdapConnection ld = null;
- String exampleRoot = Config.getProperty( EIds.EXAMPLE_ROOT );
+ String exampleRoot = Config.getInstance().getProperty( EIds.EXAMPLE_ROOT );
if (LOG.isDebugEnabled())
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java b/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
index 9b2469b..fca8127 100755
--- a/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
+++ b/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
@@ -20,8 +20,9 @@
package org.apache.directory.fortress.core.impl;
import junit.framework.Test;
-import junit.framework.TestSuite;
import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
import org.apache.directory.fortress.core.GlobalIds;
/**
@@ -104,7 +105,7 @@ public class FortressJUnitTest extends TestCase
if ( !isFirstRun() )
{
// PwPolicyMgr PW Policy Teardown:
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testDeletePasswordPolicy" ) );
}
@@ -125,7 +126,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AdminMgrImplTest( "testDelRoleDescendant" ) );
suite.addTest( new AdminMgrImplTest( "testDelRoleAscendant" ) );
suite.addTest( new AdminMgrImplTest( "testDeleteRole" ) );
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testDelete" ) );
}
@@ -150,7 +151,7 @@ public class FortressJUnitTest extends TestCase
/* 2. Build Up */
/***********************************************************/
// PW PolicyMgr APIs:
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testAdd" ) );
suite.addTest( new PswdPolicyMgrImplTest( "testUpdate" ) );
@@ -187,7 +188,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AdminMgrImplTest( "testUpdateRole" ) );
suite.addTest( new AdminMgrImplTest( "testAddUser" ) );
suite.addTest( new AdminMgrImplTest( "testUpdateUser" ) );
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testUpdatePasswordPolicy" ) );
}
@@ -209,7 +210,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new DelegatedMgrImplTest( "testSearchAdminRole" ) );
// ReviewMgr RBAC:
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testRead" ) );
suite.addTest( new PswdPolicyMgrImplTest( "testSearch" ) );
@@ -252,7 +253,7 @@ public class FortressJUnitTest extends TestCase
// AccessMgr RBAC:
suite.addTest( new AccessMgrImplTest( "testGetUserId" ) );
suite.addTest( new AccessMgrImplTest( "testGetUser" ) );
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
// These tests are reliant on OpenLDAP's pwpolicy overlay:
suite.addTest( new AdminMgrImplTest( "testResetPassword" ) );
@@ -278,7 +279,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AccessMgrImplTest( "testCreateSessionWithRolesTrusted" ) );
// PwPolicyMgr PW Policy checks:
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
// These tests are reliant on OpenLDAP's pwpolicy overlay:
suite.addTest( new PswdPolicyMgrImplTest( "testMinAge" ) );
@@ -300,7 +301,7 @@ public class FortressJUnitTest extends TestCase
/* 5. Audit Checks */
/***********************************************************/
//suite.addTest(new AuditMgrImplTest("testSearchAuthNInvalid"));
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
// These tests reliant on OpenLDAP's slapo access log overlay:
suite.addTest( new AuditMgrImplTest( "testSearchBinds" ) );
[03/15] directory-fortress-core git commit: refactored to not use
static initialization blocks
Posted by cp...@apache.org.
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
index 35da4f9..4c47e5e 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
@@ -112,19 +112,9 @@ public abstract class LdapDataProvider
private static final String ENABLE_LDAP_STARTTLS = "enable.ldap.starttls";
- private static final boolean IS_SSL = (
- Config.getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
- Config.getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
- Config.getProperty( GlobalIds.TRUST_STORE ) != null &&
- Config.getProperty( GlobalIds.TRUST_STORE_PW ) != null );
-
- private static final boolean IS_SET_TRUST_STORE_PROP = (
- IS_SSL &&
- Config.getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
- Config.getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
-
- private static final boolean IS_SSL_DEBUG = ( ( Config.getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( Config
- .getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ).equalsIgnoreCase( "true" ) ) );
+ private boolean IS_SSL;
+ private boolean IS_SET_TRUST_STORE_PROP;
+ private boolean IS_SSL_DEBUG;
/**
* The Admin connection pool
@@ -146,43 +136,62 @@ public abstract class LdapDataProvider
private static final char[] LDAP_META_CHARS = loadLdapEscapeChars();
private static final String[] LDAP_REPL_VALS = loadValidLdapVals();
- static
+ public LdapDataProvider(){
+ init();
+ }
+
+ private void init()
{
- String host = Config.getProperty( GlobalIds.LDAP_HOST, "localhost" );
- int port = Config.getInt( GlobalIds.LDAP_PORT, 389 );
- int min = Config.getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
- int max = Config.getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
- int logmin = Config.getInt( LDAP_LOG_POOL_MIN, 1 );
- int logmax = Config.getInt( LDAP_LOG_POOL_MAX, 10 );
+ IS_SSL = (
+ Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
+ Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
+ Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) != null &&
+ Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) != null );
+
+ IS_SET_TRUST_STORE_PROP = (
+ IS_SSL &&
+ Config.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
+ Config.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
+
+ IS_SSL_DEBUG = ( ( Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( Config
+ .getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ).equalsIgnoreCase( "true" ) ) );
+
+
+ String host = Config.getInstance().getProperty( GlobalIds.LDAP_HOST, "localhost" );
+ int port = Config.getInstance().getInt( GlobalIds.LDAP_PORT, 389 );
+ int min = Config.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
+ int max = Config.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
+ int logmin = Config.getInstance().getInt( LDAP_LOG_POOL_MIN, 1 );
+ int logmax = Config.getInstance().getInt( LDAP_LOG_POOL_MAX, 10 );
LOG.info( "LDAP POOL: host=[{}], port=[{}], min=[{}], max=[{}]", host, port, min, max );
if ( IS_SET_TRUST_STORE_PROP )
{
LOG.info( "Set JSSE truststore properties in Apache LDAP client:" );
- LOG.info( "javax.net.ssl.trustStore: {}", Config.getProperty( GlobalIds.TRUST_STORE ) );
+ LOG.info( "javax.net.ssl.trustStore: {}", Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
LOG.info( "javax.net.debug: {}", IS_SSL_DEBUG );
- System.setProperty( "javax.net.ssl.trustStore", Config.getProperty( GlobalIds.TRUST_STORE ) );
- System.setProperty( "javax.net.ssl.trustStorePassword", Config.getProperty( GlobalIds.TRUST_STORE_PW ) );
+ System.setProperty( "javax.net.ssl.trustStore", Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
+ System.setProperty( "javax.net.ssl.trustStorePassword", Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) );
System.setProperty( "javax.net.debug", Boolean.valueOf( IS_SSL_DEBUG ).toString() );
}
LdapConnectionConfig config = new LdapConnectionConfig();
config.setLdapHost( host );
config.setLdapPort( port );
- config.setName( Config.getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+ config.setName( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
config.setUseSsl( IS_SSL );
//config.setTrustManagers( new NoVerificationTrustManager() );
- if(Config.getBoolean(ENABLE_LDAP_STARTTLS, false)){
+ if(Config.getInstance().getBoolean(ENABLE_LDAP_STARTTLS, false)){
config.setUseTls(true);
}
- if ( IS_SSL && StringUtils.isNotEmpty( Config.getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( Config.getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ if ( IS_SSL && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
{
// validate certificates but allow self-signed certs if within this truststore:
- config.setTrustManagers( new LdapClientTrustStoreManager( Config.getProperty( GlobalIds.TRUST_STORE ), Config.getProperty( GlobalIds.TRUST_STORE_PW )
+ config.setTrustManagers( new LdapClientTrustStoreManager( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ), Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW )
.toCharArray(), null,
true ) );
}
@@ -190,11 +199,11 @@ public abstract class LdapDataProvider
String adminPw;
if ( EncryptUtil.isEnabled() )
{
- adminPw = EncryptUtil.decrypt( Config.getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
+ adminPw = EncryptUtil.getInstance().decrypt( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
}
else
{
- adminPw = Config.getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
+ adminPw = Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
}
config.setCredentials( adminPw );
@@ -249,28 +258,28 @@ public abstract class LdapDataProvider
LdapConnectionConfig logConfig = new LdapConnectionConfig();
logConfig.setLdapHost( host );
logConfig.setLdapPort( port );
- logConfig.setName( Config.getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+ logConfig.setName( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
logConfig.setUseSsl( IS_SSL );
- if ( IS_SSL && StringUtils.isNotEmpty( Config.getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( Config.getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ if ( IS_SSL && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
{
// validate certificates but allow self-signed certs if within this truststore:
- logConfig.setTrustManagers( new LdapClientTrustStoreManager( Config.getProperty( GlobalIds.TRUST_STORE ),
- Config.getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
+ logConfig.setTrustManagers( new LdapClientTrustStoreManager( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ),
+ Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
null, true ) );
}
- logConfig.setName( Config.getProperty( LDAP_LOG_POOL_UID, "" ) );
+ logConfig.setName( Config.getInstance().getProperty( LDAP_LOG_POOL_UID, "" ) );
String logPw;
if ( EncryptUtil.isEnabled() )
{
- logPw = EncryptUtil.decrypt( Config.getProperty( LDAP_LOG_POOL_PW ) );
+ logPw = EncryptUtil.getInstance().decrypt( Config.getInstance().getProperty( LDAP_LOG_POOL_PW ) );
}
else
{
- logPw = Config.getProperty( LDAP_LOG_POOL_PW );
+ logPw = Config.getInstance().getProperty( LDAP_LOG_POOL_PW );
}
logConfig.setCredentials( logPw );
poolFactory = new ValidatingPoolableLdapConnectionFactory( logConfig );
@@ -292,13 +301,13 @@ public abstract class LdapDataProvider
*/
protected String getRootDn( String contextId, String root )
{
- String szDn = Config.getProperty( root );
+ String szDn = Config.getInstance().getProperty( root );
// The contextId must not be null, or "HOME" or "null"
if ( StringUtils.isNotEmpty( contextId ) && !contextId.equalsIgnoreCase( GlobalIds.NULL ) && !contextId
.equals( GlobalIds.HOME ) )
{
- int idx = szDn.indexOf( Config.getProperty( GlobalIds.SUFFIX ) );
+ int idx = szDn.indexOf( Config.getInstance().getProperty( GlobalIds.SUFFIX ) );
if ( idx > 0 )
{
// Found. The DN is ,ou=<contextId>,
@@ -334,11 +343,11 @@ public abstract class LdapDataProvider
.equals( GlobalIds.HOME ) )
{
dn.append( SchemaConstants.OU_AT ).append( "=" ).append( contextId ).append( "," +
- "" ).append( Config.getProperty( GlobalIds.SUFFIX ) );
+ "" ).append( Config.getInstance().getProperty( GlobalIds.SUFFIX ) );
}
else
{
- dn.append( Config.getProperty( GlobalIds.SUFFIX ) );
+ dn.append( Config.getInstance().getProperty( GlobalIds.SUFFIX ) );
}
return dn.toString();
}
@@ -425,7 +434,7 @@ public abstract class LdapDataProvider
{
COUNTERS.incrementAdd();
- if ( !GlobalIds.IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
+ if ( !GlobalIds.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
{
if ( StringUtils.isNotEmpty( entity.getAdminSession().getInternalUserId() ) )
{
@@ -686,7 +695,7 @@ public abstract class LdapDataProvider
*/
private void audit( List<Modification> mods, FortEntity entity )
{
- if ( !GlobalIds.IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
+ if ( !GlobalIds.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
{
if ( StringUtils.isNotEmpty( entity.getAdminSession().getInternalUserId() ) )
{
@@ -1336,7 +1345,7 @@ public abstract class LdapDataProvider
throw new LdapException( error );
}
- if ( GlobalIds.LDAP_FILTER_SIZE_FOUND )
+ if ( GlobalIds.getInstance().LDAP_FILTER_SIZE_FOUND )
{
value = escapeLDAPSearchFilter( value );
}
@@ -1513,7 +1522,7 @@ public abstract class LdapDataProvider
*/
private static char[] loadLdapEscapeChars()
{
- if ( !GlobalIds.LDAP_FILTER_SIZE_FOUND )
+ if ( !GlobalIds.getInstance().LDAP_FILTER_SIZE_FOUND )
{
return null;
}
@@ -1523,7 +1532,7 @@ public abstract class LdapDataProvider
for ( int i = 1;; i++ )
{
String prop = GlobalIds.LDAP_FILTER + i;
- String value = Config.getProperty( prop );
+ String value = Config.getInstance().getProperty( prop );
if ( value == null )
{
@@ -1542,7 +1551,7 @@ public abstract class LdapDataProvider
*/
private static String[] loadValidLdapVals()
{
- if ( !GlobalIds.LDAP_FILTER_SIZE_FOUND )
+ if ( !GlobalIds.getInstance().LDAP_FILTER_SIZE_FOUND )
{
return null;
}
@@ -1552,7 +1561,7 @@ public abstract class LdapDataProvider
for ( int i = 1;; i++ )
{
String prop = GlobalIds.LDAP_SUB + i;
- String value = Config.getProperty( prop );
+ String value = Config.getInstance().getProperty( prop );
if ( value == null )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java b/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
index bde06a4..ab8300a 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
@@ -19,13 +19,13 @@
*/
package org.apache.directory.fortress.core.model;
+import java.util.StringTokenizer;
+
import org.apache.commons.lang.StringUtils;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.ValidationException;
import org.apache.directory.fortress.core.util.VUtil;
-import java.util.StringTokenizer;
-
/**
* Utilities to copy constraints attributes between entities.
*
@@ -134,7 +134,7 @@ public class ConstraintUtil
{
if ( StringUtils.isNotEmpty( inputString ) )
{
- StringTokenizer tkn = new StringTokenizer( inputString, GlobalIds.DELIMITER, true );
+ StringTokenizer tkn = new StringTokenizer( inputString, GlobalIds.getInstance().DELIMITER, true );
if ( tkn.countTokens() > 0 )
{
int count = tkn.countTokens();
@@ -143,11 +143,11 @@ public class ConstraintUtil
for ( int i = 0; i < count; i++ )
{
String szValue = tkn.nextToken();
- if ( szValue.equals( GlobalIds.DELIMITER ) && !previousTokenWasDelimiter )
+ if ( szValue.equals( GlobalIds.getInstance().DELIMITER ) && !previousTokenWasDelimiter )
{
previousTokenWasDelimiter = true;
}
- else if ( szValue.equals( GlobalIds.DELIMITER ) )
+ else if ( szValue.equals( GlobalIds.getInstance().DELIMITER ) )
{
previousTokenWasDelimiter = true;
index++;
@@ -210,56 +210,56 @@ public class ConstraintUtil
{
StringBuilder sb = new StringBuilder();
sb.append( constraint.getName() );
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getTimeout() != null )
{
sb.append( constraint.getTimeout() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getBeginTime() != null )
{
sb.append( constraint.getBeginTime() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getEndTime() != null )
{
sb.append( constraint.getEndTime() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getBeginDate() != null )
{
sb.append( constraint.getBeginDate() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getEndDate() != null )
{
sb.append( constraint.getEndDate() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getBeginLockDate() != null )
{
sb.append( constraint.getBeginLockDate() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getEndLockDate() != null )
{
sb.append( constraint.getEndLockDate() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( constraint.getDayMask() != null )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java b/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
index 8764db6..0c0916e 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
@@ -19,12 +19,12 @@
*/
package org.apache.directory.fortress.core.model;
-import org.apache.directory.fortress.core.GlobalIds;
-
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
+import org.apache.directory.fortress.core.GlobalIds;
+
/**
* Utilities to convert to/from property formats.
*
@@ -91,7 +91,7 @@ public final class PropUtil
*/
public static Properties getProperties( String inputString, char separator )
{
- return getProperties( inputString, separator, GlobalIds.DELIMITER );
+ return getProperties( inputString, separator, GlobalIds.getInstance().DELIMITER );
}
/**
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java b/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
index 7b3b557..e7a6d31 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
@@ -162,7 +162,7 @@ public class UserAdminRole extends UserRole implements Administrator
{
if ( ( szRawData != null ) && ( szRawData.length() > 0 ) )
{
- String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, GlobalIds.DELIMITER );
+ String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, GlobalIds.getInstance().DELIMITER );
for ( int i = 0; i < tokens.length; i++ )
{
if ( StringUtils.isNotEmpty( tokens[i] ) )
@@ -248,37 +248,37 @@ public class UserAdminRole extends UserRole implements Administrator
String szRole;
StringBuilder sb = new StringBuilder();
sb.append( name );
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
sb.append( this.getTimeout() );
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( this.getBeginTime() != null )
{
sb.append( this.getBeginTime() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( this.getEndTime() != null )
{
sb.append( this.getEndTime() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( this.getBeginDate() != null )
{
sb.append( this.getBeginDate() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( this.getEndDate() != null )
{
sb.append( this.getEndDate() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( this.getBeginLockDate() != null )
{
@@ -286,14 +286,14 @@ public class UserAdminRole extends UserRole implements Administrator
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( this.getEndLockDate() != null )
{
sb.append( this.getEndLockDate() );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( this.getDayMask() != null )
{
@@ -304,7 +304,7 @@ public class UserAdminRole extends UserRole implements Administrator
{
for ( String org : this.getOsUSet() )
{
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
sb.append( U );
sb.append( GlobalIds.PROP_SEP );
sb.append( org );
@@ -315,7 +315,7 @@ public class UserAdminRole extends UserRole implements Administrator
{
for ( String org : this.getOsPSet() )
{
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
sb.append( P );
sb.append( GlobalIds.PROP_SEP );
sb.append( org );
@@ -323,7 +323,7 @@ public class UserAdminRole extends UserRole implements Administrator
}
if ( StringUtils.isNotEmpty( this.getRoleRangeRaw() ) )
{
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
sb.append( R );
sb.append( GlobalIds.PROP_SEP );
sb.append( this.getRoleRangeRaw() );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
index 86d277d..efb59d5 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
@@ -152,7 +152,7 @@ public class UserRole extends FortEntity implements Serializable, Constraint
{
if ( ( szRawData != null ) && ( szRawData.length() > 0 ) )
{
- String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, GlobalIds.DELIMITER );
+ String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, GlobalIds.getInstance().DELIMITER );
for ( int i = 0; i < tokens.length; i++ )
{
if ( StringUtils.isNotEmpty( tokens[i] ) )
@@ -214,51 +214,51 @@ public class UserRole extends FortEntity implements Serializable, Constraint
StringBuilder sb = new StringBuilder();
sb.append( name );
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
sb.append( timeout );
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( beginTime != null )
{
sb.append( beginTime );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( endTime != null )
{
sb.append( endTime );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( beginDate != null )
{
sb.append( beginDate );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( endDate != null )
{
sb.append( endDate );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( beginLockDate != null )
{
sb.append( beginLockDate );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( endLockDate != null )
{
sb.append( endLockDate );
}
- sb.append( GlobalIds.DELIMITER );
+ sb.append( GlobalIds.getInstance().DELIMITER );
if ( dayMask != null )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/AccessMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/AccessMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/AccessMgrRestImpl.java
index cdf32fe..8fbfcb9 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/AccessMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/AccessMgrRestImpl.java
@@ -19,23 +19,23 @@
*/
package org.apache.directory.fortress.core.rest;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
import org.apache.directory.fortress.core.AccessMgr;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.model.FortRequest;
-import org.apache.directory.fortress.core.model.FortResponse;
import org.apache.directory.fortress.core.impl.AccessMgrImpl;
import org.apache.directory.fortress.core.impl.Manageable;
+import org.apache.directory.fortress.core.model.FortRequest;
+import org.apache.directory.fortress.core.model.FortResponse;
import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
import org.apache.directory.fortress.core.util.VUtil;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
/**
* Implementation class that performs runtime access control operations on data objects of type Fortress entities
* This object performs runtime access control operations on objects that are provisioned RBAC entities
@@ -94,7 +94,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setContextId(this.contextId);
request.setEntity(new User(userId, password));
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_AUTHN);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_AUTHN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -123,11 +123,11 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
String szResponse;
if(isTrusted)
{
- szResponse = RestUtils.post(szRequest, HttpIds.RBAC_CREATE_TRUSTED);
+ szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_CREATE_TRUSTED);
}
else
{
- szResponse = RestUtils.post(szRequest, HttpIds.RBAC_CREATE);
+ szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_CREATE);
}
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
@@ -156,7 +156,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setSession(session);
request.setEntity(perm);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_AUTHZ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_AUTHZ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -184,7 +184,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_PERMS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_PERMS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -212,7 +212,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_ROLES);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -240,7 +240,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_AUTHZ_ROLES);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_AUTHZ_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -272,7 +272,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setSession(session);
request.setEntity(role);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_ADD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -300,7 +300,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setSession(session);
request.setEntity(role);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_DROP);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_DROP);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -326,7 +326,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_USERID);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_USERID);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -355,7 +355,7 @@ public class AccessMgrRestImpl extends Manageable implements AccessMgr
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.RBAC_USER);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.RBAC_USER);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
index f22f6f5..c3d0540 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
@@ -21,8 +21,9 @@ package org.apache.directory.fortress.core.rest;
import org.apache.directory.fortress.core.AdminMgr;
-import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
import org.apache.directory.fortress.core.model.PermGrant;
@@ -33,7 +34,6 @@ import org.apache.directory.fortress.core.model.RoleRelationship;
import org.apache.directory.fortress.core.model.SDSet;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
-import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.util.VUtil;
@@ -95,7 +95,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -125,7 +125,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_DISABLE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_DISABLE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -150,7 +150,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -176,7 +176,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -208,7 +208,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_CHGPW );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_CHGPW );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -233,7 +233,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_LOCK );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_LOCK );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -258,7 +258,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_UNLOCK );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_UNLOCK );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -285,7 +285,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_RESET );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_RESET );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -323,7 +323,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -353,7 +353,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -379,7 +379,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -409,7 +409,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_ASGN );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_ASGN );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -434,7 +434,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_DEASGN );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_DEASGN );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -460,7 +460,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PERM_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -491,7 +491,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PERM_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -521,7 +521,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.PERM_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -547,7 +547,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.OBJ_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.OBJ_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -578,7 +578,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.OBJ_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.OBJ_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -608,7 +608,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.OBJ_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.OBJ_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -640,7 +640,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_GRANT );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_GRANT );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -672,7 +672,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_REVOKE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_REVOKE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -704,7 +704,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_GRANT );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_GRANT );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -736,7 +736,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.USER_REVOKE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.USER_REVOKE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -765,7 +765,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_DESC );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_DESC );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -794,7 +794,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_ASC );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_ASC );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -823,7 +823,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_ADDINHERIT );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_ADDINHERIT );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -852,7 +852,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.ROLE_DELINHERIT );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_DELINHERIT );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() != 0 )
{
@@ -878,7 +878,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.SSD_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.SSD_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -908,7 +908,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.SSD_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.SSD_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -941,7 +941,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.SSD_ADD_MEMBER );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.SSD_ADD_MEMBER );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -974,7 +974,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.SSD_DEL_MEMBER );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.SSD_DEL_MEMBER );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1005,7 +1005,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.SSD_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.SSD_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1037,7 +1037,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.SSD_CARD_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.SSD_CARD_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1068,7 +1068,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.DSD_ADD );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.DSD_ADD );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1098,7 +1098,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.DSD_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.DSD_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1131,7 +1131,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.DSD_ADD_MEMBER );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.DSD_ADD_MEMBER );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1164,7 +1164,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.DSD_DEL_MEMBER );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.DSD_DEL_MEMBER );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1195,7 +1195,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.DSD_DELETE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.DSD_DELETE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
@@ -1227,7 +1227,7 @@ public final class AdminMgrRestImpl extends Manageable implements AdminMgr
request.setSession( adminSess );
}
String szRequest = RestUtils.marshal( request );
- String szResponse = RestUtils.post( szRequest, HttpIds.DSD_CARD_UPDATE );
+ String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.DSD_CARD_UPDATE );
FortResponse response = RestUtils.unmarshall( szResponse );
if ( response.getErrorCode() == 0 )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/AuditMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/AuditMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/AuditMgrRestImpl.java
index 9d5c01b..bd1a5f6 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/AuditMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/AuditMgrRestImpl.java
@@ -19,21 +19,21 @@
*/
package org.apache.directory.fortress.core.rest;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.directory.fortress.core.AuditMgr;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.AuthZ;
import org.apache.directory.fortress.core.model.Bind;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
-import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.Mod;
import org.apache.directory.fortress.core.model.UserAudit;
import org.apache.directory.fortress.core.util.VUtil;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* This class performs searches across <a href="http://www.openldap.org/">OpenLDAP</a>'s slapd access log using HTTP access
* to En Masse REST server. The access log events are
@@ -126,7 +126,7 @@ public class AuditMgrRestImpl extends Manageable implements AuditMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.AUDIT_UAUTHZS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_UAUTHZS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -162,7 +162,7 @@ public class AuditMgrRestImpl extends Manageable implements AuditMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.AUDIT_AUTHZS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_AUTHZS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -198,7 +198,7 @@ public class AuditMgrRestImpl extends Manageable implements AuditMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.AUDIT_BINDS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_BINDS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -234,7 +234,7 @@ public class AuditMgrRestImpl extends Manageable implements AuditMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.AUDIT_SESSIONS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_SESSIONS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -270,7 +270,7 @@ public class AuditMgrRestImpl extends Manageable implements AuditMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.AUDIT_MODS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_MODS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -306,7 +306,7 @@ public class AuditMgrRestImpl extends Manageable implements AuditMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.AUDIT_INVLD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_INVLD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/ConfigMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/ConfigMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/ConfigMgrRestImpl.java
index 845c827..b3e51ee 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/ConfigMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/ConfigMgrRestImpl.java
@@ -19,16 +19,16 @@
*/
package org.apache.directory.fortress.core.rest;
+import java.util.Properties;
+
+import org.apache.directory.fortress.core.ConfigMgr;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.ConfigMgr;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
import org.apache.directory.fortress.core.model.Props;
import org.apache.directory.fortress.core.util.VUtil;
-import java.util.Properties;
-
/**
* This Manager impl supplies CRUD methods used to manage properties stored within the ldap directory using HTTP access to En Masse REST server.
* The Fortress config nodes are used to remotely share Fortress client specific properties between processes.
@@ -60,7 +60,7 @@ public class ConfigMgrRestImpl implements ConfigMgr
request.setEntity(inProps);
request.setValue(name);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.CFG_ADD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -89,7 +89,7 @@ public class ConfigMgrRestImpl implements ConfigMgr
request.setEntity(inProps);
request.setValue(name);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.CFG_UPDATE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -114,7 +114,7 @@ public class ConfigMgrRestImpl implements ConfigMgr
FortRequest request = new FortRequest();
request.setValue(name);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.CFG_DELETE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -136,7 +136,7 @@ public class ConfigMgrRestImpl implements ConfigMgr
request.setEntity(inProps);
request.setValue(name);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.CFG_DELETE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -156,7 +156,7 @@ public class ConfigMgrRestImpl implements ConfigMgr
FortRequest request = new FortRequest();
request.setValue(name);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.CFG_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
Props props;
if (response.getErrorCode() == 0)
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/DelAccessMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/DelAccessMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/DelAccessMgrRestImpl.java
index 9c8d9ca..557b444 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/DelAccessMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/DelAccessMgrRestImpl.java
@@ -19,23 +19,23 @@
*/
package org.apache.directory.fortress.core.rest;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.directory.fortress.core.DelAccessMgr;
import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
-import org.apache.directory.fortress.core.model.RolePerm;
-import org.apache.directory.fortress.core.model.UserAdminRole;
-import org.apache.directory.fortress.core.DelAccessMgr;
import org.apache.directory.fortress.core.model.Permission;
+import org.apache.directory.fortress.core.model.Role;
+import org.apache.directory.fortress.core.model.RolePerm;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
+import org.apache.directory.fortress.core.model.UserAdminRole;
import org.apache.directory.fortress.core.model.UserRole;
-import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.util.VUtil;
-import org.apache.directory.fortress.core.SecurityException;
-
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
/**
* This class implements the ARBAC02 DelAccessMgr interface for performing runtime delegated access control operations on objects that are provisioned Fortress ARBAC entities
@@ -81,7 +81,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setSession(session);
request.setEntity(uRole);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_ASSIGN);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_ASSIGN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -115,7 +115,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setSession(session);
request.setEntity(uRole);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_DEASSIGN);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_DEASSIGN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -151,7 +151,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setSession(session);
request.setEntity(context);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_GRANT);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_GRANT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -187,7 +187,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setSession(session);
request.setEntity(context);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_REVOKE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_REVOKE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -221,7 +221,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setSession(session);
request.setEntity(perm);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_AUTHZ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_AUTHZ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -252,7 +252,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setSession(session);
request.setEntity(role);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_ADD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -281,7 +281,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setSession(session);
request.setEntity(role);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_DROP);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_DROP);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -308,7 +308,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_ROLES);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -337,7 +337,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_AUTHZ_ROLES);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_AUTHZ_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -369,7 +369,7 @@ public class DelAccessMgrRestImpl extends AccessMgrRestImpl implements DelAccess
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ADMIN_PERMS);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_PERMS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/DelAdminMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/DelAdminMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/DelAdminMgrRestImpl.java
index 08963d3..73a016d 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/DelAdminMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/DelAdminMgrRestImpl.java
@@ -20,12 +20,13 @@
package org.apache.directory.fortress.core.rest;
import org.apache.directory.fortress.core.DelAdminMgr;
+import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.AdminRole;
import org.apache.directory.fortress.core.model.AdminRoleRelationship;
import org.apache.directory.fortress.core.model.FortRequest;
import org.apache.directory.fortress.core.model.FortResponse;
-import org.apache.directory.fortress.core.impl.Manageable;
import org.apache.directory.fortress.core.model.OrgUnit;
import org.apache.directory.fortress.core.model.OrgUnitRelationship;
import org.apache.directory.fortress.core.model.PermGrant;
@@ -33,7 +34,6 @@ import org.apache.directory.fortress.core.model.PermObj;
import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserAdminRole;
-import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.util.VUtil;
@@ -74,7 +74,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_ADD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -104,7 +104,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_DELETE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -130,7 +130,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_UPDATE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -160,7 +160,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_ASGN);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_ASGN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -185,7 +185,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_DEASGN);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_DEASGN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -211,7 +211,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_ADD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -242,7 +242,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_UPDATE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -273,7 +273,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_DELETE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -309,7 +309,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_DESC);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_DESC);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -339,7 +339,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_ASC);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_ASC);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -370,7 +370,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_ADDINHERIT);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_ADDINHERIT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -401,7 +401,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_DELINHERIT);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_DELINHERIT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -431,7 +431,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_DESC);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_DESC);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -461,7 +461,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_ASC);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_ASC);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -491,7 +491,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_ADDINHERIT);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_ADDINHERIT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -521,7 +521,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_DELINHERIT);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_DELINHERIT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -548,7 +548,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_ADD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -580,7 +580,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_UPDATE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -611,7 +611,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.PERM_DELETE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -638,7 +638,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.OBJ_ADD);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -670,7 +670,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.OBJ_UPDATE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -701,7 +701,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.OBJ_DELETE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -733,7 +733,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_GRANT);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_GRANT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -765,7 +765,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ROLE_REVOKE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_REVOKE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -797,7 +797,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_GRANT);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_GRANT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
@@ -829,7 +829,7 @@ public final class DelAdminMgrRestImpl extends Manageable implements DelAdminMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_REVOKE);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_REVOKE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0)
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/rest/DelReviewMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/DelReviewMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/DelReviewMgrRestImpl.java
index 0012075..fb1f1f0 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/DelReviewMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/DelReviewMgrRestImpl.java
@@ -73,7 +73,7 @@ public class DelReviewMgrRestImpl extends Manageable implements DelReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -104,7 +104,7 @@ public class DelReviewMgrRestImpl extends Manageable implements DelReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -135,7 +135,7 @@ public class DelReviewMgrRestImpl extends Manageable implements DelReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ARLE_ASGNED);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -166,7 +166,7 @@ public class DelReviewMgrRestImpl extends Manageable implements DelReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.USER_ASGNED_ADMIN);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED_ADMIN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -202,7 +202,7 @@ public class DelReviewMgrRestImpl extends Manageable implements DelReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_READ);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
@@ -234,7 +234,7 @@ public class DelReviewMgrRestImpl extends Manageable implements DelReviewMgr
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
- String szResponse = RestUtils.post(szRequest, HttpIds.ORG_SEARCH);
+ String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0)
{
[13/15] directory-fortress-core git commit: moved isRest into initial
load and fixed URL loading in rest utils
Posted by cp...@apache.org.
moved isRest into initial load and fixed URL loading in rest utils
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/8fde6e74
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/8fde6e74
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/8fde6e74
Branch: refs/heads/master
Commit: 8fde6e7417e94c6bbe4f9e748bcf7196a67f82a9
Parents: b09d805
Author: clp207 <cl...@psu.edu>
Authored: Wed May 4 15:12:28 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Wed May 4 15:12:28 2016 -0400
----------------------------------------------------------------------
.../apache/directory/fortress/core/rest/RestUtils.java | 10 ++++++----
.../org/apache/directory/fortress/core/util/Config.java | 8 ++++----
2 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/8fde6e74/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
index 0325b35..a5dacfa 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
@@ -77,9 +77,9 @@ public class RestUtils
private String HTTP_HOST;
private String HTTP_PORT;
private String HTTP_PROTOCOL;
- private static final String VERSION = System.getProperty( "version" );
- private static final String SERVICE = "fortress-rest-" + VERSION;
- private String URI = HTTP_PROTOCOL + "://" + HTTP_HOST + ":" + HTTP_PORT + "/" + SERVICE + "/";
+ private String VERSION;
+ private String SERVICE;
+ private String URI;
private static final int HTTP_OK = 200;
private static final int HTTP_401_UNAUTHORIZED = 401;
private static final int HTTP_403_FORBIDDEN = 403;
@@ -121,7 +121,9 @@ public class RestUtils
IS_SET_TRUST_STORE_PROP = (
Config.getInstance().getProperty( SET_TRUST_STORE_PROP ) != null &&
Config.getInstance().getProperty( SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
-
+ VERSION = System.getProperty( "version" );
+ SERVICE = "fortress-rest-" + VERSION;
+ URI = HTTP_PROTOCOL + "://" + HTTP_HOST + ":" + HTTP_PORT + "/" + SERVICE + "/";
if ( IS_SET_TRUST_STORE_PROP )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/8fde6e74/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index 446531a..79c316b 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -131,6 +131,8 @@ public final class Config
config.load( fUserUrl );
}
+ restEnabled = ( ( getProperty( GlobalIds.ENABLE_REST ) != null ) && ( getProperty( GlobalIds.ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
+
// Check to see if any of the ldap connection parameters have been overridden:
getExternalConfig();
}
@@ -306,8 +308,6 @@ public final class Config
auditDisabled = ( ( getProperty( GlobalIds.DISABLE_AUDIT ) != null ) && ( getProperty( GlobalIds.DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
- restEnabled = ( ( getProperty( GlobalIds.ENABLE_REST ) != null ) && ( getProperty( GlobalIds.ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
-
realm = GlobalIds.REALM_TYPE.equalsIgnoreCase( getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
openldap = ( ( getProperty( GlobalIds.SERVER_TYPE ) != null ) && ( getProperty( GlobalIds.SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
@@ -601,9 +601,9 @@ public final class Config
try
{
String configClassName = this.getProperty( GlobalIds.CONFIG_IMPLEMENTATION );
- boolean IS_REST = ((this.getProperty(ConfigMgrFactory.ENABLE_REST) != null) && (this.getProperty(ConfigMgrFactory.ENABLE_REST).equalsIgnoreCase("true")));
+ //boolean IS_REST = ((this.getProperty(ConfigMgrFactory.ENABLE_REST) != null) && (this.getProperty(ConfigMgrFactory.ENABLE_REST).equalsIgnoreCase("true")));
- ConfigMgr cfgMgr = ConfigMgrFactory.createInstance(configClassName, IS_REST);
+ ConfigMgr cfgMgr = ConfigMgrFactory.createInstance(configClassName, false);
props = cfgMgr.read( realmName );
}
catch ( CfgException ce )
[09/15] directory-fortress-core git commit: fixed circular loop with
config instead of local config
Posted by cp...@apache.org.
fixed circular loop with config instead of local config
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/07d205a1
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/07d205a1
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/07d205a1
Branch: refs/heads/master
Commit: 07d205a11f3d292adc7b5e8748ef56ceb8520581
Parents: ecf623b
Author: clp207 <cl...@psu.edu>
Authored: Tue Apr 26 19:31:18 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Tue Apr 26 19:31:18 2016 -0400
----------------------------------------------------------------------
.../apache/directory/fortress/core/util/crypto/EncryptUtil.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/07d205a1/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
index d2bd30f..be17eac 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
@@ -19,7 +19,6 @@
*/
package org.apache.directory.fortress.core.util.crypto;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.LocalConfig;
import org.jasypt.util.text.BasicTextEncryptor;
@@ -85,7 +84,7 @@ public final class EncryptUtil
public static boolean isEnabled()
{
boolean result = false;
- if(LocalConfig.getInstance().getProperty(CRYPTO_PROP)!= null && !Config.getInstance().getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
+ if(LocalConfig.getInstance().getProperty(CRYPTO_PROP)!= null && !LocalConfig.getInstance().getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
{
result = true;
}
[06/15] directory-fortress-core git commit: working on getting junit
tests running after refactor
Posted by cp...@apache.org.
working on getting junit tests running after refactor
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/d0924b2b
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/d0924b2b
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/d0924b2b
Branch: refs/heads/master
Commit: d0924b2b7304a609cff8e1a44a3f79eb764f6738
Parents: 908a073
Author: clp207 <cl...@psu.edu>
Authored: Thu Apr 21 15:52:41 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Thu Apr 21 15:52:41 2016 -0400
----------------------------------------------------------------------
.../fortress/core/ConfigMgrFactory.java | 8 +-
.../directory/fortress/core/GlobalIds.java | 30 +-
.../fortress/core/impl/AdminRoleP.java | 6 +-
.../directory/fortress/core/impl/ConfigDAO.java | 8 +-
.../fortress/core/impl/ConfigMgrImpl.java | 6 +-
.../directory/fortress/core/impl/UserP.java | 12 +-
.../fortress/core/ldap/LdapDataProvider.java | 136 ++-----
.../directory/fortress/core/ldap/LdapUtil.java | 117 ++++++
.../directory/fortress/core/util/Config.java | 201 ++---------
.../fortress/core/util/LocalConfig.java | 360 +++++++++++++++++++
.../fortress/core/util/cache/CacheMgr.java | 2 +-
.../fortress/core/util/crypto/EncryptUtil.java | 5 +-
12 files changed, 575 insertions(+), 316 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
index 6d85d3f..7430775 100755
--- a/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
@@ -35,7 +35,7 @@ import org.apache.directory.fortress.core.util.Config;
*/
public final class ConfigMgrFactory
{
- private final static String ENABLE_REST = "enable.mgr.impl.rest";
+ public final static String ENABLE_REST = "enable.mgr.impl.rest";
private ConfigMgrFactory()
{
@@ -54,6 +54,12 @@ public final class ConfigMgrFactory
String configClassName = Config.getInstance().getProperty( GlobalIds.CONFIG_IMPLEMENTATION );
boolean IS_REST = ((Config.getInstance().getProperty(ENABLE_REST) != null) && (Config.getInstance().getProperty(ENABLE_REST).equalsIgnoreCase("true")));
+ return ConfigMgrFactory.createInstance(configClassName, IS_REST);
+ }
+
+ public static ConfigMgr createInstance(String configClassName, boolean IS_REST)
+ throws SecurityException
+ {
if (configClassName == null || configClassName.compareTo("") == 0)
{
if(IS_REST)
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
index 0fe67a3..0b42189 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
@@ -59,8 +59,6 @@ public final class GlobalIds
*/
private GlobalIds()
{
- init();
-
IS_AUDIT_DISABLED = ( ( Config.getInstance().getProperty( DISABLE_AUDIT ) != null ) && ( Config
.getInstance().getProperty( DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
@@ -71,10 +69,7 @@ public final class GlobalIds
.getInstance().getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
IS_OPENLDAP = ( ( Config.getInstance().getProperty( SERVER_TYPE ) != null ) && ( Config
- .getInstance().getProperty( SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
-
- LDAP_FILTER_SIZE_FOUND = ( Config
- .getInstance().getProperty( LDAP_FILTER_SIZE_PROP ) != null );
+ .getInstance().getProperty( SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
DELIMITER = Config.getInstance().getProperty( "attr.delimiter", "$" );
}
@@ -463,10 +458,6 @@ public final class GlobalIds
*/
public static final String LDAP_FILTER_SIZE_PROP = "ldap.filter.size";
- /**
- * Used during ldap filter processing.
- */
- public boolean LDAP_FILTER_SIZE_FOUND;
public static final String APACHE_LDAP_API = "apache";
public static final String AUTH_Z_FAILED = "authzfailed";
public static final String POP_NAME = "ftOpNm";
@@ -497,25 +488,6 @@ public final class GlobalIds
private static int ldapFilterSize = 25;
/**
- * enable the ldap filter size variable to be used later during filter processing.
- */
- private void init()
- {
- try
- {
- String lenProp = Config.getInstance().getProperty( LDAP_FILTER_SIZE_PROP );
- if ( LDAP_FILTER_SIZE_FOUND )
- {
- ldapFilterSize = Integer.valueOf( lenProp );
- }
- }
- catch ( java.lang.NumberFormatException nfe )
- {
- //ignore
- }
- }
-
- /**
* Maximum number of entries allowed for ldap filter replacements.
*/
public static final int LDAP_FILTER_SIZE = ldapFilterSize;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java b/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
index e6e0008..75483cc 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
@@ -60,8 +60,8 @@ public final class AdminRoleP
{
private static final String CLS_NM = AdminRoleP.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static final AdminRoleDAO rDao = new AdminRoleDAO();
- private static final OrgUnitP op = new OrgUnitP();
+ private AdminRoleDAO rDao;
+ private OrgUnitP op;
private static final ConstraintValidator constraintValidator = VUtil.getConstraintValidator();
/**
@@ -69,6 +69,8 @@ public final class AdminRoleP
*/
AdminRoleP()
{
+ rDao = new AdminRoleDAO();
+ op = new OrgUnitP();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
index b2278b4..f971c46 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
@@ -39,7 +39,7 @@ import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.PropUtil;
-import org.apache.directory.fortress.core.util.Config;
+import org.apache.directory.fortress.core.util.LocalConfig;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -86,12 +86,12 @@ final class ConfigDAO extends LdapDataProvider
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
private String CONFIG_ROOT_DN;
- private static final String CONFIG_OBJ_CLASS[] =
+ private final String CONFIG_OBJ_CLASS[] =
{
SchemaConstants.DEVICE_OC, GlobalIds.PROPS_AUX_OBJECT_CLASS_NAME
};
- private static final String[] CONFIG_ATRS =
+ private final String[] CONFIG_ATRS =
{
SchemaConstants.CN_AT, GlobalIds.PROPS
};
@@ -104,7 +104,7 @@ final class ConfigDAO extends LdapDataProvider
{
super();
- CONFIG_ROOT_DN = Config.getInstance().getProperty( GlobalIds.CONFIG_ROOT_PARAM );
+ CONFIG_ROOT_DN = LocalConfig.getInstance().getProperty( GlobalIds.CONFIG_ROOT_PARAM );
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/impl/ConfigMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ConfigMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/ConfigMgrImpl.java
index 5dea257..2c80df4 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ConfigMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ConfigMgrImpl.java
@@ -41,8 +41,12 @@ import org.apache.directory.fortress.core.SecurityException;
*/
public class ConfigMgrImpl implements ConfigMgr, Serializable
{
- private static final ConfigP cfgP = new ConfigP();
+ private ConfigP cfgP;
+ public ConfigMgrImpl() {
+ cfgP = new ConfigP();
+ }
+
/**
* {@inheritDoc}
*/
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserP.java b/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
index f089540..30af294 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
@@ -69,11 +69,11 @@ final class UserP
{
//private static final boolean IS_SESSION_PROPS_ENABLED = Config.getBoolean( "user.session.props.enabled", false );
private static final String CLS_NM = UserP.class.getName();
- private static UserDAO uDao = new UserDAO();
+ private static UserDAO uDao;
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static final PolicyP policyP = new PolicyP();
- private static final AdminRoleP admRoleP = new AdminRoleP();
- private static final OrgUnitP orgUnitP = new OrgUnitP();
+ private PolicyP policyP;
+ private AdminRoleP admRoleP;
+ private OrgUnitP orgUnitP;
/**
@@ -81,6 +81,10 @@ final class UserP
*/
UserP()
{
+ uDao = new UserDAO();
+ policyP = new PolicyP();
+ admRoleP = new AdminRoleP();
+ orgUnitP = new OrgUnitP();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
index 4c47e5e..6c6979d 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
@@ -76,6 +76,7 @@ import org.apache.directory.fortress.core.model.FortEntity;
import org.apache.directory.fortress.core.model.Hier;
import org.apache.directory.fortress.core.model.Relationship;
import org.apache.directory.fortress.core.util.Config;
+import org.apache.directory.fortress.core.util.LocalConfig;
import org.apache.directory.fortress.core.util.crypto.EncryptUtil;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.LdapConnectionConfig;
@@ -133,65 +134,62 @@ public abstract class LdapDataProvider
private static final PasswordPolicy PP_REQ_CTRL = new PasswordPolicyImpl();
- private static final char[] LDAP_META_CHARS = loadLdapEscapeChars();
- private static final String[] LDAP_REPL_VALS = loadValidLdapVals();
-
public LdapDataProvider(){
init();
}
private void init()
- {
+ {
IS_SSL = (
- Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
- Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
- Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) != null &&
- Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) != null );
+ LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
+ LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
+ LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) != null &&
+ LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) != null );
IS_SET_TRUST_STORE_PROP = (
IS_SSL &&
- Config.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
- Config.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
+ LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
+ LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
- IS_SSL_DEBUG = ( ( Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( Config
+ IS_SSL_DEBUG = ( ( LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( LocalConfig
.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ).equalsIgnoreCase( "true" ) ) );
- String host = Config.getInstance().getProperty( GlobalIds.LDAP_HOST, "localhost" );
- int port = Config.getInstance().getInt( GlobalIds.LDAP_PORT, 389 );
- int min = Config.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
- int max = Config.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
- int logmin = Config.getInstance().getInt( LDAP_LOG_POOL_MIN, 1 );
- int logmax = Config.getInstance().getInt( LDAP_LOG_POOL_MAX, 10 );
+ String host = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_HOST, "localhost" );
+ int port = LocalConfig.getInstance().getInt( GlobalIds.LDAP_PORT, 389 );
+ int min = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
+ int max = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
+ int logmin = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MIN, 1 );
+ int logmax = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MAX, 10 );
LOG.info( "LDAP POOL: host=[{}], port=[{}], min=[{}], max=[{}]", host, port, min, max );
if ( IS_SET_TRUST_STORE_PROP )
{
LOG.info( "Set JSSE truststore properties in Apache LDAP client:" );
- LOG.info( "javax.net.ssl.trustStore: {}", Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
+ LOG.info( "javax.net.ssl.trustStore: {}", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
LOG.info( "javax.net.debug: {}", IS_SSL_DEBUG );
- System.setProperty( "javax.net.ssl.trustStore", Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
- System.setProperty( "javax.net.ssl.trustStorePassword", Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) );
+ System.setProperty( "javax.net.ssl.trustStore", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
+ System.setProperty( "javax.net.ssl.trustStorePassword", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) );
System.setProperty( "javax.net.debug", Boolean.valueOf( IS_SSL_DEBUG ).toString() );
}
LdapConnectionConfig config = new LdapConnectionConfig();
config.setLdapHost( host );
config.setLdapPort( port );
- config.setName( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+ config.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
config.setUseSsl( IS_SSL );
//config.setTrustManagers( new NoVerificationTrustManager() );
- if(Config.getInstance().getBoolean(ENABLE_LDAP_STARTTLS, false)){
+ if(LocalConfig.getInstance().getBoolean(ENABLE_LDAP_STARTTLS, false)){
config.setUseTls(true);
}
- if ( IS_SSL && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
{
// validate certificates but allow self-signed certs if within this truststore:
- config.setTrustManagers( new LdapClientTrustStoreManager( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ), Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW )
+ config.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ), LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW )
.toCharArray(), null,
true ) );
}
@@ -199,11 +197,11 @@ public abstract class LdapDataProvider
String adminPw;
if ( EncryptUtil.isEnabled() )
{
- adminPw = EncryptUtil.getInstance().decrypt( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
+ adminPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
}
else
{
- adminPw = Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
+ adminPw = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
}
config.setCredentials( adminPw );
@@ -258,28 +256,28 @@ public abstract class LdapDataProvider
LdapConnectionConfig logConfig = new LdapConnectionConfig();
logConfig.setLdapHost( host );
logConfig.setLdapPort( port );
- logConfig.setName( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+ logConfig.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
logConfig.setUseSsl( IS_SSL );
- if ( IS_SSL && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
{
// validate certificates but allow self-signed certs if within this truststore:
- logConfig.setTrustManagers( new LdapClientTrustStoreManager( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ),
- Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
+ logConfig.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ),
+ LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
null, true ) );
}
- logConfig.setName( Config.getInstance().getProperty( LDAP_LOG_POOL_UID, "" ) );
+ logConfig.setName( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_UID, "" ) );
String logPw;
if ( EncryptUtil.isEnabled() )
{
- logPw = EncryptUtil.getInstance().decrypt( Config.getInstance().getProperty( LDAP_LOG_POOL_PW ) );
+ logPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW ) );
}
else
{
- logPw = Config.getInstance().getProperty( LDAP_LOG_POOL_PW );
+ logPw = LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW );
}
logConfig.setCredentials( logPw );
poolFactory = new ValidatingPoolableLdapConnectionFactory( logConfig );
@@ -1345,7 +1343,7 @@ public abstract class LdapDataProvider
throw new LdapException( error );
}
- if ( GlobalIds.getInstance().LDAP_FILTER_SIZE_FOUND )
+ if ( LdapUtil.getInstance().isLdapfilterSizeFound() )
{
value = escapeLDAPSearchFilter( value );
}
@@ -1517,63 +1515,7 @@ public abstract class LdapDataProvider
}
- /**
- *
- */
- private static char[] loadLdapEscapeChars()
- {
- if ( !GlobalIds.getInstance().LDAP_FILTER_SIZE_FOUND )
- {
- return null;
- }
-
- char[] ldapMetaChars = new char[GlobalIds.LDAP_FILTER_SIZE];
-
- for ( int i = 1;; i++ )
- {
- String prop = GlobalIds.LDAP_FILTER + i;
- String value = Config.getInstance().getProperty( prop );
-
- if ( value == null )
- {
- break;
- }
-
- ldapMetaChars[i - 1] = value.charAt( 0 );
- }
-
- return ldapMetaChars;
- }
-
-
- /**
- *
- */
- private static String[] loadValidLdapVals()
- {
- if ( !GlobalIds.getInstance().LDAP_FILTER_SIZE_FOUND )
- {
- return null;
- }
-
- String[] ldapReplacements = new String[GlobalIds.LDAP_FILTER_SIZE];
-
- for ( int i = 1;; i++ )
- {
- String prop = GlobalIds.LDAP_SUB + i;
- String value = Config.getInstance().getProperty( prop );
-
- if ( value == null )
- {
- break;
- }
-
- ldapReplacements[i - 1] = value;
- }
-
- return ldapReplacements;
- }
-
+
/**
* Perform encoding on supplied input string for certain unsafe ascii characters. These chars may be unsafe
@@ -1583,7 +1525,7 @@ public abstract class LdapDataProvider
* @param filter contains the data to filter.
* @return possibly modified input string for matched characters.
*/
- protected static String escapeLDAPSearchFilter( String filter )
+ protected String escapeLDAPSearchFilter( String filter )
{
StringBuilder sb = new StringBuilder();
int filterLen = filter.length();
@@ -1596,14 +1538,14 @@ public abstract class LdapDataProvider
for ( ; j < GlobalIds.LDAP_FILTER_SIZE; j++ )
{
- if ( LDAP_META_CHARS[j] > curChar )
+ if ( LdapUtil.getInstance().getLdapMetaChars()[j] > curChar )
{
break;
}
- else if ( curChar == LDAP_META_CHARS[j] )
+ else if ( curChar == LdapUtil.getInstance().getLdapMetaChars()[j] )
{
sb.append( "\\" );
- sb.append( LDAP_REPL_VALS[j] );
+ sb.append( LdapUtil.getInstance().getLdapReplVals()[j] );
found = true;
break;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java
new file mode 100644
index 0000000..f0ccf81
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java
@@ -0,0 +1,117 @@
+package org.apache.directory.fortress.core.ldap;
+
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.util.Config;
+
+
+public class LdapUtil {
+
+ private boolean ldapfilterSizeFound = false;
+ private int ldapFilterSize = 25;
+ private char[] ldapMetaChars;
+ private String[] ldapReplVals;
+
+ private static volatile LdapUtil INSTANCE = null;
+
+ public static LdapUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (LdapUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new LdapUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ /**
+ *
+ */
+ private static char[] loadLdapEscapeChars()
+ {
+ if ( !LdapUtil.getInstance().isLdapfilterSizeFound() )
+ {
+ return null;
+ }
+
+ char[] ldapMetaChars = new char[LdapUtil.getInstance().getLdapFilterSize()];
+
+ for ( int i = 1;; i++ )
+ {
+ String prop = GlobalIds.LDAP_FILTER + i;
+ String value = Config.getInstance().getProperty( prop );
+
+ if ( value == null )
+ {
+ break;
+ }
+
+ ldapMetaChars[i - 1] = value.charAt( 0 );
+ }
+
+ return ldapMetaChars;
+ }
+
+
+ /**
+ *
+ */
+ private static String[] loadValidLdapVals()
+ {
+ if ( !LdapUtil.getInstance().isLdapfilterSizeFound() )
+ {
+ return null;
+ }
+
+ String[] ldapReplacements = new String[LdapUtil.getInstance().getLdapFilterSize()];
+
+ for ( int i = 1;; i++ )
+ {
+ String prop = GlobalIds.LDAP_SUB + i;
+ String value = Config.getInstance().getProperty( prop );
+
+ if ( value == null )
+ {
+ break;
+ }
+
+ ldapReplacements[i - 1] = value;
+ }
+
+ return ldapReplacements;
+ }
+
+
+ public boolean isLdapfilterSizeFound() {
+ return ldapfilterSizeFound;
+ }
+
+ public void setLdapfilterSizeFound(boolean ldapfilterSizeFound) {
+ this.ldapfilterSizeFound = ldapfilterSizeFound;
+ }
+
+ public int getLdapFilterSize() {
+ return ldapFilterSize;
+ }
+
+ public void setLdapFilterSize(int ldapFilterSize) {
+ this.ldapFilterSize = ldapFilterSize;
+ }
+
+ public char[] getLdapMetaChars() {
+ return ldapMetaChars;
+ }
+
+ public void setLdapMetaChars(char[] ldapMetaChars) {
+ this.ldapMetaChars = ldapMetaChars;
+ }
+
+ public String[] getLdapReplVals() {
+ return ldapReplVals;
+ }
+
+ public void setLdapReplVals(String[] ldapReplVals) {
+ this.ldapReplVals = ldapReplVals;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index d3d773d..4efc574 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -20,12 +20,10 @@
package org.apache.directory.fortress.core.util;
-import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang.StringUtils;
import org.apache.directory.fortress.core.CfgException;
import org.apache.directory.fortress.core.CfgRuntimeException;
import org.apache.directory.fortress.core.ConfigMgr;
@@ -33,6 +31,7 @@ import org.apache.directory.fortress.core.ConfigMgrFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.ldap.LdapUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,27 +50,11 @@ import org.slf4j.LoggerFactory;
*/
public final class Config
{
- private static final String PROP_FILE = "fortress.properties";
- private static final String USER_PROP_FILE = "fortress.user.properties";
- private static final String EXT_LDAP_HOST = "fortress.host";
- private static final String EXT_LDAP_PORT = "fortress.port";
- private static final String EXT_LDAP_ADMIN_POOL_UID = "fortress.admin.user";
- private static final String EXT_LDAP_ADMIN_POOL_PW = "fortress.admin.pw";
- private static final String EXT_LDAP_ADMIN_POOL_MIN = "fortress.min.admin.conn";
- private static final String EXT_LDAP_ADMIN_POOL_MAX = "fortress.max.admin.conn";
- private static final String EXT_ENABLE_LDAP_SSL = "fortress.enable.ldap.ssl";
- private static final String EXT_ENABLE_LDAP_SSL_DEBUG = "fortress.enable.ldap.ssl.debug";
- private static final String EXT_TRUST_STORE = "fortress.trust.store";
- private static final String EXT_TRUST_STORE_PW = "fortress.trust.store.password";
- private static final String EXT_SET_TRUST_STORE_PROP = "fortress.trust.store.set.prop";
- private static final String EXT_CONFIG_REALM = "fortress.config.realm";
- private static final String EXT_CONFIG_ROOT_DN = "fortress.config.root";
- private static final String EXT_SERVER_TYPE = "fortress.ldap.server.type";
private static PropertiesConfiguration config;
private static final String CLS_NM = Config.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static volatile Config INSTANCE = null;
+ private static volatile Config INSTANCE = null;
public static Config getInstance() {
if(INSTANCE == null) {
@@ -88,31 +71,7 @@ public final class Config
{
try
{
- // Load the system config file.
- URL fUrl = Config.class.getClassLoader().getResource( PROP_FILE );
- config = new PropertiesConfiguration();
- config.setDelimiterParsingDisabled( true );
- if ( fUrl == null )
- {
- String error = "static init: Error, null cfg file: " + PROP_FILE;
- LOG.warn( error );
- }
- else
- {
- LOG.info( "static init: found from: {} path: {}", PROP_FILE, fUrl.getPath() );
- config.load( fUrl );
- LOG.info( "static init: loading from: {}", PROP_FILE );
- }
-
- URL fUserUrl = Config.class.getClassLoader().getResource( USER_PROP_FILE );
- if ( fUserUrl != null )
- {
- LOG.info( "static init: found user properties from: {} path: {}", USER_PROP_FILE, fUserUrl.getPath() );
- config.load( fUserUrl );
- }
-
- // Check to see if any of the ldap connection parameters have been overridden:
- getExternalConfig();
+ config = LocalConfig.getInstance().getConfig();
// Retrieve parameters from the config node stored in target LDAP DIT:
String realmName = config.getString( GlobalIds.CONFIG_REALM, "DEFAULT" );
@@ -129,22 +88,33 @@ public final class Config
config.setProperty( key, val );
}
}
+
+ //init ldap util vals since config is stored ons erver
+ boolean ldapfilterSizeFound = ( getProperty( GlobalIds.LDAP_FILTER_SIZE_PROP ) != null );
+ LdapUtil.getInstance().setLdapfilterSizeFound(ldapfilterSizeFound);
+
+ try
+ {
+ String lenProp = getProperty( GlobalIds.LDAP_FILTER_SIZE_PROP );
+ if ( ldapfilterSizeFound )
+ {
+ LdapUtil.getInstance().setLdapFilterSize(Integer.valueOf( lenProp ));
+ }
+ }
+ catch ( java.lang.NumberFormatException nfe )
+ {
+ //ignore
+ }
+
}
else
{
LOG.info( "static init: config realm not setup" );
}
}
- catch ( org.apache.commons.configuration.ConfigurationException ex )
- {
- String error = "static init: Error loading from cfg file: [" + PROP_FILE
- + "] ConfigurationException=" + ex;
- LOG.error( error );
- throw new CfgRuntimeException( GlobalErrIds.FT_CONFIG_BOOTSTRAP_FAILED, error, ex );
- }
catch ( SecurityException se )
{
- String error = "static init: Error loading from cfg file: [" + PROP_FILE + "] SecurityException="
+ String error = "static init: Error loading from remote config: SecurityException="
+ se;
LOG.error( error );
throw new CfgRuntimeException( GlobalErrIds.FT_CONFIG_INITIALIZE_FAILED, error, se );
@@ -381,7 +351,10 @@ public final class Config
Properties props = null;
try
{
- ConfigMgr cfgMgr = ConfigMgrFactory.createInstance();
+ String configClassName = this.getProperty( GlobalIds.CONFIG_IMPLEMENTATION );
+ boolean IS_REST = ((this.getProperty(ConfigMgrFactory.ENABLE_REST) != null) && (this.getProperty(ConfigMgrFactory.ENABLE_REST).equalsIgnoreCase("true")));
+
+ ConfigMgr cfgMgr = ConfigMgrFactory.createInstance(configClassName, IS_REST);
props = cfgMgr.read( realmName );
}
catch ( CfgException ce )
@@ -399,126 +372,4 @@ public final class Config
return props;
}
-
- /**
- * This method is called during configuration initialization. It determines if
- * the ldap connection coordinates have been overridden as system properties.
- */
- private void getExternalConfig()
- {
- String PREFIX = "getExternalConfig override name [{}] value [{}]";
- // Check to see if the ldap host has been overridden by a system property:
- String szValue = System.getProperty( EXT_LDAP_HOST );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_HOST, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_HOST, szValue );
- }
- // Check to see if the ldap port has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_PORT );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_PORT, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_PORT, szValue );
- }
-
- // Check to see if the admin pool uid has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_UID );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_UID, szValue );
- // never display ldap admin userid name to log:
- LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_UID );
- }
-
- // Check to see if the admin pool pw has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_PW );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_PW, szValue );
- // never display password of any type to log:
- LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_PW );
- }
-
- // Check to see if the admin pool min connections has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MIN );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
- }
-
- // Check to see if the admin pool max connections has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MAX );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
- }
-
- // Check to see if ssl enabled parameter has been overridden by a system property:
- szValue = System.getProperty( EXT_ENABLE_LDAP_SSL );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.ENABLE_LDAP_SSL, szValue );
- LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL, szValue );
- }
-
- // Check to see if the ssl debug enabled parameter has been overridden by a system property:
- szValue = System.getProperty( EXT_ENABLE_LDAP_SSL_DEBUG );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
- LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
- }
-
- // Check to see if the trust store location has been overridden by a system property:
- szValue = System.getProperty( EXT_TRUST_STORE );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.TRUST_STORE, szValue );
- LOG.info( PREFIX, GlobalIds.TRUST_STORE, szValue );
- }
-
- // Check to see if the trust store password has been overridden by a system property:
- szValue = System.getProperty( EXT_TRUST_STORE_PW );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.TRUST_STORE_PW, szValue );
- // never display password value to log:
- LOG.info( "getExternalConfig override name [{}]", GlobalIds.TRUST_STORE_PW );
- }
-
- // Check to see if the trust store set parameter has been overridden by a system property:
- szValue = System.getProperty( EXT_SET_TRUST_STORE_PROP );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.SET_TRUST_STORE_PROP, szValue );
- LOG.info( PREFIX, GlobalIds.SET_TRUST_STORE_PROP, szValue );
- }
-
- // Check to see if the config realm name has been overridden by a system property:
- szValue = System.getProperty( EXT_CONFIG_REALM );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.CONFIG_REALM, szValue );
- LOG.info( PREFIX, GlobalIds.CONFIG_REALM, szValue );
- }
-
- // Check to see if the config realm name has been overridden by a system property:
- szValue = System.getProperty( EXT_CONFIG_ROOT_DN );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.CONFIG_ROOT_PARAM, szValue );
- LOG.info( PREFIX, GlobalIds.CONFIG_ROOT_PARAM, szValue );
- }
-
- // Check to see if the ldap server type has been overridden by a system property:
- szValue = System.getProperty( EXT_SERVER_TYPE );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.SERVER_TYPE, szValue );
- LOG.info( PREFIX, GlobalIds.SERVER_TYPE, szValue );
- }
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java b/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java
new file mode 100644
index 0000000..7c612e1
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java
@@ -0,0 +1,360 @@
+package org.apache.directory.fortress.core.util;
+
+import java.net.URL;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang.StringUtils;
+import org.apache.directory.fortress.core.CfgRuntimeException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LocalConfig {
+
+ private static final String CLS_NM = LocalConfig.class.getName();
+ private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+
+ private static final String PROP_FILE = "fortress.properties";
+ private static final String USER_PROP_FILE = "fortress.user.properties";
+ private static final String EXT_LDAP_HOST = "fortress.host";
+ private static final String EXT_LDAP_PORT = "fortress.port";
+ private static final String EXT_LDAP_ADMIN_POOL_UID = "fortress.admin.user";
+ private static final String EXT_LDAP_ADMIN_POOL_PW = "fortress.admin.pw";
+ private static final String EXT_LDAP_ADMIN_POOL_MIN = "fortress.min.admin.conn";
+ private static final String EXT_LDAP_ADMIN_POOL_MAX = "fortress.max.admin.conn";
+ private static final String EXT_ENABLE_LDAP_SSL = "fortress.enable.ldap.ssl";
+ private static final String EXT_ENABLE_LDAP_SSL_DEBUG = "fortress.enable.ldap.ssl.debug";
+ private static final String EXT_TRUST_STORE = "fortress.trust.store";
+ private static final String EXT_TRUST_STORE_PW = "fortress.trust.store.password";
+ private static final String EXT_SET_TRUST_STORE_PROP = "fortress.trust.store.set.prop";
+ private static final String EXT_CONFIG_REALM = "fortress.config.realm";
+ private static final String EXT_CONFIG_ROOT_DN = "fortress.config.root";
+ private static final String EXT_SERVER_TYPE = "fortress.ldap.server.type";
+
+ private PropertiesConfiguration config;
+
+ private static volatile LocalConfig INSTANCE = null;
+
+ public static LocalConfig getInstance() {
+ if(INSTANCE == null) {
+ synchronized (LocalConfig.class) {
+ if(INSTANCE == null){
+ INSTANCE = new LocalConfig();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ private void init()
+ {
+ try
+ {
+ // Load the system config file.
+ URL fUrl = Config.class.getClassLoader().getResource( PROP_FILE );
+ config = new PropertiesConfiguration();
+ config.setDelimiterParsingDisabled( true );
+ if ( fUrl == null )
+ {
+ String error = "static init: Error, null cfg file: " + PROP_FILE;
+ LOG.warn( error );
+ }
+ else
+ {
+ LOG.info( "static init: found from: {} path: {}", PROP_FILE, fUrl.getPath() );
+ config.load( fUrl );
+ LOG.info( "static init: loading from: {}", PROP_FILE );
+ }
+
+ URL fUserUrl = Config.class.getClassLoader().getResource( USER_PROP_FILE );
+ if ( fUserUrl != null )
+ {
+ LOG.info( "static init: found user properties from: {} path: {}", USER_PROP_FILE, fUserUrl.getPath() );
+ config.load( fUserUrl );
+ }
+
+ // Check to see if any of the ldap connection parameters have been overridden:
+ getExternalConfig();
+ }
+ catch ( org.apache.commons.configuration.ConfigurationException ex )
+ {
+ String error = "static init: Error loading from cfg file: [" + PROP_FILE
+ + "] ConfigurationException=" + ex;
+ LOG.error( error );
+ throw new CfgRuntimeException( GlobalErrIds.FT_CONFIG_BOOTSTRAP_FAILED, error, ex );
+ }
+ }
+
+ /**
+ * Private constructor
+ *
+ */
+ private LocalConfig()
+ {
+ init();
+ }
+
+ /**
+ * This method is called during configuration initialization. It determines if
+ * the ldap connection coordinates have been overridden as system properties.
+ */
+ private void getExternalConfig()
+ {
+ String PREFIX = "getExternalConfig override name [{}] value [{}]";
+ // Check to see if the ldap host has been overridden by a system property:
+ String szValue = System.getProperty( EXT_LDAP_HOST );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_HOST, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_HOST, szValue );
+ }
+ // Check to see if the ldap port has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_PORT );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_PORT, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_PORT, szValue );
+ }
+
+ // Check to see if the admin pool uid has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_UID );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_UID, szValue );
+ // never display ldap admin userid name to log:
+ LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_UID );
+ }
+
+ // Check to see if the admin pool pw has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_PW );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_PW, szValue );
+ // never display password of any type to log:
+ LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_PW );
+ }
+
+ // Check to see if the admin pool min connections has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MIN );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
+ }
+
+ // Check to see if the admin pool max connections has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MAX );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
+ }
+
+ // Check to see if ssl enabled parameter has been overridden by a system property:
+ szValue = System.getProperty( EXT_ENABLE_LDAP_SSL );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.ENABLE_LDAP_SSL, szValue );
+ LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL, szValue );
+ }
+
+ // Check to see if the ssl debug enabled parameter has been overridden by a system property:
+ szValue = System.getProperty( EXT_ENABLE_LDAP_SSL_DEBUG );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
+ LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
+ }
+
+ // Check to see if the trust store location has been overridden by a system property:
+ szValue = System.getProperty( EXT_TRUST_STORE );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.TRUST_STORE, szValue );
+ LOG.info( PREFIX, GlobalIds.TRUST_STORE, szValue );
+ }
+
+ // Check to see if the trust store password has been overridden by a system property:
+ szValue = System.getProperty( EXT_TRUST_STORE_PW );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.TRUST_STORE_PW, szValue );
+ // never display password value to log:
+ LOG.info( "getExternalConfig override name [{}]", GlobalIds.TRUST_STORE_PW );
+ }
+
+ // Check to see if the trust store set parameter has been overridden by a system property:
+ szValue = System.getProperty( EXT_SET_TRUST_STORE_PROP );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.SET_TRUST_STORE_PROP, szValue );
+ LOG.info( PREFIX, GlobalIds.SET_TRUST_STORE_PROP, szValue );
+ }
+
+ // Check to see if the config realm name has been overridden by a system property:
+ szValue = System.getProperty( EXT_CONFIG_REALM );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.CONFIG_REALM, szValue );
+ LOG.info( PREFIX, GlobalIds.CONFIG_REALM, szValue );
+ }
+
+ // Check to see if the config realm name has been overridden by a system property:
+ szValue = System.getProperty( EXT_CONFIG_ROOT_DN );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.CONFIG_ROOT_PARAM, szValue );
+ LOG.info( PREFIX, GlobalIds.CONFIG_ROOT_PARAM, szValue );
+ }
+
+ // Check to see if the ldap server type has been overridden by a system property:
+ szValue = System.getProperty( EXT_SERVER_TYPE );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.SERVER_TYPE, szValue );
+ LOG.info( PREFIX, GlobalIds.SERVER_TYPE, szValue );
+ }
+ }
+
+ public PropertiesConfiguration getConfig() {
+ return config;
+ }
+
+ /**
+ * Gets the prop attribute as String value from the apache commons cfg component.
+ *
+ * @param name contains the name of the property.
+ * @return contains the value associated with the property or null if not not found.
+ */
+ public String getProperty( String name )
+ {
+ String value = null;
+ if ( config != null )
+ {
+ value = ( String ) config.getProperty( name );
+ LOG.debug( "getProperty name [{}] value [{}]", name, value );
+ }
+ else
+ {
+ LOG.error( "getProperty invalid config, can't read prop [{}]", name );
+ }
+ return value;
+ }
+
+
+ /**
+ * Get the property value from the apache commons config but specify a default value if not found.
+ *
+ * @param name contains the name of the property.
+ * @param defaultValue specified by client will be returned if property value is not found.
+ * @return contains the value for the property as a String.
+ */
+ public String getProperty( String name, String defaultValue )
+ {
+ String value = null;
+ if ( config != null )
+ {
+ value = ( String ) config.getProperty( name );
+ }
+ else
+ {
+ String warn = "getProperty invalid config, can't read prop [" + name + "]";
+ LOG.warn( warn );
+ }
+ if ( value == null || value.length() == 0 )
+ {
+ value = defaultValue;
+ }
+ return value;
+ }
+
+ /**
+ * Gets the int attribute of the Config class, or 0 if not found.
+ *
+ * @param key name of the property name.
+ * @return The int value or 0 if not found.
+ */
+ public int getInt( String key )
+ {
+ int value = 0;
+ if ( config != null )
+ {
+ value = config.getInt( key );
+ }
+ else
+ {
+ String warn = "getInt invalid config, can't read prop [" + key + "]";
+ LOG.warn( warn );
+ }
+ return value;
+ }
+
+
+ /**
+ * Gets the int attribute of the Config class or default value if not found.
+ *
+ * @param key name of the property name.
+ * @param defaultValue to use if property not found.
+ * @return The int value or default value if not found.
+ */
+ public int getInt( String key, int defaultValue )
+ {
+ int value = 0;
+ if ( config != null )
+ {
+ value = config.getInt( key, defaultValue );
+ }
+ else
+ {
+ String warn = "getInt invalid config, can't read prop [" + key + "]";
+ LOG.warn( warn );
+ }
+ return value;
+ }
+
+ /**
+ * Gets the boolean attribute associated with the name or false if not found.
+ *
+ * @param key name of the property name.
+ * @return The boolean value or false if not found.
+ */
+ public boolean getBoolean( String key )
+ {
+ boolean value = false;
+ if ( config != null )
+ {
+ value = config.getBoolean( key );
+ }
+ else
+ {
+ String warn = "getBoolean - invalid config, can't read prop [" + key + "]";
+ LOG.warn( warn );
+ }
+ return value;
+ }
+
+
+ /**
+ * Gets the boolean attribute associated with the name or false if not found.
+ *
+ * @param key name of the property name.
+ * @param defaultValue specified by client will be returned if property value is not found.
+ * @return The boolean value or false if not found.
+ */
+ public boolean getBoolean( String key, boolean defaultValue )
+ {
+ boolean value = defaultValue;
+ if ( config != null )
+ {
+ value = config.getBoolean( key, defaultValue );
+ }
+ else
+ {
+ String warn = "getBoolean - invalid config, can't read prop [" + key + "]";
+ LOG.warn( warn );
+ }
+ return value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
index 95dc7f3..843cf35 100644
--- a/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
@@ -97,7 +97,7 @@ public final class CacheMgr
* @return reference to cache for specified object.
*/
public Cache getCache( String cacheName )
- {
+ {
return CacheFactory.createInstance( cacheName, mEhCacheImpl );
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/d0924b2b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
index bf5d516..d2bd30f 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
@@ -20,6 +20,7 @@
package org.apache.directory.fortress.core.util.crypto;
import org.apache.directory.fortress.core.util.Config;
+import org.apache.directory.fortress.core.util.LocalConfig;
import org.jasypt.util.text.BasicTextEncryptor;
/**
@@ -48,7 +49,7 @@ public final class EncryptUtil
private void init()
{
textEncryptor = new BasicTextEncryptor();
- textEncryptor.setPassword(Config.getInstance().getProperty(CRYPTO_PROP, "adlfarerovcja;39 d"));
+ textEncryptor.setPassword(LocalConfig.getInstance().getProperty(CRYPTO_PROP, "adlfarerovcja;39 d"));
}
/**
@@ -84,7 +85,7 @@ public final class EncryptUtil
public static boolean isEnabled()
{
boolean result = false;
- if(Config.getInstance().getProperty(CRYPTO_PROP)!= null && !Config.getInstance().getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
+ if(LocalConfig.getInstance().getProperty(CRYPTO_PROP)!= null && !Config.getInstance().getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
{
result = true;
}
[12/15] directory-fortress-core git commit: changed vars in config to
private and added getters
Posted by cp...@apache.org.
changed vars in config to private and added getters
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/b09d8059
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/b09d8059
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/b09d8059
Branch: refs/heads/master
Commit: b09d80594ed3cff92fdce00151ba287e9b341f37
Parents: e9c143f
Author: clp207 <cl...@psu.edu>
Authored: Tue May 3 14:40:05 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Tue May 3 14:40:05 2016 -0400
----------------------------------------------------------------------
.../fortress/core/AccessMgrFactory.java | 2 +-
.../fortress/core/AdminMgrFactory.java | 2 +-
.../fortress/core/AuditMgrFactory.java | 2 +-
.../fortress/core/DelAccessMgrFactory.java | 2 +-
.../fortress/core/DelAdminMgrFactory.java | 2 +-
.../fortress/core/DelReviewMgrFactory.java | 2 +-
.../fortress/core/PwPolicyMgrFactory.java | 2 +-
.../fortress/core/ReviewMgrFactory.java | 2 +-
.../directory/fortress/core/impl/PermDAO.java | 2 +-
.../directory/fortress/core/impl/UserDAO.java | 20 +++++-----
.../fortress/core/ldap/LdapDataProvider.java | 4 +-
.../fortress/core/model/ConstraintUtil.java | 8 ++--
.../directory/fortress/core/model/PropUtil.java | 2 +-
.../fortress/core/model/UserAdminRole.java | 4 +-
.../directory/fortress/core/model/UserRole.java | 4 +-
.../directory/fortress/core/util/Config.java | 40 +++++++++++++++-----
.../fortress/core/impl/FortressJUnitTest.java | 16 ++++----
17 files changed, 69 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
index 3d4a98a..8a06376 100755
--- a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
@@ -68,7 +68,7 @@ public final class AccessMgrFactory
AccessMgr accessMgr;
if ( StringUtils.isEmpty( accessClassName ) )
{
- if(Config.getInstance().IS_REST)
+ if(Config.getInstance().isRestEnabled())
{
accessMgr = new AccessMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
index b17dae7..f07fe22 100755
--- a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
@@ -71,7 +71,7 @@ public final class AdminMgrFactory
if ( StringUtils.isEmpty( adminClassName ) )
{
- if(Config.getInstance().IS_REST)
+ if(Config.getInstance().isRestEnabled())
{
adminMgr = new AdminMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
index 57864a8..c578598 100755
--- a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
@@ -70,7 +70,7 @@ public final class AuditMgrFactory
if ( StringUtils.isEmpty( auditClassName ) )
{
- if(Config.getInstance().IS_REST)
+ if(Config.getInstance().isRestEnabled())
{
auditMgr = new AuditMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
index 98e546c..6eeb227 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
@@ -70,7 +70,7 @@ public final class DelAccessMgrFactory
if ( StringUtils.isEmpty( accessClassName ) )
{
- if(Config.getInstance().IS_REST)
+ if(Config.getInstance().isRestEnabled())
{
accessMgr = new DelAccessMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
index b5b0d2e..9720fe3 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
@@ -71,7 +71,7 @@ public final class DelAdminMgrFactory
if ( Strings.isEmpty( dAdminClassName ) )
{
- if ( Config.getInstance().IS_REST )
+ if ( Config.getInstance().isRestEnabled() )
{
delAdminMgr = new DelAdminMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
index 7e35055..d958ce6 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
@@ -68,7 +68,7 @@ public final class DelReviewMgrFactory
if ( StringUtils.isEmpty( dReviewClassName ) )
{
- if(Config.getInstance().IS_REST)
+ if(Config.getInstance().isRestEnabled())
{
delReviewMgr = new DelReviewMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
index f32d1b7..7cbef5e 100755
--- a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
@@ -69,7 +69,7 @@ public final class PwPolicyMgrFactory
if ( StringUtils.isEmpty( policyClassName ) )
{
- if(Config.getInstance().IS_REST)
+ if(Config.getInstance().isRestEnabled())
{
policyMgr = new PwPolicyMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
index 720b504..a0e6018 100755
--- a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
@@ -69,7 +69,7 @@ public final class ReviewMgrFactory
if ( StringUtils.isEmpty( reviewClassName ) )
{
- if(Config.getInstance().IS_REST)
+ if(Config.getInstance().isRestEnabled())
{
reviewMgr = new ReviewMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
index 326d18c..8b3e594 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
@@ -921,7 +921,7 @@ final class PermDAO extends LdapDataProvider
throws FinderException
{
// Audit can be turned off here with fortress config param: 'disable.audit=true'
- if ( Config.getInstance().IS_OPENLDAP && ! Config.getInstance().IS_AUDIT_DISABLED )
+ if ( Config.getInstance().isOpenldap() && ! Config.getInstance().isAuditDisabled() )
{
try
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
index 21f2e39..8cef25f 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
@@ -228,12 +228,14 @@ final class UserDAO extends LdapDataProvider
// POSIX_ACCOUNT_OBJECT_CLASS_NAME
};
- LOG.debug( "GlobalIds.IS_OPENLDAP: " + Config.getInstance().IS_OPENLDAP );
- LOG.debug( "GlobalIds.IS_OPENLDAP ? OPENLDAP_PW_RESET : null: " + ( Config.getInstance().IS_OPENLDAP ? OPENLDAP_PW_RESET
+ boolean isOpenldap = Config.getInstance().isOpenldap();
+
+ LOG.debug( "GlobalIds.IS_OPENLDAP: " + isOpenldap );
+ LOG.debug( "GlobalIds.IS_OPENLDAP ? OPENLDAP_PW_RESET : null: " + ( isOpenldap ? OPENLDAP_PW_RESET
: null ) );
- LOG.debug( "GlobalIds.IS_OPENLDAP: " + Config.getInstance().IS_OPENLDAP );
+ LOG.debug( "GlobalIds.IS_OPENLDAP: " + isOpenldap );
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( isOpenldap )
{
// This default set of attributes contains all and is used for search operations.
defaultAtrs = new String[]
@@ -497,7 +499,7 @@ final class UserDAO extends LdapDataProvider
myEntry.add( SYSTEM_USER, entity.isSystem().toString().toUpperCase() );
}
- if ( Config.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
+ if ( Config.getInstance().isOpenldap() && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
{
String pwdPolicyDn = GlobalIds.POLICY_NODE_TYPE + "=" + entity.getPwPolicy() + "," + getRootDn(
entity.getContextId(), GlobalIds.PPOLICY_ROOT );
@@ -602,7 +604,7 @@ final class UserDAO extends LdapDataProvider
entity.getTitle() ) );
}
- if ( Config.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
+ if ( Config.getInstance().isOpenldap() && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
{
String szDn = GlobalIds.POLICY_NODE_TYPE + "=" + entity.getPwPolicy() + "," + getRootDn( entity
.getContextId(), GlobalIds.PPOLICY_ROOT );
@@ -1056,7 +1058,7 @@ final class UserDAO extends LdapDataProvider
case CHANGE_AFTER_RESET:
// Don't throw exception if authenticating in J2EE Realm - The Web application must
// give user a chance to modify their password.
- if ( !Config.getInstance().IS_REALM )
+ if ( !Config.getInstance().isRealm() )
{
errMsg = msgHdr + "PASSWORD HAS BEEN RESET BY LDAP_ADMIN_POOL_UID";
rc = GlobalErrIds.USER_PW_RESET;
@@ -1712,7 +1714,7 @@ final class UserDAO extends LdapDataProvider
modify( ld, userDn, mods );
// This modify update audit attributes on the User entry (if enabled):
- if ( Config.getInstance().IS_OPENLDAP && ! Config.getInstance().IS_AUDIT_DISABLED )
+ if ( Config.getInstance().isOpenldap() && ! Config.getInstance().isAuditDisabled() )
{
mods = new ArrayList<>();
modify( ld, userDn, mods, entity );
@@ -2088,7 +2090,7 @@ final class UserDAO extends LdapDataProvider
entity.addProperties( PropUtil.getProperties( getAttributes( entry, GlobalIds.PROPS ) ) );
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
szBoolean = getAttribute( entry, OPENLDAP_PW_RESET );
if ( szBoolean != null && szBoolean.equalsIgnoreCase( "true" ) )
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
index 908b9fb..c2b955e 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
@@ -240,7 +240,7 @@ public abstract class LdapDataProvider
{
COUNTERS.incrementAdd();
- if ( !Config.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
+ if ( !Config.getInstance().isAuditDisabled() && ( entity != null ) && ( entity.getAdminSession() != null ) )
{
if ( StringUtils.isNotEmpty( entity.getAdminSession().getInternalUserId() ) )
{
@@ -501,7 +501,7 @@ public abstract class LdapDataProvider
*/
private void audit( List<Modification> mods, FortEntity entity )
{
- if ( !Config.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
+ if ( !Config.getInstance().isAuditDisabled() && ( entity != null ) && ( entity.getAdminSession() != null ) )
{
if ( StringUtils.isNotEmpty( entity.getAdminSession().getInternalUserId() ) )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java b/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
index a1eb7db..35327b7 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
@@ -134,7 +134,7 @@ public class ConstraintUtil
{
if ( StringUtils.isNotEmpty( inputString ) )
{
- StringTokenizer tkn = new StringTokenizer( inputString, Config.getInstance().DELIMITER, true );
+ StringTokenizer tkn = new StringTokenizer( inputString, Config.getInstance().getDelimiter(), true );
if ( tkn.countTokens() > 0 )
{
int count = tkn.countTokens();
@@ -143,11 +143,11 @@ public class ConstraintUtil
for ( int i = 0; i < count; i++ )
{
String szValue = tkn.nextToken();
- if ( szValue.equals( Config.getInstance().DELIMITER ) && !previousTokenWasDelimiter )
+ if ( szValue.equals( Config.getInstance().getDelimiter() ) && !previousTokenWasDelimiter )
{
previousTokenWasDelimiter = true;
}
- else if ( szValue.equals( Config.getInstance().DELIMITER ) )
+ else if ( szValue.equals( Config.getInstance().getDelimiter() ) )
{
previousTokenWasDelimiter = true;
index++;
@@ -206,7 +206,7 @@ public class ConstraintUtil
public static String setConstraint( Constraint constraint )
{
String szConstraint = null;
- String delimiter = Config.getInstance().DELIMITER;
+ String delimiter = Config.getInstance().getDelimiter();
if ( constraint != null )
{
StringBuilder sb = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java b/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
index 3fb2b87..914f989 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
@@ -92,7 +92,7 @@ public final class PropUtil
*/
public static Properties getProperties( String inputString, char separator )
{
- return getProperties( inputString, separator, Config.getInstance().DELIMITER );
+ return getProperties( inputString, separator, Config.getInstance().getDelimiter() );
}
/**
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java b/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
index e064a12..84e7d8d 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
@@ -163,7 +163,7 @@ public class UserAdminRole extends UserRole implements Administrator
{
if ( ( szRawData != null ) && ( szRawData.length() > 0 ) )
{
- String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, Config.getInstance().DELIMITER );
+ String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, Config.getInstance().getDelimiter() );
for ( int i = 0; i < tokens.length; i++ )
{
if ( StringUtils.isNotEmpty( tokens[i] ) )
@@ -247,7 +247,7 @@ public class UserAdminRole extends UserRole implements Administrator
public String getRawData()
{
String szRole;
- String delimeter = Config.getInstance().DELIMITER;
+ String delimeter = Config.getInstance().getDelimiter();
StringBuilder sb = new StringBuilder();
sb.append( name );
sb.append( delimeter );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
index e769699..27c0d70 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
@@ -152,7 +152,7 @@ public class UserRole extends FortEntity implements Serializable, Constraint
{
if ( ( szRawData != null ) && ( szRawData.length() > 0 ) )
{
- String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, Config.getInstance().DELIMITER );
+ String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, Config.getInstance().getDelimiter() );
for ( int i = 0; i < tokens.length; i++ )
{
if ( StringUtils.isNotEmpty( tokens[i] ) )
@@ -211,7 +211,7 @@ public class UserRole extends FortEntity implements Serializable, Constraint
@Override
public String getRawData()
{
- String delimeter = Config.getInstance().DELIMITER;
+ String delimeter = Config.getInstance().getDelimiter();
StringBuilder sb = new StringBuilder();
sb.append( name );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index 355fce9..446531a 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -75,20 +75,20 @@ public final class Config
private boolean remoteConfigLoaded = false;
- public boolean IS_REST;
- public boolean IS_AUDIT_DISABLED;
- public boolean IS_OPENLDAP;
+ private boolean restEnabled;
+ private boolean auditDisabled;
+ private boolean openldap;
/**
* This constant is used during authentication to determine if runtime is security realm. If IS_REALM == true,
* the authentication module will not throw SecurityException on password resets. This is to enable the authentication
* event to succeed allowing the application to prompt user to change their password.
*/
- public boolean IS_REALM;
+ private boolean realm;
/**
* Fortress stores complex attribute types within a single attribute in ldap. Usually a delimiter of '$' is used for string tokenization.
* format: {@code part1$part2$part3....} Stored in fortress.properties as 'attr.delimiter=$'
*/
- public String DELIMITER;
+ private String delimiter;
private static volatile Config INSTANCE = null;
@@ -304,15 +304,15 @@ public final class Config
//ignore
}
- IS_AUDIT_DISABLED = ( ( getProperty( GlobalIds.DISABLE_AUDIT ) != null ) && ( getProperty( GlobalIds.DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
+ auditDisabled = ( ( getProperty( GlobalIds.DISABLE_AUDIT ) != null ) && ( getProperty( GlobalIds.DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
- IS_REST = ( ( getProperty( GlobalIds.ENABLE_REST ) != null ) && ( getProperty( GlobalIds.ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
+ restEnabled = ( ( getProperty( GlobalIds.ENABLE_REST ) != null ) && ( getProperty( GlobalIds.ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
- IS_REALM = GlobalIds.REALM_TYPE.equalsIgnoreCase( getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
+ realm = GlobalIds.REALM_TYPE.equalsIgnoreCase( getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
- IS_OPENLDAP = ( ( getProperty( GlobalIds.SERVER_TYPE ) != null ) && ( getProperty( GlobalIds.SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
+ openldap = ( ( getProperty( GlobalIds.SERVER_TYPE ) != null ) && ( getProperty( GlobalIds.SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
- DELIMITER = getProperty( "attr.delimiter", "$" );
+ delimiter = getProperty( "attr.delimiter", "$" );
remoteConfigLoaded = true;
}
@@ -624,4 +624,24 @@ public final class Config
public boolean isRemoteConfigLoaded() {
return remoteConfigLoaded;
}
+
+ public boolean isRestEnabled() {
+ return restEnabled;
+ }
+
+ public boolean isAuditDisabled() {
+ return auditDisabled;
+ }
+
+ public boolean isOpenldap() {
+ return openldap;
+ }
+
+ public boolean isRealm() {
+ return realm;
+ }
+
+ public String getDelimiter() {
+ return delimiter;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b09d8059/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java b/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
index 5429386..c590b68 100755
--- a/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
+++ b/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
@@ -105,7 +105,7 @@ public class FortressJUnitTest extends TestCase
if ( !isFirstRun() )
{
// PwPolicyMgr PW Policy Teardown:
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
suite.addTest( new PswdPolicyMgrImplTest( "testDeletePasswordPolicy" ) );
}
@@ -126,7 +126,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AdminMgrImplTest( "testDelRoleDescendant" ) );
suite.addTest( new AdminMgrImplTest( "testDelRoleAscendant" ) );
suite.addTest( new AdminMgrImplTest( "testDeleteRole" ) );
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
suite.addTest( new PswdPolicyMgrImplTest( "testDelete" ) );
}
@@ -151,7 +151,7 @@ public class FortressJUnitTest extends TestCase
/* 2. Build Up */
/***********************************************************/
// PW PolicyMgr APIs:
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
suite.addTest( new PswdPolicyMgrImplTest( "testAdd" ) );
suite.addTest( new PswdPolicyMgrImplTest( "testUpdate" ) );
@@ -188,7 +188,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AdminMgrImplTest( "testUpdateRole" ) );
suite.addTest( new AdminMgrImplTest( "testAddUser" ) );
suite.addTest( new AdminMgrImplTest( "testUpdateUser" ) );
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
suite.addTest( new PswdPolicyMgrImplTest( "testUpdatePasswordPolicy" ) );
}
@@ -210,7 +210,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new DelegatedMgrImplTest( "testSearchAdminRole" ) );
// ReviewMgr RBAC:
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
suite.addTest( new PswdPolicyMgrImplTest( "testRead" ) );
suite.addTest( new PswdPolicyMgrImplTest( "testSearch" ) );
@@ -253,7 +253,7 @@ public class FortressJUnitTest extends TestCase
// AccessMgr RBAC:
suite.addTest( new AccessMgrImplTest( "testGetUserId" ) );
suite.addTest( new AccessMgrImplTest( "testGetUser" ) );
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
// These tests are reliant on OpenLDAP's pwpolicy overlay:
suite.addTest( new AdminMgrImplTest( "testResetPassword" ) );
@@ -279,7 +279,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AccessMgrImplTest( "testCreateSessionWithRolesTrusted" ) );
// PwPolicyMgr PW Policy checks:
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
// These tests are reliant on OpenLDAP's pwpolicy overlay:
suite.addTest( new PswdPolicyMgrImplTest( "testMinAge" ) );
@@ -301,7 +301,7 @@ public class FortressJUnitTest extends TestCase
/* 5. Audit Checks */
/***********************************************************/
//suite.addTest(new AuditMgrImplTest("testSearchAuthNInvalid"));
- if ( Config.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().isOpenldap() )
{
// These tests reliant on OpenLDAP's slapo access log overlay:
suite.addTest( new AuditMgrImplTest( "testSearchBinds" ) );
[11/15] directory-fortress-core git commit: removed local config and
put check in all factories to load remote config
Posted by cp...@apache.org.
removed local config and put check in all factories to load remote config
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/e9c143f7
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/e9c143f7
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/e9c143f7
Branch: refs/heads/master
Commit: e9c143f7050d04c4540ae1b57cafff44bb33b9af
Parents: a5ad103
Author: clp207 <cl...@psu.edu>
Authored: Tue May 3 13:45:06 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Tue May 3 13:45:06 2016 -0400
----------------------------------------------------------------------
.../fortress/core/AccelMgrFactory.java | 7 +
.../fortress/core/AccessMgrFactory.java | 7 +
.../fortress/core/AdminMgrFactory.java | 7 +
.../fortress/core/AuditMgrFactory.java | 7 +
.../fortress/core/DelAccessMgrFactory.java | 7 +
.../fortress/core/DelAdminMgrFactory.java | 7 +
.../fortress/core/DelReviewMgrFactory.java | 7 +
.../fortress/core/GroupMgrFactory.java | 7 +
.../fortress/core/PwPolicyMgrFactory.java | 7 +
.../fortress/core/ReviewMgrFactory.java | 7 +
.../directory/fortress/core/impl/ConfigDAO.java | 4 +-
.../core/ldap/LdapConnectionProvider.java | 64 ++--
.../directory/fortress/core/util/Config.java | 190 +++++++++-
.../fortress/core/util/LocalConfig.java | 360 -------------------
.../fortress/core/util/crypto/EncryptUtil.java | 6 +-
15 files changed, 294 insertions(+), 400 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
index fabea9f..5fd7ee9 100644
--- a/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
@@ -71,6 +71,13 @@ public final class AccelMgrFactory
{
accelMgr = (AccelMgr) ClassUtil.createInstance(accelClassName);
}
+
+ if(accelMgr instanceof AccelMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
accelMgr.setContextId(contextId);
return accelMgr;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
index 1455379..3d4a98a 100755
--- a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
@@ -81,6 +81,13 @@ public final class AccessMgrFactory
{
accessMgr = (AccessMgr) ClassUtil.createInstance(accessClassName);
}
+
+ if(accessMgr instanceof AccessMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
accessMgr.setContextId(contextId);
return accessMgr;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
index 8c617d5..b17dae7 100755
--- a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
@@ -85,6 +85,13 @@ public final class AdminMgrFactory
adminMgr = (AdminMgr) ClassUtil.createInstance(adminClassName);
}
+ if(adminMgr instanceof AdminMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
+
adminMgr.setContextId(contextId);
return adminMgr;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
index 8ae1834..57864a8 100755
--- a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
@@ -83,6 +83,13 @@ public final class AuditMgrFactory
{
auditMgr = (AuditMgr) ClassUtil.createInstance(auditClassName);
}
+
+ if(auditMgr instanceof AuditMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
auditMgr.setContextId(contextId);
return auditMgr;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
index ed8a905..98e546c 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
@@ -83,6 +83,13 @@ public final class DelAccessMgrFactory
{
accessMgr = (DelAccessMgr) ClassUtil.createInstance(accessClassName);
}
+
+ if(accessMgr instanceof DelAccessMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
accessMgr.setContextId(contextId);
return accessMgr;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
index 00d2c5a..b5b0d2e 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
@@ -85,6 +85,13 @@ public final class DelAdminMgrFactory
delAdminMgr = (DelAdminMgr) ClassUtil.createInstance( dAdminClassName );
}
+ if(delAdminMgr instanceof DelAdminMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
+
delAdminMgr.setContextId(contextId);
return delAdminMgr;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
index 1c008b4..7e35055 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
@@ -81,6 +81,13 @@ public final class DelReviewMgrFactory
{
delReviewMgr = (DelReviewMgr) ClassUtil.createInstance(dReviewClassName);
}
+
+ if(delReviewMgr instanceof DelReviewMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
delReviewMgr.setContextId(contextId);
return delReviewMgr;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
index 7b3473c..22bd0c1 100755
--- a/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
@@ -79,6 +79,13 @@ public final class GroupMgrFactory
GroupMgr groupMgr = (GroupMgr) ClassUtil.createInstance(groupClassName);
groupMgr.setContextId(contextId);
+ if(groupMgr instanceof GroupMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
+
return groupMgr;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
index 0fb127a..f32d1b7 100755
--- a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
@@ -83,6 +83,13 @@ public final class PwPolicyMgrFactory
policyMgr = (PwPolicyMgr) ClassUtil.createInstance(policyClassName);
}
+ if(policyMgr instanceof PwPolicyMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
+
policyMgr.setContextId(contextId);
return policyMgr;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
index 2ee3f8c..720b504 100755
--- a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
@@ -83,6 +83,13 @@ public final class ReviewMgrFactory
reviewMgr = ( ReviewMgr ) ClassUtil.createInstance(reviewClassName);
}
+ if(reviewMgr instanceof ReviewMgrImpl){
+ Config cfg = Config.getInstance();
+ if(!cfg.isRemoteConfigLoaded()){
+ cfg.loadRemoteConfig();
+ }
+ }
+
reviewMgr.setContextId(contextId);
return reviewMgr;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
index f971c46..e765762 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
@@ -39,7 +39,7 @@ import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.PropUtil;
-import org.apache.directory.fortress.core.util.LocalConfig;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -104,7 +104,7 @@ final class ConfigDAO extends LdapDataProvider
{
super();
- CONFIG_ROOT_DN = LocalConfig.getInstance().getProperty( GlobalIds.CONFIG_ROOT_PARAM );
+ CONFIG_ROOT_DN = Config.getInstance().getProperty( GlobalIds.CONFIG_ROOT_PARAM );
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java
index dd56e93..e18af91 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java
@@ -13,7 +13,7 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.fortress.core.CfgRuntimeException;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.util.LocalConfig;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.crypto.EncryptUtil;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.LdapConnectionConfig;
@@ -73,55 +73,55 @@ public class LdapConnectionProvider {
private void init()
{
IS_SSL = (
- LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
- LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
- LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) != null &&
- LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) != null );
+ Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
+ Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
+ Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) != null &&
+ Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) != null );
IS_SET_TRUST_STORE_PROP = (
IS_SSL &&
- LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
- LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
+ Config.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
+ Config.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
- IS_SSL_DEBUG = ( ( LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( LocalConfig
+ IS_SSL_DEBUG = ( ( Config.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( Config
.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ).equalsIgnoreCase( "true" ) ) );
- String host = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_HOST, "localhost" );
- int port = LocalConfig.getInstance().getInt( GlobalIds.LDAP_PORT, 389 );
- int min = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
- int max = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
- int logmin = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MIN, 1 );
- int logmax = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MAX, 10 );
+ String host = Config.getInstance().getProperty( GlobalIds.LDAP_HOST, "localhost" );
+ int port = Config.getInstance().getInt( GlobalIds.LDAP_PORT, 389 );
+ int min = Config.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
+ int max = Config.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
+ int logmin = Config.getInstance().getInt( LDAP_LOG_POOL_MIN, 1 );
+ int logmax = Config.getInstance().getInt( LDAP_LOG_POOL_MAX, 10 );
LOG.info( "LDAP POOL: host=[{}], port=[{}], min=[{}], max=[{}]", host, port, min, max );
if ( IS_SET_TRUST_STORE_PROP )
{
LOG.info( "Set JSSE truststore properties in Apache LDAP client:" );
- LOG.info( "javax.net.ssl.trustStore: {}", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
+ LOG.info( "javax.net.ssl.trustStore: {}", Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
LOG.info( "javax.net.debug: {}", IS_SSL_DEBUG );
- System.setProperty( "javax.net.ssl.trustStore", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
- System.setProperty( "javax.net.ssl.trustStorePassword", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) );
+ System.setProperty( "javax.net.ssl.trustStore", Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
+ System.setProperty( "javax.net.ssl.trustStorePassword", Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) );
System.setProperty( "javax.net.debug", Boolean.valueOf( IS_SSL_DEBUG ).toString() );
}
LdapConnectionConfig config = new LdapConnectionConfig();
config.setLdapHost( host );
config.setLdapPort( port );
- config.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+ config.setName( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
config.setUseSsl( IS_SSL );
//config.setTrustManagers( new NoVerificationTrustManager() );
- if(LocalConfig.getInstance().getBoolean(ENABLE_LDAP_STARTTLS, false)){
+ if(Config.getInstance().getBoolean(ENABLE_LDAP_STARTTLS, false)){
config.setUseTls(true);
}
- if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ if ( IS_SSL && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
{
// validate certificates but allow self-signed certs if within this truststore:
- config.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ), LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW )
+ config.setTrustManagers( new LdapClientTrustStoreManager( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ), Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW )
.toCharArray(), null,
true ) );
}
@@ -129,11 +129,11 @@ public class LdapConnectionProvider {
String adminPw;
if ( EncryptUtil.isEnabled() )
{
- adminPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
+ adminPw = EncryptUtil.getInstance().decrypt( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
}
else
{
- adminPw = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
+ adminPw = Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
}
config.setCredentials( adminPw );
@@ -188,28 +188,28 @@ public class LdapConnectionProvider {
LdapConnectionConfig logConfig = new LdapConnectionConfig();
logConfig.setLdapHost( host );
logConfig.setLdapPort( port );
- logConfig.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+ logConfig.setName( Config.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
logConfig.setUseSsl( IS_SSL );
- if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ if ( IS_SSL && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
{
// validate certificates but allow self-signed certs if within this truststore:
- logConfig.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ),
- LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
+ logConfig.setTrustManagers( new LdapClientTrustStoreManager( Config.getInstance().getProperty( GlobalIds.TRUST_STORE ),
+ Config.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
null, true ) );
}
- logConfig.setName( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_UID, "" ) );
+ logConfig.setName( Config.getInstance().getProperty( LDAP_LOG_POOL_UID, "" ) );
String logPw;
if ( EncryptUtil.isEnabled() )
{
- logPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW ) );
+ logPw = EncryptUtil.getInstance().decrypt( Config.getInstance().getProperty( LDAP_LOG_POOL_PW ) );
}
else
{
- logPw = LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW );
+ logPw = Config.getInstance().getProperty( LDAP_LOG_POOL_PW );
}
logConfig.setCredentials( logPw );
poolFactory = new ValidatingPoolableLdapConnectionFactory( logConfig );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index 556725d..355fce9 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -20,10 +20,12 @@
package org.apache.directory.fortress.core.util;
+import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;
import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang.StringUtils;
import org.apache.directory.fortress.core.CfgException;
import org.apache.directory.fortress.core.CfgRuntimeException;
import org.apache.directory.fortress.core.ConfigMgr;
@@ -54,6 +56,25 @@ public final class Config
private static final String CLS_NM = Config.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+ private static final String PROP_FILE = "fortress.properties";
+ private static final String USER_PROP_FILE = "fortress.user.properties";
+ private static final String EXT_LDAP_HOST = "fortress.host";
+ private static final String EXT_LDAP_PORT = "fortress.port";
+ private static final String EXT_LDAP_ADMIN_POOL_UID = "fortress.admin.user";
+ private static final String EXT_LDAP_ADMIN_POOL_PW = "fortress.admin.pw";
+ private static final String EXT_LDAP_ADMIN_POOL_MIN = "fortress.min.admin.conn";
+ private static final String EXT_LDAP_ADMIN_POOL_MAX = "fortress.max.admin.conn";
+ private static final String EXT_ENABLE_LDAP_SSL = "fortress.enable.ldap.ssl";
+ private static final String EXT_ENABLE_LDAP_SSL_DEBUG = "fortress.enable.ldap.ssl.debug";
+ private static final String EXT_TRUST_STORE = "fortress.trust.store";
+ private static final String EXT_TRUST_STORE_PW = "fortress.trust.store.password";
+ private static final String EXT_SET_TRUST_STORE_PROP = "fortress.trust.store.set.prop";
+ private static final String EXT_CONFIG_REALM = "fortress.config.realm";
+ private static final String EXT_CONFIG_ROOT_DN = "fortress.config.root";
+ private static final String EXT_SERVER_TYPE = "fortress.ldap.server.type";
+
+ private boolean remoteConfigLoaded = false;
+
public boolean IS_REST;
public boolean IS_AUDIT_DISABLED;
public boolean IS_OPENLDAP;
@@ -83,12 +104,171 @@ public final class Config
return INSTANCE;
}
- private void init()
+ private void loadLocalConfig()
{
try
{
- config = LocalConfig.getInstance().getConfig();
+ // Load the system config file.
+ URL fUrl = Config.class.getClassLoader().getResource( PROP_FILE );
+ config = new PropertiesConfiguration();
+ config.setDelimiterParsingDisabled( true );
+ if ( fUrl == null )
+ {
+ String error = "static init: Error, null cfg file: " + PROP_FILE;
+ LOG.warn( error );
+ }
+ else
+ {
+ LOG.info( "static init: found from: {} path: {}", PROP_FILE, fUrl.getPath() );
+ config.load( fUrl );
+ LOG.info( "static init: loading from: {}", PROP_FILE );
+ }
+
+ URL fUserUrl = Config.class.getClassLoader().getResource( USER_PROP_FILE );
+ if ( fUserUrl != null )
+ {
+ LOG.info( "static init: found user properties from: {} path: {}", USER_PROP_FILE, fUserUrl.getPath() );
+ config.load( fUserUrl );
+ }
+
+ // Check to see if any of the ldap connection parameters have been overridden:
+ getExternalConfig();
+ }
+ catch ( org.apache.commons.configuration.ConfigurationException ex )
+ {
+ String error = "static init: Error loading from cfg file: [" + PROP_FILE
+ + "] ConfigurationException=" + ex;
+ LOG.error( error );
+ throw new CfgRuntimeException( GlobalErrIds.FT_CONFIG_BOOTSTRAP_FAILED, error, ex );
+ }
+ }
+
+ /**
+ * This method is called during configuration initialization. It determines if
+ * the ldap connection coordinates have been overridden as system properties.
+ */
+ private void getExternalConfig()
+ {
+ String PREFIX = "getExternalConfig override name [{}] value [{}]";
+ // Check to see if the ldap host has been overridden by a system property:
+ String szValue = System.getProperty( EXT_LDAP_HOST );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_HOST, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_HOST, szValue );
+ }
+ // Check to see if the ldap port has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_PORT );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_PORT, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_PORT, szValue );
+ }
+
+ // Check to see if the admin pool uid has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_UID );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_UID, szValue );
+ // never display ldap admin userid name to log:
+ LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_UID );
+ }
+
+ // Check to see if the admin pool pw has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_PW );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_PW, szValue );
+ // never display password of any type to log:
+ LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_PW );
+ }
+
+ // Check to see if the admin pool min connections has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MIN );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
+ }
+
+ // Check to see if the admin pool max connections has been overridden by a system property:
+ szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MAX );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
+ LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
+ }
+
+ // Check to see if ssl enabled parameter has been overridden by a system property:
+ szValue = System.getProperty( EXT_ENABLE_LDAP_SSL );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.ENABLE_LDAP_SSL, szValue );
+ LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL, szValue );
+ }
+
+ // Check to see if the ssl debug enabled parameter has been overridden by a system property:
+ szValue = System.getProperty( EXT_ENABLE_LDAP_SSL_DEBUG );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
+ LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
+ }
+
+ // Check to see if the trust store location has been overridden by a system property:
+ szValue = System.getProperty( EXT_TRUST_STORE );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.TRUST_STORE, szValue );
+ LOG.info( PREFIX, GlobalIds.TRUST_STORE, szValue );
+ }
+
+ // Check to see if the trust store password has been overridden by a system property:
+ szValue = System.getProperty( EXT_TRUST_STORE_PW );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.TRUST_STORE_PW, szValue );
+ // never display password value to log:
+ LOG.info( "getExternalConfig override name [{}]", GlobalIds.TRUST_STORE_PW );
+ }
+ // Check to see if the trust store set parameter has been overridden by a system property:
+ szValue = System.getProperty( EXT_SET_TRUST_STORE_PROP );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.SET_TRUST_STORE_PROP, szValue );
+ LOG.info( PREFIX, GlobalIds.SET_TRUST_STORE_PROP, szValue );
+ }
+
+ // Check to see if the config realm name has been overridden by a system property:
+ szValue = System.getProperty( EXT_CONFIG_REALM );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.CONFIG_REALM, szValue );
+ LOG.info( PREFIX, GlobalIds.CONFIG_REALM, szValue );
+ }
+
+ // Check to see if the config realm name has been overridden by a system property:
+ szValue = System.getProperty( EXT_CONFIG_ROOT_DN );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.CONFIG_ROOT_PARAM, szValue );
+ LOG.info( PREFIX, GlobalIds.CONFIG_ROOT_PARAM, szValue );
+ }
+
+ // Check to see if the ldap server type has been overridden by a system property:
+ szValue = System.getProperty( EXT_SERVER_TYPE );
+ if( StringUtils.isNotEmpty( szValue ))
+ {
+ config.setProperty( GlobalIds.SERVER_TYPE, szValue );
+ LOG.info( PREFIX, GlobalIds.SERVER_TYPE, szValue );
+ }
+ }
+
+ public void loadRemoteConfig()
+ {
+ try
+ {
// Retrieve parameters from the config node stored in target LDAP DIT:
String realmName = config.getString( GlobalIds.CONFIG_REALM, "DEFAULT" );
if ( realmName != null && realmName.length() > 0 )
@@ -134,6 +314,7 @@ public final class Config
DELIMITER = getProperty( "attr.delimiter", "$" );
+ remoteConfigLoaded = true;
}
else
{
@@ -155,7 +336,7 @@ public final class Config
*/
private Config()
{
- init();
+ loadLocalConfig();
}
private char[] loadLdapEscapeChars()
@@ -440,4 +621,7 @@ public final class Config
return props;
}
+ public boolean isRemoteConfigLoaded() {
+ return remoteConfigLoaded;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java b/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java
deleted file mode 100644
index 7c612e1..0000000
--- a/src/main/java/org/apache/directory/fortress/core/util/LocalConfig.java
+++ /dev/null
@@ -1,360 +0,0 @@
-package org.apache.directory.fortress.core.util;
-
-import java.net.URL;
-
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.CfgRuntimeException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LocalConfig {
-
- private static final String CLS_NM = LocalConfig.class.getName();
- private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
-
- private static final String PROP_FILE = "fortress.properties";
- private static final String USER_PROP_FILE = "fortress.user.properties";
- private static final String EXT_LDAP_HOST = "fortress.host";
- private static final String EXT_LDAP_PORT = "fortress.port";
- private static final String EXT_LDAP_ADMIN_POOL_UID = "fortress.admin.user";
- private static final String EXT_LDAP_ADMIN_POOL_PW = "fortress.admin.pw";
- private static final String EXT_LDAP_ADMIN_POOL_MIN = "fortress.min.admin.conn";
- private static final String EXT_LDAP_ADMIN_POOL_MAX = "fortress.max.admin.conn";
- private static final String EXT_ENABLE_LDAP_SSL = "fortress.enable.ldap.ssl";
- private static final String EXT_ENABLE_LDAP_SSL_DEBUG = "fortress.enable.ldap.ssl.debug";
- private static final String EXT_TRUST_STORE = "fortress.trust.store";
- private static final String EXT_TRUST_STORE_PW = "fortress.trust.store.password";
- private static final String EXT_SET_TRUST_STORE_PROP = "fortress.trust.store.set.prop";
- private static final String EXT_CONFIG_REALM = "fortress.config.realm";
- private static final String EXT_CONFIG_ROOT_DN = "fortress.config.root";
- private static final String EXT_SERVER_TYPE = "fortress.ldap.server.type";
-
- private PropertiesConfiguration config;
-
- private static volatile LocalConfig INSTANCE = null;
-
- public static LocalConfig getInstance() {
- if(INSTANCE == null) {
- synchronized (LocalConfig.class) {
- if(INSTANCE == null){
- INSTANCE = new LocalConfig();
- }
- }
- }
- return INSTANCE;
- }
-
- private void init()
- {
- try
- {
- // Load the system config file.
- URL fUrl = Config.class.getClassLoader().getResource( PROP_FILE );
- config = new PropertiesConfiguration();
- config.setDelimiterParsingDisabled( true );
- if ( fUrl == null )
- {
- String error = "static init: Error, null cfg file: " + PROP_FILE;
- LOG.warn( error );
- }
- else
- {
- LOG.info( "static init: found from: {} path: {}", PROP_FILE, fUrl.getPath() );
- config.load( fUrl );
- LOG.info( "static init: loading from: {}", PROP_FILE );
- }
-
- URL fUserUrl = Config.class.getClassLoader().getResource( USER_PROP_FILE );
- if ( fUserUrl != null )
- {
- LOG.info( "static init: found user properties from: {} path: {}", USER_PROP_FILE, fUserUrl.getPath() );
- config.load( fUserUrl );
- }
-
- // Check to see if any of the ldap connection parameters have been overridden:
- getExternalConfig();
- }
- catch ( org.apache.commons.configuration.ConfigurationException ex )
- {
- String error = "static init: Error loading from cfg file: [" + PROP_FILE
- + "] ConfigurationException=" + ex;
- LOG.error( error );
- throw new CfgRuntimeException( GlobalErrIds.FT_CONFIG_BOOTSTRAP_FAILED, error, ex );
- }
- }
-
- /**
- * Private constructor
- *
- */
- private LocalConfig()
- {
- init();
- }
-
- /**
- * This method is called during configuration initialization. It determines if
- * the ldap connection coordinates have been overridden as system properties.
- */
- private void getExternalConfig()
- {
- String PREFIX = "getExternalConfig override name [{}] value [{}]";
- // Check to see if the ldap host has been overridden by a system property:
- String szValue = System.getProperty( EXT_LDAP_HOST );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_HOST, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_HOST, szValue );
- }
- // Check to see if the ldap port has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_PORT );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_PORT, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_PORT, szValue );
- }
-
- // Check to see if the admin pool uid has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_UID );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_UID, szValue );
- // never display ldap admin userid name to log:
- LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_UID );
- }
-
- // Check to see if the admin pool pw has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_PW );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_PW, szValue );
- // never display password of any type to log:
- LOG.info( "getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_PW );
- }
-
- // Check to see if the admin pool min connections has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MIN );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MIN, szValue );
- }
-
- // Check to see if the admin pool max connections has been overridden by a system property:
- szValue = System.getProperty( EXT_LDAP_ADMIN_POOL_MAX );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
- LOG.info( PREFIX, GlobalIds.LDAP_ADMIN_POOL_MAX, szValue );
- }
-
- // Check to see if ssl enabled parameter has been overridden by a system property:
- szValue = System.getProperty( EXT_ENABLE_LDAP_SSL );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.ENABLE_LDAP_SSL, szValue );
- LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL, szValue );
- }
-
- // Check to see if the ssl debug enabled parameter has been overridden by a system property:
- szValue = System.getProperty( EXT_ENABLE_LDAP_SSL_DEBUG );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
- LOG.info( PREFIX, GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue );
- }
-
- // Check to see if the trust store location has been overridden by a system property:
- szValue = System.getProperty( EXT_TRUST_STORE );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.TRUST_STORE, szValue );
- LOG.info( PREFIX, GlobalIds.TRUST_STORE, szValue );
- }
-
- // Check to see if the trust store password has been overridden by a system property:
- szValue = System.getProperty( EXT_TRUST_STORE_PW );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.TRUST_STORE_PW, szValue );
- // never display password value to log:
- LOG.info( "getExternalConfig override name [{}]", GlobalIds.TRUST_STORE_PW );
- }
-
- // Check to see if the trust store set parameter has been overridden by a system property:
- szValue = System.getProperty( EXT_SET_TRUST_STORE_PROP );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.SET_TRUST_STORE_PROP, szValue );
- LOG.info( PREFIX, GlobalIds.SET_TRUST_STORE_PROP, szValue );
- }
-
- // Check to see if the config realm name has been overridden by a system property:
- szValue = System.getProperty( EXT_CONFIG_REALM );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.CONFIG_REALM, szValue );
- LOG.info( PREFIX, GlobalIds.CONFIG_REALM, szValue );
- }
-
- // Check to see if the config realm name has been overridden by a system property:
- szValue = System.getProperty( EXT_CONFIG_ROOT_DN );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.CONFIG_ROOT_PARAM, szValue );
- LOG.info( PREFIX, GlobalIds.CONFIG_ROOT_PARAM, szValue );
- }
-
- // Check to see if the ldap server type has been overridden by a system property:
- szValue = System.getProperty( EXT_SERVER_TYPE );
- if( StringUtils.isNotEmpty( szValue ))
- {
- config.setProperty( GlobalIds.SERVER_TYPE, szValue );
- LOG.info( PREFIX, GlobalIds.SERVER_TYPE, szValue );
- }
- }
-
- public PropertiesConfiguration getConfig() {
- return config;
- }
-
- /**
- * Gets the prop attribute as String value from the apache commons cfg component.
- *
- * @param name contains the name of the property.
- * @return contains the value associated with the property or null if not not found.
- */
- public String getProperty( String name )
- {
- String value = null;
- if ( config != null )
- {
- value = ( String ) config.getProperty( name );
- LOG.debug( "getProperty name [{}] value [{}]", name, value );
- }
- else
- {
- LOG.error( "getProperty invalid config, can't read prop [{}]", name );
- }
- return value;
- }
-
-
- /**
- * Get the property value from the apache commons config but specify a default value if not found.
- *
- * @param name contains the name of the property.
- * @param defaultValue specified by client will be returned if property value is not found.
- * @return contains the value for the property as a String.
- */
- public String getProperty( String name, String defaultValue )
- {
- String value = null;
- if ( config != null )
- {
- value = ( String ) config.getProperty( name );
- }
- else
- {
- String warn = "getProperty invalid config, can't read prop [" + name + "]";
- LOG.warn( warn );
- }
- if ( value == null || value.length() == 0 )
- {
- value = defaultValue;
- }
- return value;
- }
-
- /**
- * Gets the int attribute of the Config class, or 0 if not found.
- *
- * @param key name of the property name.
- * @return The int value or 0 if not found.
- */
- public int getInt( String key )
- {
- int value = 0;
- if ( config != null )
- {
- value = config.getInt( key );
- }
- else
- {
- String warn = "getInt invalid config, can't read prop [" + key + "]";
- LOG.warn( warn );
- }
- return value;
- }
-
-
- /**
- * Gets the int attribute of the Config class or default value if not found.
- *
- * @param key name of the property name.
- * @param defaultValue to use if property not found.
- * @return The int value or default value if not found.
- */
- public int getInt( String key, int defaultValue )
- {
- int value = 0;
- if ( config != null )
- {
- value = config.getInt( key, defaultValue );
- }
- else
- {
- String warn = "getInt invalid config, can't read prop [" + key + "]";
- LOG.warn( warn );
- }
- return value;
- }
-
- /**
- * Gets the boolean attribute associated with the name or false if not found.
- *
- * @param key name of the property name.
- * @return The boolean value or false if not found.
- */
- public boolean getBoolean( String key )
- {
- boolean value = false;
- if ( config != null )
- {
- value = config.getBoolean( key );
- }
- else
- {
- String warn = "getBoolean - invalid config, can't read prop [" + key + "]";
- LOG.warn( warn );
- }
- return value;
- }
-
-
- /**
- * Gets the boolean attribute associated with the name or false if not found.
- *
- * @param key name of the property name.
- * @param defaultValue specified by client will be returned if property value is not found.
- * @return The boolean value or false if not found.
- */
- public boolean getBoolean( String key, boolean defaultValue )
- {
- boolean value = defaultValue;
- if ( config != null )
- {
- value = config.getBoolean( key, defaultValue );
- }
- else
- {
- String warn = "getBoolean - invalid config, can't read prop [" + key + "]";
- LOG.warn( warn );
- }
- return value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/e9c143f7/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
index be17eac..bf5d516 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/crypto/EncryptUtil.java
@@ -19,7 +19,7 @@
*/
package org.apache.directory.fortress.core.util.crypto;
-import org.apache.directory.fortress.core.util.LocalConfig;
+import org.apache.directory.fortress.core.util.Config;
import org.jasypt.util.text.BasicTextEncryptor;
/**
@@ -48,7 +48,7 @@ public final class EncryptUtil
private void init()
{
textEncryptor = new BasicTextEncryptor();
- textEncryptor.setPassword(LocalConfig.getInstance().getProperty(CRYPTO_PROP, "adlfarerovcja;39 d"));
+ textEncryptor.setPassword(Config.getInstance().getProperty(CRYPTO_PROP, "adlfarerovcja;39 d"));
}
/**
@@ -84,7 +84,7 @@ public final class EncryptUtil
public static boolean isEnabled()
{
boolean result = false;
- if(LocalConfig.getInstance().getProperty(CRYPTO_PROP)!= null && !LocalConfig.getInstance().getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
+ if(Config.getInstance().getProperty(CRYPTO_PROP)!= null && !Config.getInstance().getProperty(CRYPTO_PROP).equals("${crypto.prop}"))
{
result = true;
}
[05/15] directory-fortress-core git commit: refactored to not use
static initialization blocks
Posted by cp...@apache.org.
refactored to not use static initialization blocks
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/908a0734
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/908a0734
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/908a0734
Branch: refs/heads/master
Commit: 908a073484dd77f0d3bffa25a50ba99be1e63561
Parents: 2ebaebb
Author: clp207 <cl...@psu.edu>
Authored: Wed Apr 20 13:40:00 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Wed Apr 20 13:40:00 2016 -0400
----------------------------------------------------------------------
.../fortress/core/AccelMgrFactory.java | 5 +-
.../fortress/core/AccessMgrFactory.java | 9 +-
.../fortress/core/AdminMgrFactory.java | 10 +-
.../fortress/core/AuditMgrFactory.java | 12 ++-
.../fortress/core/ConfigMgrFactory.java | 11 +-
.../fortress/core/DelAccessMgrFactory.java | 12 ++-
.../fortress/core/DelAdminMgrFactory.java | 10 +-
.../fortress/core/DelReviewMgrFactory.java | 9 +-
.../directory/fortress/core/GlobalIds.java | 52 ++++++---
.../fortress/core/GroupMgrFactory.java | 8 +-
.../fortress/core/PwPolicyMgrFactory.java | 12 ++-
.../fortress/core/ReviewMgrFactory.java | 10 +-
.../fortress/core/ant/FortressAntTask.java | 36 +++----
.../fortress/core/impl/AccelMgrImpl.java | 3 +-
.../fortress/core/impl/AcceleratorDAO.java | 17 +--
.../fortress/core/impl/AccessMgrImpl.java | 34 +++---
.../fortress/core/impl/AdminMgrImpl.java | 30 +++---
.../fortress/core/impl/AdminRoleP.java | 15 ++-
.../directory/fortress/core/impl/AuditDAO.java | 35 +++---
.../directory/fortress/core/impl/AuditP.java | 3 +-
.../directory/fortress/core/impl/ConfigDAO.java | 17 +--
.../fortress/core/impl/DSDChecker.java | 16 +--
.../fortress/core/impl/DelAccessMgrImpl.java | 28 +++--
.../fortress/core/impl/DelAdminMgrImpl.java | 61 ++++++-----
.../fortress/core/impl/DelReviewMgrImpl.java | 17 ++-
.../directory/fortress/core/impl/GroupDAO.java | 56 +++++-----
.../fortress/core/impl/GroupMgrImpl.java | 6 +-
.../directory/fortress/core/impl/GroupP.java | 19 ++--
.../fortress/core/impl/OrgUnitDAO.java | 21 ++--
.../directory/fortress/core/impl/OrgUnitP.java | 23 ++--
.../core/impl/OrganizationalUnitDAO.java | 7 +-
.../directory/fortress/core/impl/PermDAO.java | 33 +++---
.../directory/fortress/core/impl/PermP.java | 6 +-
.../directory/fortress/core/impl/PolicyDAO.java | 7 +-
.../directory/fortress/core/impl/PolicyP.java | 17 +--
.../directory/fortress/core/impl/PsoUtil.java | 47 +++++---
.../fortress/core/impl/PwPolicyMgrImpl.java | 15 ++-
.../fortress/core/impl/ReviewMgrImpl.java | 21 ++--
.../directory/fortress/core/impl/RoleDAO.java | 15 +--
.../directory/fortress/core/impl/RoleP.java | 3 +-
.../directory/fortress/core/impl/RoleUtil.java | 55 ++++++----
.../directory/fortress/core/impl/SDUtil.java | 76 +++++++------
.../directory/fortress/core/impl/SdDAO.java | 11 +-
.../directory/fortress/core/impl/SdP.java | 3 +-
.../directory/fortress/core/impl/SuffixDAO.java | 9 +-
.../directory/fortress/core/impl/UserDAO.java | 71 ++++++------
.../directory/fortress/core/impl/UserP.java | 6 +-
.../directory/fortress/core/impl/UsoUtil.java | 45 +++++---
.../fortress/core/ldap/LdapDataProvider.java | 107 ++++++++++---------
.../fortress/core/model/ConstraintUtil.java | 26 ++---
.../directory/fortress/core/model/PropUtil.java | 6 +-
.../fortress/core/model/UserAdminRole.java | 24 ++---
.../directory/fortress/core/model/UserRole.java | 18 ++--
.../fortress/core/rest/AccessMgrRestImpl.java | 34 +++---
.../fortress/core/rest/AdminMgrRestImpl.java | 82 +++++++-------
.../fortress/core/rest/AuditMgrRestImpl.java | 20 ++--
.../fortress/core/rest/ConfigMgrRestImpl.java | 16 +--
.../core/rest/DelAccessMgrRestImpl.java | 38 +++----
.../fortress/core/rest/DelAdminMgrRestImpl.java | 56 +++++-----
.../core/rest/DelReviewMgrRestImpl.java | 12 +--
.../fortress/core/rest/PwPolicyMgrRestImpl.java | 20 ++--
.../directory/fortress/core/rest/RestUtils.java | 86 ++++++++++-----
.../fortress/core/rest/ReviewMgrRestImpl.java | 84 +++++++--------
.../directory/fortress/core/util/Config.java | 9 +-
.../directory/fortress/core/util/RegExUtil.java | 28 +++--
.../directory/fortress/core/util/VUtil.java | 36 +++++--
.../fortress/core/util/cache/CacheMgr.java | 44 ++++----
.../fortress/core/util/crypto/EncryptUtil.java | 29 +++--
.../fortress/core/AdminMgrConsole.java | 28 ++---
.../fortress/core/EncryptMgrConsole.java | 4 +-
.../core/example/ExampleAdminMgrFactory.java | 4 +-
.../fortress/core/example/ExampleDAO.java | 28 ++---
.../fortress/core/impl/FortressJUnitTest.java | 19 ++--
73 files changed, 1101 insertions(+), 801 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
index 898d0a7..fabea9f 100644
--- a/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
@@ -20,9 +20,9 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.impl.AccelMgrImpl;
import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -35,7 +35,6 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
public final class AccelMgrFactory
{
- private static String accelClassName = Config.getProperty(GlobalIds.ACCEL_IMPLEMENTATION);
private static final String CLS_NM = AccelMgrFactory.class.getName();
/**
@@ -60,6 +59,8 @@ public final class AccelMgrFactory
public static AccelMgr createInstance(String contextId)
throws SecurityException
{
+ String accelClassName = Config.getInstance().getProperty(GlobalIds.ACCEL_IMPLEMENTATION);
+
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
AccelMgr accelMgr;
if ( StringUtils.isEmpty( accelClassName ) )
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
index bceb210..54a924b 100755
--- a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
@@ -20,10 +20,10 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.impl.AccessMgrImpl;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.rest.AccessMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -38,7 +38,6 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
public final class AccessMgrFactory
{
- private static String accessClassName = Config.getProperty(GlobalIds.ACCESS_IMPLEMENTATION);
private static final String CLS_NM = AccessMgrFactory.class.getName();
/**
@@ -64,10 +63,12 @@ public final class AccessMgrFactory
{
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
+ String accessClassName = Config.getInstance().getProperty(GlobalIds.ACCESS_IMPLEMENTATION);
+
AccessMgr accessMgr;
if ( StringUtils.isEmpty( accessClassName ) )
{
- if(GlobalIds.IS_REST)
+ if(GlobalIds.getInstance().IS_REST)
{
accessMgr = new AccessMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
index d1b695c..d95c686 100755
--- a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
@@ -20,11 +20,11 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.impl.AdminMgrImpl;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.rest.AdminMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -39,7 +39,6 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
public final class AdminMgrFactory
{
- private static String adminClassName = Config.getProperty(GlobalIds.ADMIN_IMPLEMENTATION);
private static final String CLS_NM = AdminMgrFactory.class.getName();
/**
@@ -65,11 +64,14 @@ public final class AdminMgrFactory
throws SecurityException
{
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
+
+ String adminClassName = Config.getInstance().getProperty(GlobalIds.ADMIN_IMPLEMENTATION);
+
AdminMgr adminMgr;
if ( StringUtils.isEmpty( adminClassName ) )
{
- if(GlobalIds.IS_REST)
+ if(GlobalIds.getInstance().IS_REST)
{
adminMgr = new AdminMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
index d486ac9..168ba29 100755
--- a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
@@ -20,11 +20,11 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.impl.AuditMgrImpl;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.rest.AuditMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -37,8 +37,7 @@ import org.apache.directory.fortress.core.util.VUtil;
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public final class AuditMgrFactory
-{
- private static String auditClassName = Config.getProperty(GlobalIds.AUDIT_IMPLEMENTATION);
+{
private static final String CLS_NM = AuditMgrFactory.class.getName();
/**
@@ -64,11 +63,14 @@ public final class AuditMgrFactory
throws SecurityException
{
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
+
+ String auditClassName = Config.getInstance().getProperty(GlobalIds.AUDIT_IMPLEMENTATION);
+
AuditMgr auditMgr;
if ( StringUtils.isEmpty( auditClassName ) )
{
- if(GlobalIds.IS_REST)
+ if(GlobalIds.getInstance().IS_REST)
{
auditMgr = new AuditMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
index 8eb481d..6d85d3f 100755
--- a/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/ConfigMgrFactory.java
@@ -19,10 +19,10 @@
*/
package org.apache.directory.fortress.core;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.impl.ConfigMgrImpl;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.rest.ConfigMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
/**
* Creates an instance of the ConfigMgr object.
@@ -35,10 +35,8 @@ import org.apache.directory.fortress.core.rest.ConfigMgrRestImpl;
*/
public final class ConfigMgrFactory
{
- private static String configClassName = Config.getProperty( GlobalIds.CONFIG_IMPLEMENTATION );
private final static String ENABLE_REST = "enable.mgr.impl.rest";
- private static final boolean IS_REST = ((Config.getProperty(ENABLE_REST) != null) && (Config.getProperty(ENABLE_REST).equalsIgnoreCase("true")));
-
+
private ConfigMgrFactory()
{
@@ -53,6 +51,9 @@ public final class ConfigMgrFactory
public static ConfigMgr createInstance()
throws SecurityException
{
+ String configClassName = Config.getInstance().getProperty( GlobalIds.CONFIG_IMPLEMENTATION );
+ boolean IS_REST = ((Config.getInstance().getProperty(ENABLE_REST) != null) && (Config.getInstance().getProperty(ENABLE_REST).equalsIgnoreCase("true")));
+
if (configClassName == null || configClassName.compareTo("") == 0)
{
if(IS_REST)
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
index 2b5b555..738d400 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
@@ -20,11 +20,11 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.impl.DelAccessMgrImpl;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.rest.DelAccessMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -36,8 +36,7 @@ import org.apache.directory.fortress.core.util.VUtil;
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public final class DelAccessMgrFactory
-{
- private static String accessClassName = Config.getProperty(GlobalIds.DELEGATED_ACCESS_IMPLEMENTATION);
+{
private static final String CLS_NM = DelAccessMgrFactory.class.getName();
/**
@@ -64,11 +63,14 @@ public final class DelAccessMgrFactory
throws SecurityException
{
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
+
+ String accessClassName = Config.getInstance().getProperty(GlobalIds.DELEGATED_ACCESS_IMPLEMENTATION);
+
DelAccessMgr accessMgr;
if ( StringUtils.isEmpty( accessClassName ) )
{
- if(GlobalIds.IS_REST)
+ if(GlobalIds.getInstance().IS_REST)
{
accessMgr = new DelAccessMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
index 6a5f393..9ff0a7a 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
@@ -20,11 +20,11 @@
package org.apache.directory.fortress.core;
import org.apache.directory.api.util.Strings;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.impl.DelAdminMgrImpl;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.rest.DelAdminMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -38,7 +38,6 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
public final class DelAdminMgrFactory
{
- private static String dAdminClassName = Config.getProperty(GlobalIds.DELEGATED_ADMIN_IMPLEMENTATION);
private static final String CLS_NM = DelAdminMgrFactory.class.getName();
private static final String CREATE_INSTANCE_METHOD = CLS_NM + ".createInstance";
@@ -65,11 +64,14 @@ public final class DelAdminMgrFactory
throws SecurityException
{
VUtil.assertNotNull( contextId, GlobalErrIds.CONTEXT_NULL, CREATE_INSTANCE_METHOD );
+
+ String dAdminClassName = Config.getInstance().getProperty(GlobalIds.DELEGATED_ADMIN_IMPLEMENTATION);
+
DelAdminMgr delAdminMgr;
if ( Strings.isEmpty( dAdminClassName ) )
{
- if ( GlobalIds.IS_REST )
+ if ( GlobalIds.getInstance().IS_REST )
{
delAdminMgr = new DelAdminMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
index 70229f7..4264601 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
@@ -20,11 +20,11 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.impl.DelReviewMgrImpl;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.rest.DelReviewMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -37,7 +37,6 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
public final class DelReviewMgrFactory
{
- private static String dReviewClassName = Config.getProperty(GlobalIds.DELEGATED_REVIEW_IMPLEMENTATION);
private static final String CLS_NM = DelReviewMgrFactory.class.getName();
/**
@@ -63,11 +62,13 @@ public final class DelReviewMgrFactory
throws SecurityException
{
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
+ String dReviewClassName = Config.getInstance().getProperty(GlobalIds.DELEGATED_REVIEW_IMPLEMENTATION);
+
DelReviewMgr delReviewMgr;
if ( StringUtils.isEmpty( dReviewClassName ) )
{
- if(GlobalIds.IS_REST)
+ if(GlobalIds.getInstance().IS_REST)
{
delReviewMgr = new DelReviewMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
index 51bb710..0fe67a3 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
@@ -40,22 +40,51 @@ public final class GlobalIds
{
public static final String CONFIG_ROOT_PARAM = "config.root";
+ private static volatile GlobalIds INSTANCE = null;
+
+ public static GlobalIds getInstance() {
+ if(INSTANCE == null) {
+ synchronized (GlobalIds.class) {
+ if(INSTANCE == null){
+ INSTANCE = new GlobalIds();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
/**
* Private constructor
*
*/
private GlobalIds()
{
+ init();
+
+ IS_AUDIT_DISABLED = ( ( Config.getInstance().getProperty( DISABLE_AUDIT ) != null ) && ( Config
+ .getInstance().getProperty( DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
+
+ IS_REST = ( ( Config.getInstance().getProperty( ENABLE_REST ) != null ) && ( Config
+ .getInstance().getProperty( ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
+
+ IS_REALM = GlobalIds.REALM_TYPE.equalsIgnoreCase( Config
+ .getInstance().getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
+
+ IS_OPENLDAP = ( ( Config.getInstance().getProperty( SERVER_TYPE ) != null ) && ( Config
+ .getInstance().getProperty( SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
+
+ LDAP_FILTER_SIZE_FOUND = ( Config
+ .getInstance().getProperty( LDAP_FILTER_SIZE_PROP ) != null );
+
+ DELIMITER = Config.getInstance().getProperty( "attr.delimiter", "$" );
}
public static final String HOME = "HOME";
public static final String TENANT = "tenant";
private static final String DISABLE_AUDIT = "disable.audit";
- public static final boolean IS_AUDIT_DISABLED = ( ( Config.getProperty( DISABLE_AUDIT ) != null ) && ( Config
- .getProperty( DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
+ public boolean IS_AUDIT_DISABLED;
private static final String ENABLE_REST = "enable.mgr.impl.rest";
- public static final boolean IS_REST = ( ( Config.getProperty( ENABLE_REST ) != null ) && ( Config
- .getProperty( ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
+ public boolean IS_REST;
/**
* The following constants are used within the factory classes:
@@ -147,8 +176,7 @@ public final class GlobalIds
* the authentication module will not throw SecurityException on password resets. This is to enable the authentication
* event to succeed allowing the application to prompt user to change their password.
*/
- public static final boolean IS_REALM = GlobalIds.REALM_TYPE.equalsIgnoreCase( Config
- .getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
+ public boolean IS_REALM;
/**
* Parameter specifies the distinguished name (dn) of the LDAP suffix. The is the root or top-most node for a Directory Information Tree (DIT). The typical
@@ -234,8 +262,7 @@ public final class GlobalIds
*/
public static final String SERVER_TYPE = "ldap.server.type";
- public static final boolean IS_OPENLDAP = ( ( Config.getProperty( SERVER_TYPE ) != null ) && ( Config
- .getProperty( SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
+ public boolean IS_OPENLDAP;
/*
* *************************************************************************
@@ -439,8 +466,7 @@ public final class GlobalIds
/**
* Used during ldap filter processing.
*/
- public static final boolean LDAP_FILTER_SIZE_FOUND = ( Config
- .getProperty( LDAP_FILTER_SIZE_PROP ) != null );
+ public boolean LDAP_FILTER_SIZE_FOUND;
public static final String APACHE_LDAP_API = "apache";
public static final String AUTH_Z_FAILED = "authzfailed";
public static final String POP_NAME = "ftOpNm";
@@ -473,11 +499,11 @@ public final class GlobalIds
/**
* enable the ldap filter size variable to be used later during filter processing.
*/
- static
+ private void init()
{
try
{
- String lenProp = Config.getProperty( LDAP_FILTER_SIZE_PROP );
+ String lenProp = Config.getInstance().getProperty( LDAP_FILTER_SIZE_PROP );
if ( LDAP_FILTER_SIZE_FOUND )
{
ldapFilterSize = Integer.valueOf( lenProp );
@@ -510,7 +536,7 @@ public final class GlobalIds
* Fortress stores complex attribute types within a single attribute in ldap. Usually a delimiter of '$' is used for string tokenization.
* format: {@code part1$part2$part3....} Stored in fortress.properties as 'attr.delimiter=$'
*/
- public static final String DELIMITER = Config.getProperty( "attr.delimiter", "$" );
+ public String DELIMITER;
/**
* Maximum number of records for ldap client to wait on while processing results sets from ldap server.
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
index 770d506..7b3473c 100755
--- a/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
@@ -21,9 +21,9 @@ package org.apache.directory.fortress.core;
import org.apache.directory.api.util.Strings;
import org.apache.directory.fortress.core.impl.GroupMgrImpl;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.model.Session;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -35,8 +35,7 @@ import org.apache.directory.fortress.core.util.VUtil;
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public final class GroupMgrFactory
-{
- private static String groupClassName = Config.getProperty( GlobalIds.GROUP_IMPLEMENTATION );
+{
private static final String CLS_NM = GroupMgrFactory.class.getName();
private static final String CREATE_INSTANCE_METHOD = CLS_NM + ".createInstance";
@@ -70,6 +69,7 @@ public final class GroupMgrFactory
throws SecurityException
{
VUtil.assertNotNull( contextId, GlobalErrIds.CONTEXT_NULL, CREATE_INSTANCE_METHOD );
+ String groupClassName = Config.getInstance().getProperty( GlobalIds.GROUP_IMPLEMENTATION );
if ( Strings.isEmpty( groupClassName ) )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
index bacfe0b..92a24e6 100755
--- a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
@@ -20,11 +20,11 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.impl.PwPolicyMgrImpl;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.rest.PwPolicyMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -36,8 +36,7 @@ import org.apache.directory.fortress.core.util.VUtil;
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public final class PwPolicyMgrFactory
-{
- private static String policyClassName = Config.getProperty(GlobalIds.PSWD_POLICY_IMPLEMENTATION);
+{
private static final String CLS_NM = PwPolicyMgrFactory.class.getName();
/**
@@ -63,11 +62,14 @@ public final class PwPolicyMgrFactory
throws SecurityException
{
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
+
+ String policyClassName = Config.getInstance().getProperty(GlobalIds.PSWD_POLICY_IMPLEMENTATION);
+
PwPolicyMgr policyMgr;
if ( StringUtils.isEmpty( policyClassName ) )
{
- if(GlobalIds.IS_REST)
+ if(GlobalIds.getInstance().IS_REST)
{
policyMgr = new PwPolicyMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
index 1d65835..557b605 100755
--- a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
@@ -20,11 +20,11 @@
package org.apache.directory.fortress.core;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.impl.ReviewMgrImpl;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.rest.ReviewMgrRestImpl;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -37,7 +37,6 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
public final class ReviewMgrFactory
{
- private static String reviewClassName = Config.getProperty(GlobalIds.REVIEW_IMPLEMENTATION);
private static final String CLS_NM = ReviewMgrFactory.class.getName();
/**
@@ -63,11 +62,14 @@ public final class ReviewMgrFactory
throws SecurityException
{
VUtil.assertNotNull(contextId, GlobalErrIds.CONTEXT_NULL, CLS_NM + ".createInstance");
+
+ String reviewClassName = Config.getInstance().getProperty(GlobalIds.REVIEW_IMPLEMENTATION);
+
ReviewMgr reviewMgr;
if ( StringUtils.isEmpty( reviewClassName ) )
{
- if(GlobalIds.IS_REST)
+ if(GlobalIds.getInstance().IS_REST)
{
reviewMgr = new ReviewMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java b/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
index d6a7b53..1d1eff0 100755
--- a/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
+++ b/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
@@ -28,50 +28,48 @@ import java.util.StringTokenizer;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.model.PropUtil;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.input.InputHandler;
-import org.apache.tools.ant.input.InputRequest;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.model.Group;
-import org.apache.directory.fortress.core.GroupMgr;
-import org.apache.directory.fortress.core.GroupMgrFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.directory.fortress.core.AdminMgr;
import org.apache.directory.fortress.core.AdminMgrFactory;
import org.apache.directory.fortress.core.CfgException;
+import org.apache.directory.fortress.core.ConfigMgr;
+import org.apache.directory.fortress.core.ConfigMgrFactory;
import org.apache.directory.fortress.core.DelAdminMgr;
import org.apache.directory.fortress.core.DelAdminMgrFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.GroupMgr;
+import org.apache.directory.fortress.core.GroupMgrFactory;
import org.apache.directory.fortress.core.PwPolicyMgr;
import org.apache.directory.fortress.core.PwPolicyMgrFactory;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.ConfigMgr;
-import org.apache.directory.fortress.core.ConfigMgrFactory;
-import org.apache.directory.fortress.core.model.OrganizationalUnit;
import org.apache.directory.fortress.core.impl.OrganizationalUnitP;
-import org.apache.directory.fortress.core.model.Suffix;
import org.apache.directory.fortress.core.impl.SuffixP;
-
import org.apache.directory.fortress.core.model.AdminRole;
-import org.apache.directory.fortress.core.util.ClassUtil;
import org.apache.directory.fortress.core.model.Context;
+import org.apache.directory.fortress.core.model.Group;
import org.apache.directory.fortress.core.model.OrgUnit;
+import org.apache.directory.fortress.core.model.OrganizationalUnit;
import org.apache.directory.fortress.core.model.PermGrant;
import org.apache.directory.fortress.core.model.PermObj;
import org.apache.directory.fortress.core.model.Permission;
+import org.apache.directory.fortress.core.model.PropUtil;
import org.apache.directory.fortress.core.model.PwPolicy;
import org.apache.directory.fortress.core.model.Relationship;
import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.SDSet;
+import org.apache.directory.fortress.core.model.Suffix;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserAdminRole;
import org.apache.directory.fortress.core.model.UserRole;
+import org.apache.directory.fortress.core.util.ClassUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.Testable;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.input.InputHandler;
+import org.apache.tools.ant.input.InputRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -948,7 +946,7 @@ public class FortressAntTask extends Task implements InputHandler
LOG.info( "DEBUG MODE" );
try
{
- String testClassName = Config.getProperty( getTaskName() );
+ String testClassName = Config.getInstance().getProperty( getTaskName() );
if ( StringUtils.isEmpty( testClassName ) )
{
testClassName = "org.apache.directory.fortress.core.impl.FortressAntLoadTest";
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/AccelMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AccelMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/AccelMgrImpl.java
index 021aa15..8f69326 100644
--- a/src/main/java/org/apache/directory/fortress/core/impl/AccelMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AccelMgrImpl.java
@@ -77,7 +77,7 @@ import org.apache.directory.fortress.core.util.VUtil;
public class AccelMgrImpl extends Manageable implements AccelMgr, Serializable
{
private static final String CLS_NM = AccessMgrImpl.class.getName();
- private static final AcceleratorDAO aDao = new org.apache.directory.fortress.core.impl.AcceleratorDAO();
+ private AcceleratorDAO aDao;
/**
@@ -85,6 +85,7 @@ public class AccelMgrImpl extends Manageable implements AccelMgr, Serializable
*/
public AccelMgrImpl()
{
+ aDao = new org.apache.directory.fortress.core.impl.AcceleratorDAO();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/AcceleratorDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AcceleratorDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/AcceleratorDAO.java
index 2bf3f7f..af14943 100644
--- a/src/main/java/org/apache/directory/fortress/core/impl/AcceleratorDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AcceleratorDAO.java
@@ -20,15 +20,21 @@
package org.apache.directory.fortress.core.impl;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.Permission;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
+import org.apache.directory.ldap.client.api.LdapConnection;
import org.openldap.accelerator.api.addRole.RbacAddRoleRequest;
import org.openldap.accelerator.api.addRole.RbacAddRoleRequestImpl;
import org.openldap.accelerator.api.addRole.RbacAddRoleResponse;
@@ -49,12 +55,6 @@ import org.openldap.accelerator.api.sessionRoles.RbacSessionRolesRequestImpl;
import org.openldap.accelerator.api.sessionRoles.RbacSessionRolesResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
-import org.apache.directory.ldap.client.api.LdapConnection;
-
-import java.util.ArrayList;
-import java.util.List;
/**
@@ -70,7 +70,10 @@ final class AcceleratorDAO extends LdapDataProvider
{
private static final Logger LOG = LoggerFactory.getLogger( AcceleratorDAO.class.getName() );
-
+ public AcceleratorDAO(){
+ super();
+ }
+
/**
* Authenticate user and return sessionId inside {@link org.apache.directory.fortress.core.model.Session#sessionId}.
* This function follows the pattern from: {@link org.apache.directory.fortress.core.AccessMgr#createSession(org.apache.directory.fortress.core.model.User, boolean)}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java
index 465973b..c4ae52a 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AccessMgrImpl.java
@@ -90,8 +90,8 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
throws SecurityException
{
String methodName = "authenticate";
- VUtil.assertNotNullOrEmpty( userId, GlobalErrIds.USER_ID_NULL, getFullMethodName( CLS_NM, methodName ) );
- VUtil.assertNotNullOrEmpty( password, GlobalErrIds.USER_PW_NULL, getFullMethodName( CLS_NM, methodName ) );
+ VUtil.getInstance().assertNotNullOrEmpty( userId, GlobalErrIds.USER_ID_NULL, getFullMethodName( CLS_NM, methodName ) );
+ VUtil.getInstance().assertNotNullOrEmpty( password, GlobalErrIds.USER_PW_NULL, getFullMethodName( CLS_NM, methodName ) );
User inUser = new User( userId );
inUser.setContextId( contextId );
@@ -130,12 +130,12 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
assertContext( CLS_NM, methodName, perm, GlobalErrIds.PERM_NULL );
assertContext( CLS_NM, methodName, session, GlobalErrIds.USER_SESS_NULL );
- VUtil.assertNotNullOrEmpty( perm.getOpName(), GlobalErrIds.PERM_OPERATION_NULL,
+ VUtil.getInstance().assertNotNullOrEmpty( perm.getOpName(), GlobalErrIds.PERM_OPERATION_NULL,
getFullMethodName( CLS_NM, methodName ) );
- VUtil.assertNotNullOrEmpty( perm.getObjName(), GlobalErrIds.PERM_OBJECT_NULL,
+ VUtil.getInstance().assertNotNullOrEmpty( perm.getObjName(), GlobalErrIds.PERM_OBJECT_NULL,
getFullMethodName( CLS_NM, methodName ) );
- VUtil.validateConstraints( session, VUtil.ConstraintType.USER, false );
- VUtil.validateConstraints( session, VUtil.ConstraintType.ROLE, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false );
setEntitySession(CLS_NM, methodName, session);
return permP.checkPermission( session, perm );
}
@@ -150,8 +150,8 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
{
String methodName = "sessionPermissions";
assertContext( CLS_NM, methodName, session, GlobalErrIds.USER_SESS_NULL );
- VUtil.validateConstraints( session, VUtil.ConstraintType.USER, false );
- VUtil.validateConstraints( session, VUtil.ConstraintType.ROLE, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false );
setEntitySession(CLS_NM, methodName, session);
return permP.search( session );
}
@@ -166,8 +166,8 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
{
String methodName = "sessionRoles";
assertContext( CLS_NM, methodName, session, GlobalErrIds.USER_SESS_NULL );
- VUtil.validateConstraints( session, VUtil.ConstraintType.USER, false );
- VUtil.validateConstraints( session, VUtil.ConstraintType.ROLE, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false );
setEntitySession(CLS_NM, methodName, session);
return session.getRoles();
}
@@ -182,11 +182,11 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
{
String methodName = "authorizedRoles";
assertContext( CLS_NM, methodName, session, GlobalErrIds.USER_SESS_NULL );
- VUtil.assertNotNull( session.getUser(), GlobalErrIds.USER_NULL, CLS_NM + ".authorizedRoles" );
- VUtil.validateConstraints( session, VUtil.ConstraintType.USER, false );
- VUtil.validateConstraints( session, VUtil.ConstraintType.ROLE, false );
+ VUtil.getInstance().assertNotNull( session.getUser(), GlobalErrIds.USER_NULL, CLS_NM + ".authorizedRoles" );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false );
setEntitySession(CLS_NM, methodName, session);
- return RoleUtil.getInheritedRoles( session.getRoles(), this.contextId );
+ return RoleUtil.getInstance().getInheritedRoles( session.getRoles(), this.contextId );
}
@@ -225,13 +225,13 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
}
// validate Dynamic Separation of Duty Relations:
- SDUtil.validateDSD( session, role );
+ SDUtil.getInstance().validateDSD( session, role );
// set the role to the session:
session.setRole( uRoles.get( indx ) );
// Check role temporal constraints & DSD:
- VUtil.validateConstraints( session, VUtil.ConstraintType.ROLE, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false );
}
@@ -247,7 +247,7 @@ public class AccessMgrImpl extends Manageable implements AccessMgr, Serializable
assertContext( CLS_NM, methodName, role, GlobalErrIds.ROLE_NULL );
role.setUserId( session.getUserId() );
List<UserRole> roles = session.getRoles();
- VUtil
+ VUtil.getInstance()
.assertNotNull( roles, GlobalErrIds.URLE_DEACTIVE_FAILED, CLS_NM + getFullMethodName( CLS_NM, methodName ) );
int indx = roles.indexOf( role );
if ( indx != -1 )
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
index 2326d2b..e58242a 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
@@ -254,7 +254,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
String methodName = "deleteRole";
assertContext( CLS_NM, methodName, role, GlobalErrIds.ROLE_NULL );
setEntitySession( CLS_NM, methodName, role );
- int numChildren = RoleUtil.numChildren( role.getName(), role.getContextId() );
+ int numChildren = RoleUtil.getInstance().numChildren( role.getName(), role.getContextId() );
if ( numChildren > 0 )
{
String error = methodName + " role [" + role.getName() + "] must remove [" + numChildren +
@@ -275,12 +275,12 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
}
permP.remove( role );
// remove all parent relationships from the role graph:
- Set<String> parents = RoleUtil.getParents( role.getName(), this.contextId );
+ Set<String> parents = RoleUtil.getInstance().getParents( role.getName(), this.contextId );
if ( parents != null )
{
for ( String parent : parents )
{
- RoleUtil.updateHier( this.contextId, new Relationship( role.getName().toUpperCase(),
+ RoleUtil.getInstance().updateHier( this.contextId, new Relationship( role.getName().toUpperCase(),
parent.toUpperCase() ), Hier.Op.REM );
}
}
@@ -315,7 +315,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
user.setContextId( contextId );
setEntitySession( CLS_NM, methodName, uRole );
AdminUtil.canAssign( uRole.getAdminSession(), user, role, contextId );
- SDUtil.validateSSD( user, role );
+ SDUtil.getInstance().validateSSD( user, role );
// Get the default constraints from role:
role.setContextId( this.contextId );
@@ -520,10 +520,10 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
Role role = new Role( parentRole.getName() );
role.setContextId( this.contextId );
roleP.read( role );
- RoleUtil.validateRelationship( childRole, parentRole, false );
+ RoleUtil.getInstance().validateRelationship( childRole, parentRole, false );
childRole.setParent( parentRole.getName() );
roleP.add( childRole );
- RoleUtil.updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
+ RoleUtil.getInstance().updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
parentRole.getName().toUpperCase() ), Hier.Op.ADD );
}
@@ -543,7 +543,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
role.setContextId( this.contextId );
role = roleP.read( role );
role.setContextId( this.contextId );
- RoleUtil.validateRelationship( childRole, parentRole, false );
+ RoleUtil.getInstance().validateRelationship( childRole, parentRole, false );
roleP.add( parentRole );
// Use cRole2 to update ONLY the parents attribute on the child role and nothing else:
Role cRole2 = new Role( childRole.getName() );
@@ -552,7 +552,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
cRole2.setContextId( this.contextId );
setAdminData( CLS_NM, methodName, cRole2 );
roleP.update( cRole2 );
- RoleUtil.updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
+ RoleUtil.getInstance().updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
parentRole.getName().toUpperCase() ), Hier.Op.ADD );
}
@@ -575,8 +575,8 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
Role cRole = new Role( childRole.getName() );
cRole.setContextId( this.contextId );
cRole = roleP.read( cRole );
- RoleUtil.validateRelationship( childRole, parentRole, false );
- RoleUtil.updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
+ RoleUtil.getInstance().validateRelationship( childRole, parentRole, false );
+ RoleUtil.getInstance().updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
parentRole.getName().toUpperCase() ), Hier.Op.ADD );
// Use cRole2 to update ONLY the parents attribute on the child role and nothing else:
Role cRole2 = new Role( childRole.getName() );
@@ -598,8 +598,8 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
assertContext( CLS_NM, methodName, parentRole, GlobalErrIds.PARENT_ROLE_NULL );
setEntitySession( CLS_NM, methodName, parentRole );
assertContext( CLS_NM, methodName, childRole, GlobalErrIds.CHILD_ROLE_NULL );
- RoleUtil.validateRelationship( childRole, parentRole, true );
- RoleUtil.updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
+ RoleUtil.getInstance().validateRelationship( childRole, parentRole, true );
+ RoleUtil.getInstance().updateHier( this.contextId, new Relationship( childRole.getName().toUpperCase(),
parentRole.getName().toUpperCase() ), Hier.Op.REM );
// need to remove the parent from the child role:
Role cRole = new Role( childRole.getName() );
@@ -735,7 +735,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
{
for ( String roleName : ssdSet.getMembers() )
{
- SDUtil.clearSsdCacheEntry( roleName, contextId );
+ SDUtil.getInstance().clearSsdCacheEntry( roleName, contextId );
}
}
}
@@ -749,7 +749,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
*/
private void clearSSDCache( Role role )
{
- SDUtil.clearSsdCacheEntry( role.getName(), contextId );
+ SDUtil.getInstance().clearSsdCacheEntry( role.getName(), contextId );
}
@@ -892,6 +892,6 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr, Serializ
*/
private void clearDSDCache( SDSet dsdSet )
{
- SDUtil.clearDsdCacheEntry( dsdSet.getName(), contextId );
+ SDUtil.getInstance().clearDsdCacheEntry( dsdSet.getName(), contextId );
}
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java b/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
index 8a16107..e6e0008 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleP.java
@@ -25,21 +25,20 @@ import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.directory.fortress.core.FinderException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.RemoveException;
+import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.model.AdminRole;
import org.apache.directory.fortress.core.model.ConstraintValidator;
import org.apache.directory.fortress.core.model.Graphable;
import org.apache.directory.fortress.core.model.OrgUnit;
import org.apache.directory.fortress.core.model.UserAdminRole;
+import org.apache.directory.fortress.core.util.VUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.FinderException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.RemoveException;
-import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.util.VUtil;
-
/**
* Process module for the AdminRole entity. This class performs data validations and error mapping. It is typically called
@@ -326,7 +325,7 @@ public final class AdminRoleP
LOG.warn( error );
throw new SecurityException( GlobalErrIds.ARLE_INVLD_RANGE_INCLUSIVE, error );
}
- else if ( !RoleUtil.isParent( entity.getBeginRange(), entity.getEndRange(), entity.getContextId() )
+ else if ( !RoleUtil.getInstance().isParent( entity.getBeginRange(), entity.getEndRange(), entity.getContextId() )
&& !entity.getBeginRange().equalsIgnoreCase( entity.getEndRange() ) )
{
String error = "validate invalid range detected for role name [" + entity.getName()
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
index 58a952c..4ce23fe 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
@@ -31,19 +31,19 @@ import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.fortress.core.FinderException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.AuthZ;
import org.apache.directory.fortress.core.model.Bind;
import org.apache.directory.fortress.core.model.Mod;
+import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.model.UserAudit;
import org.apache.directory.fortress.core.util.AuditUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.time.TUtil;
import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.fortress.core.FinderException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
/**
@@ -181,6 +181,9 @@ final class AuditDAO extends LdapDataProvider
OBJECTCLASS, REQUAUTHZID, REQDN, REQEND, REQRESULT, REQSESSION, REQSTART, REQTYPE, REQMOD
};
+ public AuditDAO(){
+ super();
+ }
/**
* This method returns failed authentications where the userid is not present in the directory. This
@@ -225,8 +228,8 @@ final class AuditDAO extends LdapDataProvider
{
List<AuthZ> auditList = new ArrayList<>();
LdapConnection ld = null;
- String auditRoot = Config.getProperty( AUDIT_ROOT );
- String userRoot = Config.getProperty( GlobalIds.USER_ROOT );
+ String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
+ String userRoot = Config.getInstance().getProperty( GlobalIds.USER_ROOT );
try
{
@@ -246,13 +249,13 @@ final class AuditDAO extends LdapDataProvider
{
userId = audit.getUserId();
filter += REQDN + "=" + SchemaConstants.UID_AT + "=" + userId + "," + userRoot + ")(" +
- REQUAUTHZID + "=" + "cn=Manager," + Config.getProperty( GlobalIds.SUFFIX ) + ")";
+ REQUAUTHZID + "=" + "cn=Manager," + Config.getInstance().getProperty( GlobalIds.SUFFIX ) + ")";
}
else
{
// pull back all failed authN attempts for all users:
filter += REQATTR + "=" + SchemaConstants.UID_AT + ")(" +
- REQUAUTHZID + "=" + "cn=Manager," + Config.getProperty( GlobalIds.SUFFIX ) + ")";
+ REQUAUTHZID + "=" + "cn=Manager," + Config.getInstance().getProperty( GlobalIds.SUFFIX ) + ")";
}
if ( audit.isFailedOnly() )
@@ -314,7 +317,7 @@ final class AuditDAO extends LdapDataProvider
{
List<AuthZ> auditList = new ArrayList<>();
LdapConnection ld = null;
- String auditRoot = Config.getProperty( AUDIT_ROOT );
+ String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
String permRoot = getRootDn( audit.isAdmin(), audit.getContextId() );
String userRoot = getRootDn( audit.getContextId(), GlobalIds.USER_ROOT );
@@ -396,7 +399,7 @@ final class AuditDAO extends LdapDataProvider
{
List<AuthZ> auditList = new ArrayList<>();
LdapConnection ld = null;
- String auditRoot = Config.getProperty( AUDIT_ROOT );
+ String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
String userRoot = getRootDn( audit.getContextId(), GlobalIds.USER_ROOT );
try
@@ -411,7 +414,7 @@ final class AuditDAO extends LdapDataProvider
{
// have to limit the query to only authorization entries.
// TODO: determine why the cn=Manager user is showing up in this search:
- filter += REQUAUTHZID + "=*)(!(" + REQUAUTHZID + "=cn=Manager," + Config.getProperty( GlobalIds.SUFFIX )
+ filter += REQUAUTHZID + "=*)(!(" + REQUAUTHZID + "=cn=Manager," + Config.getInstance().getProperty( GlobalIds.SUFFIX )
+ "))";
// TODO: fix this so filter by only the Fortress AuthZ entries and not the others:
@@ -469,7 +472,7 @@ final class AuditDAO extends LdapDataProvider
{
List<Bind> auditList = new ArrayList<>();
LdapConnection ld = null;
- String auditRoot = Config.getProperty( AUDIT_ROOT );
+ String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
String userRoot = getRootDn( audit.getContextId(), GlobalIds.USER_ROOT );
try
@@ -552,7 +555,7 @@ final class AuditDAO extends LdapDataProvider
{
List<Mod> modList = new ArrayList<>();
LdapConnection ld = null;
- String auditRoot = Config.getProperty( AUDIT_ROOT );
+ String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
String userRoot = getRootDn( audit.getContextId(), GlobalIds.USER_ROOT );
@@ -607,7 +610,7 @@ final class AuditDAO extends LdapDataProvider
{
List<Mod> modList = new ArrayList<>();
LdapConnection ld = null;
- String auditRoot = Config.getProperty( AUDIT_ROOT );
+ String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
try
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/AuditP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AuditP.java b/src/main/java/org/apache/directory/fortress/core/impl/AuditP.java
index ca6960e..1d9b870 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AuditP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AuditP.java
@@ -50,7 +50,7 @@ import org.apache.directory.fortress.core.model.UserAudit;
*/
public final class AuditP
{
- private static final AuditDAO aDao = new AuditDAO();
+ private AuditDAO aDao;
/**
@@ -58,6 +58,7 @@ public final class AuditP
*/
AuditP()
{
+ aDao = new AuditDAO();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
index a3f7a9b..b2278b4 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
@@ -32,17 +32,17 @@ import org.apache.directory.api.ldap.model.exception.LdapEntryAlreadyExistsExcep
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.fortress.core.CreateException;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.model.PropUtil;
-import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.FinderException;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
+import org.apache.directory.fortress.core.model.PropUtil;
+import org.apache.directory.fortress.core.util.Config;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -84,7 +84,7 @@ final class ConfigDAO extends LdapDataProvider
{
private static final String CLS_NM = ConfigDAO.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static final String CONFIG_ROOT_DN = Config.getProperty( GlobalIds.CONFIG_ROOT_PARAM );
+ private String CONFIG_ROOT_DN;
private static final String CONFIG_OBJ_CLASS[] =
{
@@ -102,6 +102,9 @@ final class ConfigDAO extends LdapDataProvider
*/
ConfigDAO()
{
+ super();
+
+ CONFIG_ROOT_DN = Config.getInstance().getProperty( GlobalIds.CONFIG_ROOT_PARAM );
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/DSDChecker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/DSDChecker.java b/src/main/java/org/apache/directory/fortress/core/impl/DSDChecker.java
index ee00c3d..8a47857 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/DSDChecker.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/DSDChecker.java
@@ -24,18 +24,18 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.model.Constraint;
+import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.model.SDSet;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.UserRole;
import org.apache.directory.fortress.core.model.Warning;
import org.apache.directory.fortress.core.util.VUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
-import org.apache.directory.fortress.core.model.Constraint;
import org.apache.directory.fortress.core.util.time.Time;
import org.apache.directory.fortress.core.util.time.Validator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -89,13 +89,13 @@ public class DSDChecker
return rc;
}
// get the list of authorized roles for this user:
- Set<String> authorizedRoleSet = RoleUtil.getInheritedRoles( activeRoleList, session.getUser().getContextId() );
+ Set<String> authorizedRoleSet = RoleUtil.getInstance().getInheritedRoles( activeRoleList, session.getUser().getContextId() );
// only need to check DSD constraints if more than one role is being activated:
if ( authorizedRoleSet != null && authorizedRoleSet.size() > 1 )
{
// get all DSD sets that contain the candidate activated and authorized roles,
//If DSD cache is disabled, this will search the directory using authorizedRoleSet
- Set<SDSet> dsdSets = SDUtil.getDsdCache( authorizedRoleSet, session.getUser().getContextId() );
+ Set<SDSet> dsdSets = SDUtil.getInstance().getDsdCache( authorizedRoleSet, session.getUser().getContextId() );
if ( dsdSets != null && dsdSets.size() > 0 )
{
for ( SDSet dsd : dsdSets )
@@ -127,7 +127,7 @@ public class DSDChecker
}
else
{
- Set<String> parentSet = RoleUtil.getAscendants( activatedRole.getName(), session.getUser()
+ Set<String> parentSet = RoleUtil.getInstance().getAscendants( activatedRole.getName(), session.getUser()
.getContextId() );
// now check for every role inherited from this activated role:
for ( String parentRole : parentSet )
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/DelAccessMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/DelAccessMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/DelAccessMgrImpl.java
index 6f9484c..e874e7a 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/DelAccessMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/DelAccessMgrImpl.java
@@ -65,11 +65,17 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr, Serializable
{
- private static final String CLS_NM = DelAccessMgrImpl.class.getName();
- private static final UserP userP = new UserP();
- private static final PermP permP = new PermP();
- private static final String SUPER_ADMIN = Config.getProperty("superadmin.role", "fortress-core-super-admin");
+ private final String CLS_NM = DelAccessMgrImpl.class.getName();
+ private UserP userP;
+ private PermP permP;
+ private String SUPER_ADMIN;
+ public DelAccessMgrImpl() {
+ userP = new UserP();
+ permP = new PermP();
+ SUPER_ADMIN = Config.getInstance().getProperty("superadmin.role", "fortress-core-super-admin");
+ }
+
/**
* {@inheritDoc}
*/
@@ -172,7 +178,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr, Ser
String info = getFullMethodName(CLS_NM, methodName) + " Admin Role [" + role.getName() + "] User [" + session.getUserId() + "] adminRole not authorized for user.";
throw new SecurityException(GlobalErrIds.ARLE_ACTIVATE_FAILED, info);
}
- SDUtil.validateDSD( session, role );
+ SDUtil.getInstance().validateDSD( session, role );
// now activate the role to the session:
session.setRole(uRoles.get(indx));
@@ -239,8 +245,8 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr, Ser
{
String methodName = "sessionPermissions";
assertContext(CLS_NM, methodName, session, GlobalErrIds.USER_SESS_NULL);
- VUtil.validateConstraints( session, VUtil.ConstraintType.USER, false );
- VUtil.validateConstraints( session, VUtil.ConstraintType.ROLE, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, false );
setEntitySession(CLS_NM, methodName, session);
return permP.search( session, true );
}
@@ -278,7 +284,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr, Ser
{
// Add osU children to the set:
osUsFinal.add(osU);
- Set<String> children = UsoUtil.getDescendants( osU, this.contextId );
+ Set<String> children = UsoUtil.getInstance().getDescendants( osU, this.contextId );
osUsFinal.addAll(children);
}
// does the admin role have authority over the user object?
@@ -288,7 +294,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr, Ser
Set<String> range;
if(uaRole.getBeginRange() != null && uaRole.getEndRange() != null && !uaRole.getBeginRange().equalsIgnoreCase(uaRole.getEndRange()))
{
- range = RoleUtil.getAscendants( uaRole.getBeginRange(), uaRole.getEndRange(),
+ range = RoleUtil.getInstance().getAscendants( uaRole.getBeginRange(), uaRole.getEndRange(),
uaRole.isEndInclusive(), this.contextId );
if(uaRole.isBeginInclusive())
{
@@ -352,7 +358,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr, Ser
{
// Add osU children to the set:
osPsFinal.add(osP);
- Set<String> children = PsoUtil.getDescendants( osP, this.contextId );
+ Set<String> children = PsoUtil.getInstance().getDescendants( osP, this.contextId );
osPsFinal.addAll(children);
}
// does the admin role have authority over the perm object?
@@ -362,7 +368,7 @@ public class DelAccessMgrImpl extends AccessMgrImpl implements DelAccessMgr, Ser
Set<String> range;
if(uaRole.getBeginRange() != null && uaRole.getEndRange() != null && !uaRole.getBeginRange().equalsIgnoreCase(uaRole.getEndRange()))
{
- range = RoleUtil.getAscendants(uaRole.getBeginRange(), uaRole.getEndRange(), uaRole.isEndInclusive(), this.contextId);
+ range = RoleUtil.getInstance().getAscendants(uaRole.getBeginRange(), uaRole.getEndRange(), uaRole.isEndInclusive(), this.contextId);
if(uaRole.isBeginInclusive())
{
range.add(uaRole.getBeginRange());
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
index e7a3c79..ab8041a 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/DelAdminMgrImpl.java
@@ -63,11 +63,18 @@ import org.apache.directory.fortress.core.util.VUtil;
public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Serializable
{
private static final String CLS_NM = DelAdminMgrImpl.class.getName();
- private static final OrgUnitP ouP = new OrgUnitP();
- private static final AdminRoleP admRP = new AdminRoleP();
- private static final PermP permP = new PermP();
- private static final UserP userP = new UserP();
-
+ private OrgUnitP ouP;
+ private AdminRoleP admRP;
+ private PermP permP;
+ private UserP userP;
+
+ public DelAdminMgrImpl() {
+ ouP = new OrgUnitP();
+ admRP = new AdminRoleP();
+ permP = new PermP();
+ userP = new UserP();
+ }
+
/**
* {@inheritDoc}
*/
@@ -252,11 +259,11 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
int numChildren;
if (entity.getType() == OrgUnit.Type.USER)
{
- numChildren = UsoUtil.numChildren( entity.getName(), entity.getContextId() );
+ numChildren = UsoUtil.getInstance().numChildren( entity.getName(), entity.getContextId() );
}
else
{
- numChildren = PsoUtil.numChildren( entity.getName(), entity.getContextId() );
+ numChildren = PsoUtil.getInstance().numChildren( entity.getName(), entity.getContextId() );
}
if (numChildren > 0)
{
@@ -288,11 +295,11 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
Set<String> parents;
if (entity.getType() == OrgUnit.Type.USER)
{
- parents = UsoUtil.getParents(entity.getName(), this.contextId);
+ parents = UsoUtil.getInstance().getParents(entity.getName(), this.contextId);
}
else
{
- parents = PsoUtil.getParents(entity.getName(), this.contextId);
+ parents = PsoUtil.getInstance().getParents(entity.getName(), this.contextId);
}
if(parents != null)
{
@@ -300,11 +307,11 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
{
if (entity.getType() == OrgUnit.Type.USER)
{
- UsoUtil.updateHier(this.contextId, new Relationship(entity.getName().toUpperCase(), parent.toUpperCase()), Hier.Op.REM);
+ UsoUtil.getInstance().updateHier(this.contextId, new Relationship(entity.getName().toUpperCase(), parent.toUpperCase()), Hier.Op.REM);
}
else
{
- PsoUtil.updateHier(this.contextId, new Relationship(entity.getName().toUpperCase(), parent.toUpperCase()), Hier.Op.REM);
+ PsoUtil.getInstance().updateHier(this.contextId, new Relationship(entity.getName().toUpperCase(), parent.toUpperCase()), Hier.Op.REM);
}
}
}
@@ -330,21 +337,21 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
ouP.read(parent);
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.validateRelationship(child, parent, false);
+ UsoUtil.getInstance().validateRelationship(child, parent, false);
}
else
{
- PsoUtil.validateRelationship(child, parent, false);
+ PsoUtil.getInstance().validateRelationship(child, parent, false);
}
child.setParent(parent.getName());
ouP.add(child);
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
+ UsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
}
else
{
- PsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
+ PsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
}
}
@@ -365,11 +372,11 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
OrgUnit newChild = ouP.read(child);
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.validateRelationship(child, parent, false);
+ UsoUtil.getInstance().validateRelationship(child, parent, false);
}
else
{
- PsoUtil.validateRelationship(child, parent, false);
+ PsoUtil.getInstance().validateRelationship(child, parent, false);
}
ouP.add(parent);
newChild.setParent(parent.getName());
@@ -377,11 +384,11 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
ouP.update(newChild);
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
+ UsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
}
else
{
- PsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
+ PsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
}
}
@@ -399,11 +406,11 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
setEntitySession(CLS_NM, methodName, parent);
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.validateRelationship(child, parent, false);
+ UsoUtil.getInstance().validateRelationship(child, parent, false);
}
else
{
- PsoUtil.validateRelationship(child, parent, false);
+ PsoUtil.getInstance().validateRelationship(child, parent, false);
}
// validate that both orgs are present:
ouP.read(parent);
@@ -416,11 +423,11 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
// we're still good, now set the hierarchical relationship:
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
+ UsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
}
else
{
- PsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
+ PsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
}
}
@@ -438,19 +445,19 @@ public final class DelAdminMgrImpl extends Manageable implements DelAdminMgr, Se
setEntitySession(CLS_NM, methodName, parent);
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.validateRelationship(child, parent, true);
+ UsoUtil.getInstance().validateRelationship(child, parent, true);
}
else
{
- PsoUtil.validateRelationship(child, parent, true);
+ PsoUtil.getInstance().validateRelationship(child, parent, true);
}
if (parent.getType() == OrgUnit.Type.USER)
{
- UsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.REM);
+ UsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.REM);
}
else
{
- PsoUtil.updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.REM);
+ PsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.REM);
}
OrgUnit cOrg = ouP.read(child);
cOrg.setContextId(this.contextId);
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/DelReviewMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/DelReviewMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/DelReviewMgrImpl.java
index 77c3676..aa8bf72 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/DelReviewMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/DelReviewMgrImpl.java
@@ -55,11 +55,18 @@ import org.apache.directory.fortress.core.util.VUtil;
public class DelReviewMgrImpl extends Manageable implements DelReviewMgr, Serializable
{
private static final String CLS_NM = DelReviewMgrImpl.class.getName();
- private static final UserP userP = new UserP();
- private static final OrgUnitP ouP = new OrgUnitP();
- private static final AdminRoleP admRP = new AdminRoleP();
- private static final PermP permP = new PermP();
-
+ private UserP userP;
+ private OrgUnitP ouP;
+ private AdminRoleP admRP;
+ private PermP permP;
+
+ public DelReviewMgrImpl() {
+ userP = new UserP();
+ ouP = new OrgUnitP();
+ admRP = new AdminRoleP();
+ permP = new PermP();
+ }
+
/**
* {@inheritDoc}
*/
[14/15] directory-fortress-core git commit: Merge branch
'feature/modifyBootstrapSingleton'
Posted by cp...@apache.org.
Merge branch 'feature/modifyBootstrapSingleton'
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/69844347
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/69844347
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/69844347
Branch: refs/heads/master
Commit: 6984434705a55d28518ff20e1fb6031049b2c954
Parents: 7f7cd61 8fde6e7
Author: clp207 <cl...@psu.edu>
Authored: Thu May 5 09:37:45 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Thu May 5 09:37:45 2016 -0400
----------------------------------------------------------------------
.../fortress/core/AccelMgrFactory.java | 12 +-
.../fortress/core/AccessMgrFactory.java | 16 +-
.../fortress/core/AdminMgrFactory.java | 17 +-
.../fortress/core/AuditMgrFactory.java | 19 +-
.../fortress/core/ConfigMgrFactory.java | 19 +-
.../fortress/core/DelAccessMgrFactory.java | 19 +-
.../fortress/core/DelAdminMgrFactory.java | 17 +-
.../fortress/core/DelReviewMgrFactory.java | 16 +-
.../directory/fortress/core/GlobalIds.java | 59 +--
.../fortress/core/GroupMgrFactory.java | 15 +-
.../fortress/core/PwPolicyMgrFactory.java | 19 +-
.../fortress/core/ReviewMgrFactory.java | 17 +-
.../fortress/core/ant/FortressAntTask.java | 36 +-
.../fortress/core/impl/AccelMgrImpl.java | 3 +-
.../fortress/core/impl/AcceleratorDAO.java | 17 +-
.../fortress/core/impl/AccessMgrImpl.java | 34 +-
.../fortress/core/impl/AdminMgrImpl.java | 30 +-
.../fortress/core/impl/AdminRoleP.java | 21 +-
.../directory/fortress/core/impl/AuditDAO.java | 35 +-
.../directory/fortress/core/impl/AuditP.java | 3 +-
.../directory/fortress/core/impl/ConfigDAO.java | 21 +-
.../fortress/core/impl/ConfigMgrImpl.java | 6 +-
.../fortress/core/impl/DSDChecker.java | 16 +-
.../fortress/core/impl/DelAccessMgrImpl.java | 28 +-
.../fortress/core/impl/DelAdminMgrImpl.java | 61 +--
.../fortress/core/impl/DelReviewMgrImpl.java | 17 +-
.../directory/fortress/core/impl/GroupDAO.java | 56 +--
.../fortress/core/impl/GroupMgrImpl.java | 6 +-
.../directory/fortress/core/impl/GroupP.java | 19 +-
.../fortress/core/impl/OrgUnitDAO.java | 21 +-
.../directory/fortress/core/impl/OrgUnitP.java | 23 +-
.../core/impl/OrganizationalUnitDAO.java | 7 +-
.../directory/fortress/core/impl/PermDAO.java | 34 +-
.../directory/fortress/core/impl/PermP.java | 6 +-
.../directory/fortress/core/impl/PolicyDAO.java | 7 +-
.../directory/fortress/core/impl/PolicyP.java | 17 +-
.../directory/fortress/core/impl/PsoUtil.java | 47 +-
.../fortress/core/impl/PwPolicyMgrImpl.java | 15 +-
.../fortress/core/impl/ReviewMgrImpl.java | 21 +-
.../directory/fortress/core/impl/RoleDAO.java | 15 +-
.../directory/fortress/core/impl/RoleP.java | 3 +-
.../directory/fortress/core/impl/RoleUtil.java | 55 ++-
.../directory/fortress/core/impl/SDUtil.java | 76 ++--
.../directory/fortress/core/impl/SdDAO.java | 11 +-
.../directory/fortress/core/impl/SdP.java | 3 +-
.../directory/fortress/core/impl/SuffixDAO.java | 9 +-
.../directory/fortress/core/impl/UserDAO.java | 49 ++-
.../directory/fortress/core/impl/UserP.java | 18 +-
.../directory/fortress/core/impl/UsoUtil.java | 45 +-
.../core/ldap/LdapConnectionProvider.java | 363 ++++++++++++++++
.../fortress/core/ldap/LdapDataProvider.java | 353 ++-------------
.../directory/fortress/core/ldap/LdapUtil.java | 57 +++
.../fortress/core/model/ConstraintUtil.java | 29 +-
.../directory/fortress/core/model/PropUtil.java | 7 +-
.../fortress/core/model/UserAdminRole.java | 26 +-
.../directory/fortress/core/model/UserRole.java | 21 +-
.../fortress/core/rest/AccessMgrRestImpl.java | 34 +-
.../fortress/core/rest/AdminMgrRestImpl.java | 82 ++--
.../fortress/core/rest/AuditMgrRestImpl.java | 20 +-
.../fortress/core/rest/ConfigMgrRestImpl.java | 16 +-
.../core/rest/DelAccessMgrRestImpl.java | 38 +-
.../fortress/core/rest/DelAdminMgrRestImpl.java | 56 +--
.../core/rest/DelReviewMgrRestImpl.java | 12 +-
.../fortress/core/rest/PwPolicyMgrRestImpl.java | 20 +-
.../directory/fortress/core/rest/RestUtils.java | 92 ++--
.../fortress/core/rest/ReviewMgrRestImpl.java | 84 ++--
.../directory/fortress/core/util/Config.java | 428 ++++++++++++-------
.../directory/fortress/core/util/RegExUtil.java | 28 +-
.../directory/fortress/core/util/VUtil.java | 36 +-
.../fortress/core/util/cache/CacheMgr.java | 56 ++-
.../fortress/core/util/crypto/EncryptUtil.java | 29 +-
.../fortress/core/AdminMgrConsole.java | 28 +-
.../fortress/core/EncryptMgrConsole.java | 4 +-
.../core/example/ExampleAdminMgrFactory.java | 4 +-
.../fortress/core/example/ExampleDAO.java | 28 +-
.../fortress/core/impl/FortressJUnitTest.java | 21 +-
76 files changed, 1836 insertions(+), 1272 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/69844347/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/69844347/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
----------------------------------------------------------------------
[07/15] directory-fortress-core git commit: working on getting junit
tests running after refactor
Posted by cp...@apache.org.
working on getting junit tests running after refactor
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/ae713f3b
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/ae713f3b
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/ae713f3b
Branch: refs/heads/master
Commit: ae713f3b0a73ae47144fbd26c2913eeb503d3ecd
Parents: d0924b2
Author: clp207 <cl...@psu.edu>
Authored: Tue Apr 26 14:52:01 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Tue Apr 26 14:52:01 2016 -0400
----------------------------------------------------------------------
.../core/ldap/LdapConnectionProvider.java | 363 +++++++++++++++++++
.../fortress/core/ldap/LdapDataProvider.java | 278 +-------------
.../directory/fortress/core/ldap/LdapUtil.java | 60 ---
.../directory/fortress/core/util/Config.java | 44 ++-
.../fortress/core/util/cache/CacheMgr.java | 10 +-
5 files changed, 426 insertions(+), 329 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/ae713f3b/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java
new file mode 100644
index 0000000..dd56e93
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapConnectionProvider.java
@@ -0,0 +1,363 @@
+package org.apache.directory.fortress.core.ldap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.pool.PoolableObjectFactory;
+import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.directory.api.ldap.codec.api.LdapApiService;
+import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
+import org.apache.directory.api.ldap.codec.standalone.StandaloneLdapApiService;
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.fortress.core.CfgRuntimeException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.util.LocalConfig;
+import org.apache.directory.fortress.core.util.crypto.EncryptUtil;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.LdapConnectionConfig;
+import org.apache.directory.ldap.client.api.LdapConnectionPool;
+import org.apache.directory.ldap.client.api.ValidatingPoolableLdapConnectionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LdapConnectionProvider {
+
+ private static final String CLS_NM = LdapConnectionProvider.class.getName();
+ private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+
+ private static final String LDAP_LOG_POOL_UID = "log.admin.user";
+ private static final String LDAP_LOG_POOL_PW = "log.admin.pw";
+ private static final String LDAP_LOG_POOL_MIN = "min.log.conn";
+ private static final String LDAP_LOG_POOL_MAX = "max.log.conn";
+
+ private static final String ENABLE_LDAP_STARTTLS = "enable.ldap.starttls";
+
+ private boolean IS_SSL;
+ private boolean IS_SET_TRUST_STORE_PROP;
+ private boolean IS_SSL_DEBUG;
+
+ /**
+ * The Admin connection pool
+ */
+ private static LdapConnectionPool adminPool;
+
+ /**
+ * The Log connection pool
+ */
+ private static LdapConnectionPool logPool;
+
+ /**
+ * The User connection pool
+ */
+ private static LdapConnectionPool userPool;
+
+ private static volatile LdapConnectionProvider INSTANCE = null;
+
+ public static LdapConnectionProvider getInstance() {
+ if(INSTANCE == null) {
+ synchronized (LdapConnectionProvider.class) {
+ if(INSTANCE == null){
+ INSTANCE = new LdapConnectionProvider();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ public LdapConnectionProvider(){
+ init();
+ }
+
+ private void init()
+ {
+ IS_SSL = (
+ LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
+ LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
+ LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) != null &&
+ LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) != null );
+
+ IS_SET_TRUST_STORE_PROP = (
+ IS_SSL &&
+ LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
+ LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
+
+ IS_SSL_DEBUG = ( ( LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( LocalConfig
+ .getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ).equalsIgnoreCase( "true" ) ) );
+
+
+ String host = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_HOST, "localhost" );
+ int port = LocalConfig.getInstance().getInt( GlobalIds.LDAP_PORT, 389 );
+ int min = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
+ int max = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
+ int logmin = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MIN, 1 );
+ int logmax = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MAX, 10 );
+ LOG.info( "LDAP POOL: host=[{}], port=[{}], min=[{}], max=[{}]", host, port, min, max );
+
+ if ( IS_SET_TRUST_STORE_PROP )
+ {
+ LOG.info( "Set JSSE truststore properties in Apache LDAP client:" );
+ LOG.info( "javax.net.ssl.trustStore: {}", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
+ LOG.info( "javax.net.debug: {}", IS_SSL_DEBUG );
+ System.setProperty( "javax.net.ssl.trustStore", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
+ System.setProperty( "javax.net.ssl.trustStorePassword", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) );
+ System.setProperty( "javax.net.debug", Boolean.valueOf( IS_SSL_DEBUG ).toString() );
+ }
+
+ LdapConnectionConfig config = new LdapConnectionConfig();
+ config.setLdapHost( host );
+ config.setLdapPort( port );
+ config.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+
+ config.setUseSsl( IS_SSL );
+ //config.setTrustManagers( new NoVerificationTrustManager() );
+
+ if(LocalConfig.getInstance().getBoolean(ENABLE_LDAP_STARTTLS, false)){
+ config.setUseTls(true);
+ }
+
+ if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ {
+ // validate certificates but allow self-signed certs if within this truststore:
+ config.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ), LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW )
+ .toCharArray(), null,
+ true ) );
+ }
+
+ String adminPw;
+ if ( EncryptUtil.isEnabled() )
+ {
+ adminPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
+ }
+ else
+ {
+ adminPw = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
+ }
+
+ config.setCredentials( adminPw );
+ try
+ {
+ List<String> listExOps = new ArrayList<>();
+ listExOps.add( "org.openldap.accelerator.impl.createSession.RbacCreateSessionFactory" );
+ listExOps.add( "org.openldap.accelerator.impl.checkAccess.RbacCheckAccessFactory" );
+ listExOps.add( "org.openldap.accelerator.impl.addRole.RbacAddRoleFactory" );
+ listExOps.add( "org.openldap.accelerator.impl.dropRole.RbacDropRoleFactory" );
+ listExOps.add( "org.openldap.accelerator.impl.deleteSession.RbacDeleteSessionFactory" );
+ listExOps.add( "org.openldap.accelerator.impl.sessionRoles.RbacSessionRolesFactory" );
+ LdapApiService ldapApiService = new StandaloneLdapApiService( new ArrayList<String>(), listExOps );
+
+ if ( !LdapApiServiceFactory.isInitialized() )
+ {
+ LdapApiServiceFactory.initialize( ldapApiService );
+ }
+ config.setLdapApiService( ldapApiService );
+ }
+ catch ( Exception ex )
+ {
+ String error = "Exception caught initializing Admin Pool: " + ex;
+ throw new CfgRuntimeException( GlobalErrIds.FT_APACHE_LDAP_POOL_INIT_FAILED, error, ex );
+ }
+
+ PoolableObjectFactory<LdapConnection> poolFactory = new ValidatingPoolableLdapConnectionFactory( config );
+
+ // Create the Admin pool
+ adminPool = new LdapConnectionPool( poolFactory );
+ adminPool.setTestOnBorrow( true );
+ adminPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
+ adminPool.setMaxActive( max );
+ adminPool.setMinIdle( min );
+ adminPool.setMaxIdle( -1 );
+ //adminPool.setMaxWait( 0 );
+
+ // Create the User pool
+ userPool = new LdapConnectionPool( poolFactory );
+ userPool.setTestOnBorrow( true );
+ userPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
+ userPool.setMaxActive( max );
+ userPool.setMinIdle( min );
+ userPool.setMaxIdle( -1 );
+
+ // This pool of access log connections is used by {@link org.apache.directory.fortress.AuditMgr}.
+ // To enable, set {@code log.admin.user} && {@code log.admin.pw} inside fortress.properties file:
+ if ( StringUtils.isNotEmpty( LDAP_LOG_POOL_UID ) && StringUtils.isNotEmpty( LDAP_LOG_POOL_PW ) )
+ {
+ // Initializing the log pool in static block requires static props set within fortress.properties.
+ // To make this dynamic requires moving this code outside of static block AND storing the connection metadata inside fortress config node (in ldap).
+ LdapConnectionConfig logConfig = new LdapConnectionConfig();
+ logConfig.setLdapHost( host );
+ logConfig.setLdapPort( port );
+ logConfig.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
+
+ logConfig.setUseSsl( IS_SSL );
+
+ if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
+ && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
+ {
+ // validate certificates but allow self-signed certs if within this truststore:
+ logConfig.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ),
+ LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
+ null, true ) );
+ }
+
+ logConfig.setName( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_UID, "" ) );
+ String logPw;
+ if ( EncryptUtil.isEnabled() )
+ {
+ logPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW ) );
+ }
+ else
+ {
+ logPw = LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW );
+ }
+ logConfig.setCredentials( logPw );
+ poolFactory = new ValidatingPoolableLdapConnectionFactory( logConfig );
+ logPool = new LdapConnectionPool( poolFactory );
+ logPool.setTestOnBorrow( true );
+ logPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
+ logPool.setMaxActive( logmax );
+ logPool.setMinIdle( logmin );
+ }
+ }
+
+
+ /**
+ * Calls the PoolMgr to close the Admin LDAP connection.
+ *
+ * @param connection handle to ldap connection object.
+ */
+ public void closeAdminConnection( LdapConnection connection )
+ {
+ try
+ {
+ adminPool.releaseConnection( connection );
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+ }
+
+
+ /**
+ * Calls the PoolMgr to close the Log LDAP connection.
+ *
+ * @param connection handle to ldap connection object.
+ */
+ public void closeLogConnection( LdapConnection connection )
+ {
+ try
+ {
+ logPool.releaseConnection( connection );
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+ }
+
+
+ /**
+ * Calls the PoolMgr to close the User LDAP connection.
+ *
+ * @param connection handle to ldap connection object.
+ */
+ public void closeUserConnection( LdapConnection connection )
+ {
+ try
+ {
+ userPool.releaseConnection( connection );
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+ }
+
+
+ /**
+ * Calls the PoolMgr to get an Admin connection to the LDAP server.
+ *
+ * @return ldap connection.
+ * @throws LdapException If we had an issue getting an LDAP connection
+ */
+ public LdapConnection getAdminConnection() throws LdapException
+ {
+ try
+ {
+ return adminPool.getConnection();
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e.getMessage(), e );
+ }
+ }
+
+
+ /**
+ * Calls the PoolMgr to get an Log connection to the LDAP server.
+ *
+ * @return ldap connection.
+ * @throws LdapException If we had an issue getting an LDAP connection
+ */
+ public LdapConnection getLogConnection() throws LdapException
+ {
+ try
+ {
+ return logPool.getConnection();
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e.getMessage(), e );
+ }
+ }
+
+
+ /**
+ * Calls the PoolMgr to get an User connection to the LDAP server.
+ *
+ * @return ldap connection.
+ * @throws LdapException If we had an issue getting an LDAP connection
+ */
+ public LdapConnection getUserConnection() throws LdapException
+ {
+ try
+ {
+ return userPool.getConnection();
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e.getMessage(), e );
+ }
+ }
+
+ /**
+ * Closes all the ldap connection pools.
+ */
+ public static void closeAllConnectionPools(){
+ try{
+ LOG.info("Closing admin pool");
+ adminPool.close();
+ }
+ catch(Exception e){
+ LOG.warn("Error closing admin pool: " + e.getMessage());
+ }
+
+ try{
+ LOG.info("Closing user pool");
+ userPool.close();
+ }
+ catch(Exception e){
+ LOG.warn("Error closing user pool: " + e.getMessage());
+ }
+
+ try{
+ LOG.info("Closing log pool");
+ logPool.close();
+ }
+ catch(Exception e){
+ LOG.warn("Error closing log pool: " + e.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/ae713f3b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
index 6c6979d..aa14e36 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
@@ -30,11 +30,6 @@ import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.pool.PoolableObjectFactory;
-import org.apache.commons.pool.impl.GenericObjectPool;
-import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
-import org.apache.directory.api.ldap.codec.standalone.StandaloneLdapApiService;
import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyImpl;
import org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator;
@@ -67,8 +62,6 @@ import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz;
import org.apache.directory.api.ldap.model.message.controls.ProxiedAuthzImpl;
import org.apache.directory.api.ldap.model.name.Dn;
-import org.apache.directory.fortress.core.CfgRuntimeException;
-import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.model.Constraint;
import org.apache.directory.fortress.core.model.ConstraintUtil;
@@ -76,12 +69,7 @@ import org.apache.directory.fortress.core.model.FortEntity;
import org.apache.directory.fortress.core.model.Hier;
import org.apache.directory.fortress.core.model.Relationship;
import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.util.LocalConfig;
-import org.apache.directory.fortress.core.util.crypto.EncryptUtil;
import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.ldap.client.api.LdapConnectionConfig;
-import org.apache.directory.ldap.client.api.LdapConnectionPool;
-import org.apache.directory.ldap.client.api.ValidatingPoolableLdapConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,191 +93,12 @@ public abstract class LdapDataProvider
private static final int MAX_DEPTH = 100;
private static final LdapCounters COUNTERS = new LdapCounters();
- // Used for slapd access log {@link org.apache.directory.fortress.core.rbacAuditDAO}
- private static final String LDAP_LOG_POOL_UID = "log.admin.user";
- private static final String LDAP_LOG_POOL_PW = "log.admin.pw";
- private static final String LDAP_LOG_POOL_MIN = "min.log.conn";
- private static final String LDAP_LOG_POOL_MAX = "max.log.conn";
-
- private static final String ENABLE_LDAP_STARTTLS = "enable.ldap.starttls";
-
- private boolean IS_SSL;
- private boolean IS_SET_TRUST_STORE_PROP;
- private boolean IS_SSL_DEBUG;
-
- /**
- * The Admin connection pool
- */
- private static LdapConnectionPool adminPool;
-
- /**
- * The Log connection pool
- */
- private static LdapConnectionPool logPool;
-
- /**
- * The User connection pool
- */
- private static LdapConnectionPool userPool;
-
private static final PasswordPolicy PP_REQ_CTRL = new PasswordPolicyImpl();
-
- public LdapDataProvider(){
- init();
- }
- private void init()
- {
- IS_SSL = (
- LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ) != null &&
- LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL ).equalsIgnoreCase( "true" ) &&
- LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) != null &&
- LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) != null );
-
- IS_SET_TRUST_STORE_PROP = (
- IS_SSL &&
- LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ) != null &&
- LocalConfig.getInstance().getProperty( GlobalIds.SET_TRUST_STORE_PROP ).equalsIgnoreCase( "true" ) );
-
- IS_SSL_DEBUG = ( ( LocalConfig.getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ) != null ) && ( LocalConfig
- .getInstance().getProperty( GlobalIds.ENABLE_LDAP_SSL_DEBUG ).equalsIgnoreCase( "true" ) ) );
-
-
- String host = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_HOST, "localhost" );
- int port = LocalConfig.getInstance().getInt( GlobalIds.LDAP_PORT, 389 );
- int min = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
- int max = LocalConfig.getInstance().getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
- int logmin = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MIN, 1 );
- int logmax = LocalConfig.getInstance().getInt( LDAP_LOG_POOL_MAX, 10 );
- LOG.info( "LDAP POOL: host=[{}], port=[{}], min=[{}], max=[{}]", host, port, min, max );
-
- if ( IS_SET_TRUST_STORE_PROP )
- {
- LOG.info( "Set JSSE truststore properties in Apache LDAP client:" );
- LOG.info( "javax.net.ssl.trustStore: {}", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
- LOG.info( "javax.net.debug: {}", IS_SSL_DEBUG );
- System.setProperty( "javax.net.ssl.trustStore", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) );
- System.setProperty( "javax.net.ssl.trustStorePassword", LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) );
- System.setProperty( "javax.net.debug", Boolean.valueOf( IS_SSL_DEBUG ).toString() );
- }
-
- LdapConnectionConfig config = new LdapConnectionConfig();
- config.setLdapHost( host );
- config.setLdapPort( port );
- config.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
-
- config.setUseSsl( IS_SSL );
- //config.setTrustManagers( new NoVerificationTrustManager() );
-
- if(LocalConfig.getInstance().getBoolean(ENABLE_LDAP_STARTTLS, false)){
- config.setUseTls(true);
- }
-
- if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
- {
- // validate certificates but allow self-signed certs if within this truststore:
- config.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ), LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW )
- .toCharArray(), null,
- true ) );
- }
-
- String adminPw;
- if ( EncryptUtil.isEnabled() )
- {
- adminPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW ) );
- }
- else
- {
- adminPw = LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_PW );
- }
-
- config.setCredentials( adminPw );
- try
- {
- List<String> listExOps = new ArrayList<>();
- listExOps.add( "org.openldap.accelerator.impl.createSession.RbacCreateSessionFactory" );
- listExOps.add( "org.openldap.accelerator.impl.checkAccess.RbacCheckAccessFactory" );
- listExOps.add( "org.openldap.accelerator.impl.addRole.RbacAddRoleFactory" );
- listExOps.add( "org.openldap.accelerator.impl.dropRole.RbacDropRoleFactory" );
- listExOps.add( "org.openldap.accelerator.impl.deleteSession.RbacDeleteSessionFactory" );
- listExOps.add( "org.openldap.accelerator.impl.sessionRoles.RbacSessionRolesFactory" );
- LdapApiService ldapApiService = new StandaloneLdapApiService( new ArrayList<String>(), listExOps );
-
- if ( !LdapApiServiceFactory.isInitialized() )
- {
- LdapApiServiceFactory.initialize( ldapApiService );
- }
- config.setLdapApiService( ldapApiService );
- }
- catch ( Exception ex )
- {
- String error = "Exception caught initializing Admin Pool: " + ex;
- throw new CfgRuntimeException( GlobalErrIds.FT_APACHE_LDAP_POOL_INIT_FAILED, error, ex );
- }
-
- PoolableObjectFactory<LdapConnection> poolFactory = new ValidatingPoolableLdapConnectionFactory( config );
-
- // Create the Admin pool
- adminPool = new LdapConnectionPool( poolFactory );
- adminPool.setTestOnBorrow( true );
- adminPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
- adminPool.setMaxActive( max );
- adminPool.setMinIdle( min );
- adminPool.setMaxIdle( -1 );
- //adminPool.setMaxWait( 0 );
-
- // Create the User pool
- userPool = new LdapConnectionPool( poolFactory );
- userPool.setTestOnBorrow( true );
- userPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
- userPool.setMaxActive( max );
- userPool.setMinIdle( min );
- userPool.setMaxIdle( -1 );
-
- // This pool of access log connections is used by {@link org.apache.directory.fortress.AuditMgr}.
- // To enable, set {@code log.admin.user} && {@code log.admin.pw} inside fortress.properties file:
- if ( StringUtils.isNotEmpty( LDAP_LOG_POOL_UID ) && StringUtils.isNotEmpty( LDAP_LOG_POOL_PW ) )
- {
- // Initializing the log pool in static block requires static props set within fortress.properties.
- // To make this dynamic requires moving this code outside of static block AND storing the connection metadata inside fortress config node (in ldap).
- LdapConnectionConfig logConfig = new LdapConnectionConfig();
- logConfig.setLdapHost( host );
- logConfig.setLdapPort( port );
- logConfig.setName( LocalConfig.getInstance().getProperty( GlobalIds.LDAP_ADMIN_POOL_UID, "" ) );
-
- logConfig.setUseSsl( IS_SSL );
-
- if ( IS_SSL && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ) )
- && StringUtils.isNotEmpty( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ) ) )
- {
- // validate certificates but allow self-signed certs if within this truststore:
- logConfig.setTrustManagers( new LdapClientTrustStoreManager( LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE ),
- LocalConfig.getInstance().getProperty( GlobalIds.TRUST_STORE_PW ).toCharArray(),
- null, true ) );
- }
+ public LdapDataProvider(){
- logConfig.setName( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_UID, "" ) );
- String logPw;
- if ( EncryptUtil.isEnabled() )
- {
- logPw = EncryptUtil.getInstance().decrypt( LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW ) );
- }
- else
- {
- logPw = LocalConfig.getInstance().getProperty( LDAP_LOG_POOL_PW );
- }
- logConfig.setCredentials( logPw );
- poolFactory = new ValidatingPoolableLdapConnectionFactory( logConfig );
- logPool = new LdapConnectionPool( poolFactory );
- logPool.setTestOnBorrow( true );
- logPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
- logPool.setMaxActive( logmax );
- logPool.setMinIdle( logmin );
- }
}
-
/**
* Given a contextId and a fortress param name return the LDAP dn.
*
@@ -327,7 +136,6 @@ public abstract class LdapDataProvider
}
}
-
/**
* Given a contextId return the LDAP dn that includes the suffix.
*
@@ -1398,16 +1206,9 @@ public abstract class LdapDataProvider
*
* @param connection handle to ldap connection object.
*/
- protected void closeAdminConnection( LdapConnection connection )
+ public void closeAdminConnection( LdapConnection connection )
{
- try
- {
- adminPool.releaseConnection( connection );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
+ LdapConnectionProvider.getInstance().closeAdminConnection(connection);
}
@@ -1418,14 +1219,7 @@ public abstract class LdapDataProvider
*/
protected void closeLogConnection( LdapConnection connection )
{
- try
- {
- logPool.releaseConnection( connection );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
+ LdapConnectionProvider.getInstance().closeLogConnection(connection);
}
@@ -1434,16 +1228,9 @@ public abstract class LdapDataProvider
*
* @param connection handle to ldap connection object.
*/
- protected void closeUserConnection( LdapConnection connection )
+ protected void closeUserConnection( LdapConnection connection )
{
- try
- {
- userPool.releaseConnection( connection );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
+ LdapConnectionProvider.getInstance().closeUserConnection(connection);
}
@@ -1453,16 +1240,9 @@ public abstract class LdapDataProvider
* @return ldap connection.
* @throws LdapException If we had an issue getting an LDAP connection
*/
- protected LdapConnection getAdminConnection() throws LdapException
+ public LdapConnection getAdminConnection() throws LdapException
{
- try
- {
- return adminPool.getConnection();
- }
- catch ( Exception e )
- {
- throw new LdapException( e.getMessage(), e );
- }
+ return LdapConnectionProvider.getInstance().getAdminConnection();
}
@@ -1474,14 +1254,7 @@ public abstract class LdapDataProvider
*/
protected LdapConnection getLogConnection() throws LdapException
{
- try
- {
- return logPool.getConnection();
- }
- catch ( Exception e )
- {
- throw new LdapException( e.getMessage(), e );
- }
+ return LdapConnectionProvider.getInstance().getLogConnection();
}
@@ -1493,14 +1266,7 @@ public abstract class LdapDataProvider
*/
protected LdapConnection getUserConnection() throws LdapException
{
- try
- {
- return userPool.getConnection();
- }
- catch ( Exception e )
- {
- throw new LdapException( e.getMessage(), e );
- }
+ return LdapConnectionProvider.getInstance().getUserConnection();
}
@@ -1564,29 +1330,7 @@ public abstract class LdapDataProvider
* Closes all the ldap connection pools.
*/
public static void closeAllConnectionPools(){
- try{
- LOG.info("Closing admin pool");
- adminPool.close();
- }
- catch(Exception e){
- LOG.warn("Error closing admin pool: " + e.getMessage());
- }
-
- try{
- LOG.info("Closing user pool");
- userPool.close();
- }
- catch(Exception e){
- LOG.warn("Error closing user pool: " + e.getMessage());
- }
-
- try{
- LOG.info("Closing log pool");
- logPool.close();
- }
- catch(Exception e){
- LOG.warn("Error closing log pool: " + e.getMessage());
- }
+ LdapConnectionProvider.getInstance().closeAllConnectionPools();
}
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/ae713f3b/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java
index f0ccf81..7519275 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapUtil.java
@@ -1,7 +1,5 @@
package org.apache.directory.fortress.core.ldap;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.util.Config;
public class LdapUtil {
@@ -23,64 +21,6 @@ public class LdapUtil {
}
return INSTANCE;
}
-
- /**
- *
- */
- private static char[] loadLdapEscapeChars()
- {
- if ( !LdapUtil.getInstance().isLdapfilterSizeFound() )
- {
- return null;
- }
-
- char[] ldapMetaChars = new char[LdapUtil.getInstance().getLdapFilterSize()];
-
- for ( int i = 1;; i++ )
- {
- String prop = GlobalIds.LDAP_FILTER + i;
- String value = Config.getInstance().getProperty( prop );
-
- if ( value == null )
- {
- break;
- }
-
- ldapMetaChars[i - 1] = value.charAt( 0 );
- }
-
- return ldapMetaChars;
- }
-
-
- /**
- *
- */
- private static String[] loadValidLdapVals()
- {
- if ( !LdapUtil.getInstance().isLdapfilterSizeFound() )
- {
- return null;
- }
-
- String[] ldapReplacements = new String[LdapUtil.getInstance().getLdapFilterSize()];
-
- for ( int i = 1;; i++ )
- {
- String prop = GlobalIds.LDAP_SUB + i;
- String value = Config.getInstance().getProperty( prop );
-
- if ( value == null )
- {
- break;
- }
-
- ldapReplacements[i - 1] = value;
- }
-
- return ldapReplacements;
- }
-
public boolean isLdapfilterSizeFound() {
return ldapfilterSizeFound;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/ae713f3b/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index 4efc574..0a4cdfd 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -89,9 +89,11 @@ public final class Config
}
}
- //init ldap util vals since config is stored ons erver
+ //init ldap util vals since config is stored on server
boolean ldapfilterSizeFound = ( getProperty( GlobalIds.LDAP_FILTER_SIZE_PROP ) != null );
LdapUtil.getInstance().setLdapfilterSizeFound(ldapfilterSizeFound);
+ LdapUtil.getInstance().setLdapMetaChars( loadLdapEscapeChars() );
+ LdapUtil.getInstance().setLdapReplVals( loadValidLdapVals() );
try
{
@@ -130,6 +132,46 @@ public final class Config
init();
}
+ private char[] loadLdapEscapeChars()
+ {
+ char[] ldapMetaChars = new char[LdapUtil.getInstance().getLdapFilterSize()];
+
+ for ( int i = 1;; i++ )
+ {
+ String prop = GlobalIds.LDAP_FILTER + i;
+ String value = getProperty( prop );
+
+ if ( value == null )
+ {
+ break;
+ }
+
+ ldapMetaChars[i - 1] = value.charAt( 0 );
+ }
+
+ return ldapMetaChars;
+ }
+
+ private String[] loadValidLdapVals()
+ {
+ String[] ldapReplacements = new String[LdapUtil.getInstance().getLdapFilterSize()];
+
+ for ( int i = 1;; i++ )
+ {
+ String prop = GlobalIds.LDAP_SUB + i;
+ String value = getProperty( prop );
+
+ if ( value == null )
+ {
+ break;
+ }
+
+ ldapReplacements[i - 1] = value;
+ }
+
+ return ldapReplacements;
+ }
+
/**
* Gets the prop attribute as String value from the apache commons cfg component.
*
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/ae713f3b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
index 843cf35..32bfd2e 100644
--- a/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/cache/CacheMgr.java
@@ -20,6 +20,8 @@
package org.apache.directory.fortress.core.util.cache;
import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Ehcache;
+import net.sf.ehcache.constructs.blocking.BlockingCache;
import org.apache.directory.fortress.core.CfgException;
import org.apache.directory.fortress.core.CfgRuntimeException;
@@ -98,7 +100,13 @@ public final class CacheMgr
*/
public Cache getCache( String cacheName )
{
- return CacheFactory.createInstance( cacheName, mEhCacheImpl );
+ Ehcache cache = mEhCacheImpl.getEhcache( cacheName );
+ if(cache != null){
+ return new EhCacheImpl( cacheName, new BlockingCache(cache) );
+ }
+ else{
+ return CacheFactory.createInstance( cacheName, mEhCacheImpl );
+ }
}
/**
[10/15] directory-fortress-core git commit: made globalIds not a
singleton and moved instance vars into config class
Posted by cp...@apache.org.
made globalIds not a singleton and moved instance vars into config class
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/a5ad1032
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/a5ad1032
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/a5ad1032
Branch: refs/heads/master
Commit: a5ad10329f79891de22cc4f46f79023c78f6c947
Parents: 07d205a
Author: clp207 <cl...@psu.edu>
Authored: Mon May 2 14:13:20 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Mon May 2 14:13:20 2016 -0400
----------------------------------------------------------------------
.../fortress/core/AccessMgrFactory.java | 2 +-
.../fortress/core/AdminMgrFactory.java | 2 +-
.../fortress/core/AuditMgrFactory.java | 2 +-
.../fortress/core/DelAccessMgrFactory.java | 2 +-
.../fortress/core/DelAdminMgrFactory.java | 2 +-
.../fortress/core/DelReviewMgrFactory.java | 2 +-
.../directory/fortress/core/GlobalIds.java | 57 ++------------------
.../fortress/core/PwPolicyMgrFactory.java | 2 +-
.../fortress/core/ReviewMgrFactory.java | 2 +-
.../directory/fortress/core/impl/PermDAO.java | 3 +-
.../directory/fortress/core/impl/UserDAO.java | 18 +++----
.../fortress/core/ldap/LdapDataProvider.java | 4 +-
.../fortress/core/model/ConstraintUtil.java | 25 ++++-----
.../directory/fortress/core/model/PropUtil.java | 3 +-
.../fortress/core/model/UserAdminRole.java | 26 ++++-----
.../directory/fortress/core/model/UserRole.java | 21 ++++----
.../directory/fortress/core/util/Config.java | 26 +++++++++
.../fortress/core/impl/FortressJUnitTest.java | 18 +++----
18 files changed, 99 insertions(+), 118 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
index 54a924b..1455379 100755
--- a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
@@ -68,7 +68,7 @@ public final class AccessMgrFactory
AccessMgr accessMgr;
if ( StringUtils.isEmpty( accessClassName ) )
{
- if(GlobalIds.getInstance().IS_REST)
+ if(Config.getInstance().IS_REST)
{
accessMgr = new AccessMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
index d95c686..8c617d5 100755
--- a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
@@ -71,7 +71,7 @@ public final class AdminMgrFactory
if ( StringUtils.isEmpty( adminClassName ) )
{
- if(GlobalIds.getInstance().IS_REST)
+ if(Config.getInstance().IS_REST)
{
adminMgr = new AdminMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
index 168ba29..8ae1834 100755
--- a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
@@ -70,7 +70,7 @@ public final class AuditMgrFactory
if ( StringUtils.isEmpty( auditClassName ) )
{
- if(GlobalIds.getInstance().IS_REST)
+ if(Config.getInstance().IS_REST)
{
auditMgr = new AuditMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
index 738d400..ed8a905 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
@@ -70,7 +70,7 @@ public final class DelAccessMgrFactory
if ( StringUtils.isEmpty( accessClassName ) )
{
- if(GlobalIds.getInstance().IS_REST)
+ if(Config.getInstance().IS_REST)
{
accessMgr = new DelAccessMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
index 9ff0a7a..00d2c5a 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
@@ -71,7 +71,7 @@ public final class DelAdminMgrFactory
if ( Strings.isEmpty( dAdminClassName ) )
{
- if ( GlobalIds.getInstance().IS_REST )
+ if ( Config.getInstance().IS_REST )
{
delAdminMgr = new DelAdminMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
index 4264601..1c008b4 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
@@ -68,7 +68,7 @@ public final class DelReviewMgrFactory
if ( StringUtils.isEmpty( dReviewClassName ) )
{
- if(GlobalIds.getInstance().IS_REST)
+ if(Config.getInstance().IS_REST)
{
delReviewMgr = new DelReviewMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
index 0b42189..c2678b8 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
@@ -21,7 +21,6 @@ package org.apache.directory.fortress.core;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.apache.directory.fortress.core.util.Config;
/**
@@ -38,48 +37,12 @@ import org.apache.directory.fortress.core.util.Config;
*/
public final class GlobalIds
{
- public static final String CONFIG_ROOT_PARAM = "config.root";
-
- private static volatile GlobalIds INSTANCE = null;
-
- public static GlobalIds getInstance() {
- if(INSTANCE == null) {
- synchronized (GlobalIds.class) {
- if(INSTANCE == null){
- INSTANCE = new GlobalIds();
- }
- }
- }
- return INSTANCE;
- }
-
- /**
- * Private constructor
- *
- */
- private GlobalIds()
- {
- IS_AUDIT_DISABLED = ( ( Config.getInstance().getProperty( DISABLE_AUDIT ) != null ) && ( Config
- .getInstance().getProperty( DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
-
- IS_REST = ( ( Config.getInstance().getProperty( ENABLE_REST ) != null ) && ( Config
- .getInstance().getProperty( ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
-
- IS_REALM = GlobalIds.REALM_TYPE.equalsIgnoreCase( Config
- .getInstance().getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
-
- IS_OPENLDAP = ( ( Config.getInstance().getProperty( SERVER_TYPE ) != null ) && ( Config
- .getInstance().getProperty( SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
-
- DELIMITER = Config.getInstance().getProperty( "attr.delimiter", "$" );
- }
+ public static final String CONFIG_ROOT_PARAM = "config.root";
public static final String HOME = "HOME";
public static final String TENANT = "tenant";
- private static final String DISABLE_AUDIT = "disable.audit";
- public boolean IS_AUDIT_DISABLED;
- private static final String ENABLE_REST = "enable.mgr.impl.rest";
- public boolean IS_REST;
+ public static final String DISABLE_AUDIT = "disable.audit";
+ public static final String ENABLE_REST = "enable.mgr.impl.rest";
/**
* The following constants are used within the factory classes:
@@ -167,13 +130,6 @@ public final class GlobalIds
public static final String DSD_VALIDATOR_PROP = "temporal.validator.dsd";
/**
- * This constant is used during authentication to determine if runtime is security realm. If IS_REALM == true,
- * the authentication module will not throw SecurityException on password resets. This is to enable the authentication
- * event to succeed allowing the application to prompt user to change their password.
- */
- public boolean IS_REALM;
-
- /**
* Parameter specifies the distinguished name (dn) of the LDAP suffix. The is the root or top-most node for a Directory Information Tree (DIT). The typical
* Fortress suffix format is {@code dc=example,dc=com}.
*/
@@ -257,7 +213,6 @@ public final class GlobalIds
*/
public static final String SERVER_TYPE = "ldap.server.type";
- public boolean IS_OPENLDAP;
/*
* *************************************************************************
@@ -505,12 +460,6 @@ public final class GlobalIds
public static final char PROP_SEP = ':';
/**
- * Fortress stores complex attribute types within a single attribute in ldap. Usually a delimiter of '$' is used for string tokenization.
- * format: {@code part1$part2$part3....} Stored in fortress.properties as 'attr.delimiter=$'
- */
- public String DELIMITER;
-
- /**
* Maximum number of records for ldap client to wait on while processing results sets from ldap server.
*/
public static final int BATCH_SIZE = 1000;
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
index 92a24e6..0fb127a 100755
--- a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
@@ -69,7 +69,7 @@ public final class PwPolicyMgrFactory
if ( StringUtils.isEmpty( policyClassName ) )
{
- if(GlobalIds.getInstance().IS_REST)
+ if(Config.getInstance().IS_REST)
{
policyMgr = new PwPolicyMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
index 557b605..2ee3f8c 100755
--- a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
@@ -69,7 +69,7 @@ public final class ReviewMgrFactory
if ( StringUtils.isEmpty( reviewClassName ) )
{
- if(GlobalIds.getInstance().IS_REST)
+ if(Config.getInstance().IS_REST)
{
reviewMgr = new ReviewMgrRestImpl();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
index bcf7718..326d18c 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
@@ -58,6 +58,7 @@ import org.apache.directory.fortress.core.model.PropUtil;
import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.ldap.client.api.LdapConnection;
@@ -920,7 +921,7 @@ final class PermDAO extends LdapDataProvider
throws FinderException
{
// Audit can be turned off here with fortress config param: 'disable.audit=true'
- if ( GlobalIds.getInstance().IS_OPENLDAP && ! GlobalIds.getInstance().IS_AUDIT_DISABLED )
+ if ( Config.getInstance().IS_OPENLDAP && ! Config.getInstance().IS_AUDIT_DISABLED )
{
try
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
index c547fc5..21f2e39 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
@@ -228,12 +228,12 @@ final class UserDAO extends LdapDataProvider
// POSIX_ACCOUNT_OBJECT_CLASS_NAME
};
- LOG.debug( "GlobalIds.IS_OPENLDAP: " + GlobalIds.getInstance().IS_OPENLDAP );
- LOG.debug( "GlobalIds.IS_OPENLDAP ? OPENLDAP_PW_RESET : null: " + ( GlobalIds.getInstance().IS_OPENLDAP ? OPENLDAP_PW_RESET
+ LOG.debug( "GlobalIds.IS_OPENLDAP: " + Config.getInstance().IS_OPENLDAP );
+ LOG.debug( "GlobalIds.IS_OPENLDAP ? OPENLDAP_PW_RESET : null: " + ( Config.getInstance().IS_OPENLDAP ? OPENLDAP_PW_RESET
: null ) );
- LOG.debug( "GlobalIds.IS_OPENLDAP: " + GlobalIds.getInstance().IS_OPENLDAP );
+ LOG.debug( "GlobalIds.IS_OPENLDAP: " + Config.getInstance().IS_OPENLDAP );
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
// This default set of attributes contains all and is used for search operations.
defaultAtrs = new String[]
@@ -497,7 +497,7 @@ final class UserDAO extends LdapDataProvider
myEntry.add( SYSTEM_USER, entity.isSystem().toString().toUpperCase() );
}
- if ( GlobalIds.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
+ if ( Config.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
{
String pwdPolicyDn = GlobalIds.POLICY_NODE_TYPE + "=" + entity.getPwPolicy() + "," + getRootDn(
entity.getContextId(), GlobalIds.PPOLICY_ROOT );
@@ -602,7 +602,7 @@ final class UserDAO extends LdapDataProvider
entity.getTitle() ) );
}
- if ( GlobalIds.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
+ if ( Config.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
{
String szDn = GlobalIds.POLICY_NODE_TYPE + "=" + entity.getPwPolicy() + "," + getRootDn( entity
.getContextId(), GlobalIds.PPOLICY_ROOT );
@@ -1056,7 +1056,7 @@ final class UserDAO extends LdapDataProvider
case CHANGE_AFTER_RESET:
// Don't throw exception if authenticating in J2EE Realm - The Web application must
// give user a chance to modify their password.
- if ( !GlobalIds.getInstance().IS_REALM )
+ if ( !Config.getInstance().IS_REALM )
{
errMsg = msgHdr + "PASSWORD HAS BEEN RESET BY LDAP_ADMIN_POOL_UID";
rc = GlobalErrIds.USER_PW_RESET;
@@ -1712,7 +1712,7 @@ final class UserDAO extends LdapDataProvider
modify( ld, userDn, mods );
// This modify update audit attributes on the User entry (if enabled):
- if ( GlobalIds.getInstance().IS_OPENLDAP && ! GlobalIds.getInstance().IS_AUDIT_DISABLED )
+ if ( Config.getInstance().IS_OPENLDAP && ! Config.getInstance().IS_AUDIT_DISABLED )
{
mods = new ArrayList<>();
modify( ld, userDn, mods, entity );
@@ -2088,7 +2088,7 @@ final class UserDAO extends LdapDataProvider
entity.addProperties( PropUtil.getProperties( getAttributes( entry, GlobalIds.PROPS ) ) );
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
szBoolean = getAttribute( entry, OPENLDAP_PW_RESET );
if ( szBoolean != null && szBoolean.equalsIgnoreCase( "true" ) )
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
index aa14e36..908b9fb 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/LdapDataProvider.java
@@ -240,7 +240,7 @@ public abstract class LdapDataProvider
{
COUNTERS.incrementAdd();
- if ( !GlobalIds.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
+ if ( !Config.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
{
if ( StringUtils.isNotEmpty( entity.getAdminSession().getInternalUserId() ) )
{
@@ -501,7 +501,7 @@ public abstract class LdapDataProvider
*/
private void audit( List<Modification> mods, FortEntity entity )
{
- if ( !GlobalIds.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
+ if ( !Config.getInstance().IS_AUDIT_DISABLED && ( entity != null ) && ( entity.getAdminSession() != null ) )
{
if ( StringUtils.isNotEmpty( entity.getAdminSession().getInternalUserId() ) )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java b/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
index ab8300a..a1eb7db 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/ConstraintUtil.java
@@ -22,8 +22,8 @@ package org.apache.directory.fortress.core.model;
import java.util.StringTokenizer;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.ValidationException;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.VUtil;
/**
@@ -134,7 +134,7 @@ public class ConstraintUtil
{
if ( StringUtils.isNotEmpty( inputString ) )
{
- StringTokenizer tkn = new StringTokenizer( inputString, GlobalIds.getInstance().DELIMITER, true );
+ StringTokenizer tkn = new StringTokenizer( inputString, Config.getInstance().DELIMITER, true );
if ( tkn.countTokens() > 0 )
{
int count = tkn.countTokens();
@@ -143,11 +143,11 @@ public class ConstraintUtil
for ( int i = 0; i < count; i++ )
{
String szValue = tkn.nextToken();
- if ( szValue.equals( GlobalIds.getInstance().DELIMITER ) && !previousTokenWasDelimiter )
+ if ( szValue.equals( Config.getInstance().DELIMITER ) && !previousTokenWasDelimiter )
{
previousTokenWasDelimiter = true;
}
- else if ( szValue.equals( GlobalIds.getInstance().DELIMITER ) )
+ else if ( szValue.equals( Config.getInstance().DELIMITER ) )
{
previousTokenWasDelimiter = true;
index++;
@@ -206,60 +206,61 @@ public class ConstraintUtil
public static String setConstraint( Constraint constraint )
{
String szConstraint = null;
+ String delimiter = Config.getInstance().DELIMITER;
if ( constraint != null )
{
StringBuilder sb = new StringBuilder();
sb.append( constraint.getName() );
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getTimeout() != null )
{
sb.append( constraint.getTimeout() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getBeginTime() != null )
{
sb.append( constraint.getBeginTime() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getEndTime() != null )
{
sb.append( constraint.getEndTime() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getBeginDate() != null )
{
sb.append( constraint.getBeginDate() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getEndDate() != null )
{
sb.append( constraint.getEndDate() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getBeginLockDate() != null )
{
sb.append( constraint.getBeginLockDate() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getEndLockDate() != null )
{
sb.append( constraint.getEndLockDate() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimiter );
if ( constraint.getDayMask() != null )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java b/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
index 0c0916e..3fb2b87 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/PropUtil.java
@@ -24,6 +24,7 @@ import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.util.Config;
/**
* Utilities to convert to/from property formats.
@@ -91,7 +92,7 @@ public final class PropUtil
*/
public static Properties getProperties( String inputString, char separator )
{
- return getProperties( inputString, separator, GlobalIds.getInstance().DELIMITER );
+ return getProperties( inputString, separator, Config.getInstance().DELIMITER );
}
/**
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java b/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
index e7a6d31..e064a12 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/UserAdminRole.java
@@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.util.Config;
/**
@@ -162,7 +163,7 @@ public class UserAdminRole extends UserRole implements Administrator
{
if ( ( szRawData != null ) && ( szRawData.length() > 0 ) )
{
- String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, GlobalIds.getInstance().DELIMITER );
+ String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, Config.getInstance().DELIMITER );
for ( int i = 0; i < tokens.length; i++ )
{
if ( StringUtils.isNotEmpty( tokens[i] ) )
@@ -246,39 +247,40 @@ public class UserAdminRole extends UserRole implements Administrator
public String getRawData()
{
String szRole;
+ String delimeter = Config.getInstance().DELIMITER;
StringBuilder sb = new StringBuilder();
sb.append( name );
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
sb.append( this.getTimeout() );
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( this.getBeginTime() != null )
{
sb.append( this.getBeginTime() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( this.getEndTime() != null )
{
sb.append( this.getEndTime() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( this.getBeginDate() != null )
{
sb.append( this.getBeginDate() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( this.getEndDate() != null )
{
sb.append( this.getEndDate() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( this.getBeginLockDate() != null )
{
@@ -286,14 +288,14 @@ public class UserAdminRole extends UserRole implements Administrator
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( this.getEndLockDate() != null )
{
sb.append( this.getEndLockDate() );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( this.getDayMask() != null )
{
@@ -304,7 +306,7 @@ public class UserAdminRole extends UserRole implements Administrator
{
for ( String org : this.getOsUSet() )
{
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
sb.append( U );
sb.append( GlobalIds.PROP_SEP );
sb.append( org );
@@ -315,7 +317,7 @@ public class UserAdminRole extends UserRole implements Administrator
{
for ( String org : this.getOsPSet() )
{
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
sb.append( P );
sb.append( GlobalIds.PROP_SEP );
sb.append( org );
@@ -323,7 +325,7 @@ public class UserAdminRole extends UserRole implements Administrator
}
if ( StringUtils.isNotEmpty( this.getRoleRangeRaw() ) )
{
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
sb.append( R );
sb.append( GlobalIds.PROP_SEP );
sb.append( this.getRoleRangeRaw() );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
index efb59d5..e769699 100755
--- a/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/UserRole.java
@@ -31,7 +31,7 @@ import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.util.Config;
/**
@@ -152,7 +152,7 @@ public class UserRole extends FortEntity implements Serializable, Constraint
{
if ( ( szRawData != null ) && ( szRawData.length() > 0 ) )
{
- String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, GlobalIds.getInstance().DELIMITER );
+ String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, Config.getInstance().DELIMITER );
for ( int i = 0; i < tokens.length; i++ )
{
if ( StringUtils.isNotEmpty( tokens[i] ) )
@@ -211,54 +211,55 @@ public class UserRole extends FortEntity implements Serializable, Constraint
@Override
public String getRawData()
{
+ String delimeter = Config.getInstance().DELIMITER;
StringBuilder sb = new StringBuilder();
sb.append( name );
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
sb.append( timeout );
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( beginTime != null )
{
sb.append( beginTime );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( endTime != null )
{
sb.append( endTime );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( beginDate != null )
{
sb.append( beginDate );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( endDate != null )
{
sb.append( endDate );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( beginLockDate != null )
{
sb.append( beginLockDate );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( endLockDate != null )
{
sb.append( endLockDate );
}
- sb.append( GlobalIds.getInstance().DELIMITER );
+ sb.append( delimeter );
if ( dayMask != null )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/main/java/org/apache/directory/fortress/core/util/Config.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/Config.java b/src/main/java/org/apache/directory/fortress/core/util/Config.java
index 0a4cdfd..556725d 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/Config.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/Config.java
@@ -54,6 +54,22 @@ public final class Config
private static final String CLS_NM = Config.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+ public boolean IS_REST;
+ public boolean IS_AUDIT_DISABLED;
+ public boolean IS_OPENLDAP;
+ /**
+ * This constant is used during authentication to determine if runtime is security realm. If IS_REALM == true,
+ * the authentication module will not throw SecurityException on password resets. This is to enable the authentication
+ * event to succeed allowing the application to prompt user to change their password.
+ */
+ public boolean IS_REALM;
+ /**
+ * Fortress stores complex attribute types within a single attribute in ldap. Usually a delimiter of '$' is used for string tokenization.
+ * format: {@code part1$part2$part3....} Stored in fortress.properties as 'attr.delimiter=$'
+ */
+ public String DELIMITER;
+
+
private static volatile Config INSTANCE = null;
public static Config getInstance() {
@@ -108,6 +124,16 @@ public final class Config
//ignore
}
+ IS_AUDIT_DISABLED = ( ( getProperty( GlobalIds.DISABLE_AUDIT ) != null ) && ( getProperty( GlobalIds.DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
+
+ IS_REST = ( ( getProperty( GlobalIds.ENABLE_REST ) != null ) && ( getProperty( GlobalIds.ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
+
+ IS_REALM = GlobalIds.REALM_TYPE.equalsIgnoreCase( getProperty( GlobalIds.AUTHENTICATION_TYPE ) );
+
+ IS_OPENLDAP = ( ( getProperty( GlobalIds.SERVER_TYPE ) != null ) && ( getProperty( GlobalIds.SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
+
+ DELIMITER = getProperty( "attr.delimiter", "$" );
+
}
else
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a5ad1032/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java b/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
index fca8127..5429386 100755
--- a/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
+++ b/src/test/java/org/apache/directory/fortress/core/impl/FortressJUnitTest.java
@@ -23,7 +23,7 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.util.Config;
/**
* This JUnit test class drives all of the Fortress Administration APIs contained within {@link AdminMgrImplTest},
@@ -105,7 +105,7 @@ public class FortressJUnitTest extends TestCase
if ( !isFirstRun() )
{
// PwPolicyMgr PW Policy Teardown:
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testDeletePasswordPolicy" ) );
}
@@ -126,7 +126,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AdminMgrImplTest( "testDelRoleDescendant" ) );
suite.addTest( new AdminMgrImplTest( "testDelRoleAscendant" ) );
suite.addTest( new AdminMgrImplTest( "testDeleteRole" ) );
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testDelete" ) );
}
@@ -151,7 +151,7 @@ public class FortressJUnitTest extends TestCase
/* 2. Build Up */
/***********************************************************/
// PW PolicyMgr APIs:
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testAdd" ) );
suite.addTest( new PswdPolicyMgrImplTest( "testUpdate" ) );
@@ -188,7 +188,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AdminMgrImplTest( "testUpdateRole" ) );
suite.addTest( new AdminMgrImplTest( "testAddUser" ) );
suite.addTest( new AdminMgrImplTest( "testUpdateUser" ) );
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testUpdatePasswordPolicy" ) );
}
@@ -210,7 +210,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new DelegatedMgrImplTest( "testSearchAdminRole" ) );
// ReviewMgr RBAC:
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
suite.addTest( new PswdPolicyMgrImplTest( "testRead" ) );
suite.addTest( new PswdPolicyMgrImplTest( "testSearch" ) );
@@ -253,7 +253,7 @@ public class FortressJUnitTest extends TestCase
// AccessMgr RBAC:
suite.addTest( new AccessMgrImplTest( "testGetUserId" ) );
suite.addTest( new AccessMgrImplTest( "testGetUser" ) );
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
// These tests are reliant on OpenLDAP's pwpolicy overlay:
suite.addTest( new AdminMgrImplTest( "testResetPassword" ) );
@@ -279,7 +279,7 @@ public class FortressJUnitTest extends TestCase
suite.addTest( new AccessMgrImplTest( "testCreateSessionWithRolesTrusted" ) );
// PwPolicyMgr PW Policy checks:
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
// These tests are reliant on OpenLDAP's pwpolicy overlay:
suite.addTest( new PswdPolicyMgrImplTest( "testMinAge" ) );
@@ -301,7 +301,7 @@ public class FortressJUnitTest extends TestCase
/* 5. Audit Checks */
/***********************************************************/
//suite.addTest(new AuditMgrImplTest("testSearchAuthNInvalid"));
- if ( GlobalIds.getInstance().IS_OPENLDAP )
+ if ( Config.getInstance().IS_OPENLDAP )
{
// These tests reliant on OpenLDAP's slapo access log overlay:
suite.addTest( new AuditMgrImplTest( "testSearchBinds" ) );
[15/15] directory-fortress-core git commit: fixing config issue from
merge
Posted by cp...@apache.org.
fixing config issue from merge
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/2431eb88
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/2431eb88
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/2431eb88
Branch: refs/heads/master
Commit: 2431eb886a15707b473b0523643a57e77a2ea44d
Parents: 6984434
Author: clp207 <cl...@psu.edu>
Authored: Thu May 5 09:48:23 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Thu May 5 09:48:23 2016 -0400
----------------------------------------------------------------------
src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/2431eb88/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
index 1e97c01..5cbfea2 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
@@ -447,7 +447,7 @@ final class UserDAO extends LdapDataProvider
{
myEntry.add( SchemaConstants.USER_PASSWORD_AT, new String( entity.getPassword() ) );
}
- else if( !Config.getBoolean( GlobalIds.USER_CREATION_PASSWORD_FIELD, false ) )
+ else if( !Config.getInstance().getBoolean( GlobalIds.USER_CREATION_PASSWORD_FIELD, false ) )
{
myEntry.add( SchemaConstants.USER_PASSWORD_AT, new String( new char[]{} ) );
}
[08/15] directory-fortress-core git commit: fixed initializing of
DSDCHECKER in VUtil
Posted by cp...@apache.org.
fixed initializing of DSDCHECKER in VUtil
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/ecf623bc
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/ecf623bc
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/ecf623bc
Branch: refs/heads/master
Commit: ecf623bc6fc1bc1733d29b88a268b138eaa1ad88
Parents: ae713f3
Author: clp207 <cl...@psu.edu>
Authored: Tue Apr 26 15:21:20 2016 -0400
Committer: clp207 <cl...@psu.edu>
Committed: Tue Apr 26 15:21:20 2016 -0400
----------------------------------------------------------------------
src/main/java/org/apache/directory/fortress/core/util/VUtil.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/ecf623bc/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/util/VUtil.java b/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
index 9092fca..7b042f8 100755
--- a/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/util/VUtil.java
@@ -116,7 +116,7 @@ public final class VUtil implements ConstraintValidator
LOG.error( "static initialzier caught SecurityException=" + ex.getMessage(), ex );
}
- Config.getInstance().getProperty( GlobalIds.DSD_VALIDATOR_PROP );
+ DSDVALIDATOR = Config.getInstance().getProperty( GlobalIds.DSD_VALIDATOR_PROP );
String lengthProp = Config.getInstance().getProperty( VALIDATE_LENGTH );
if ( lengthProp != null )
[04/15] directory-fortress-core git commit: refactored to not use
static initialization blocks
Posted by cp...@apache.org.
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
index 1bbf25d..7a38421 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
@@ -21,6 +21,9 @@
package org.apache.directory.fortress.core.impl;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.lang.StringUtils;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.cursor.CursorException;
@@ -34,24 +37,21 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
-import org.apache.directory.fortress.core.model.Group;
-import org.apache.directory.fortress.core.model.PropUtil;
-import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.fortress.core.CreateException;
import org.apache.directory.fortress.core.FinderException;
-import org.apache.directory.fortress.core.model.ObjectFactory;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
-import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.ldap.LdapDataProvider;
+import org.apache.directory.fortress.core.model.Group;
+import org.apache.directory.fortress.core.model.ObjectFactory;
+import org.apache.directory.fortress.core.model.PropUtil;
import org.apache.directory.fortress.core.model.User;
+import org.apache.directory.fortress.core.util.Config;
+import org.apache.directory.ldap.client.api.LdapConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.CreateException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.RemoveException;
-
-import java.util.ArrayList;
-import java.util.List;
/**
@@ -65,27 +65,33 @@ final class GroupDAO extends LdapDataProvider
private static final String CLS_NM = GroupDAO.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
private static final String GROUP_OBJECT_CLASS = "group.objectclass";
- private static final String GROUP_OBJECT_CLASS_IMPL = Config.getProperty( GROUP_OBJECT_CLASS );
+ private String GROUP_OBJECT_CLASS_IMPL;
private static final String GROUP_PROTOCOL_ATTR = "group.protocol";
- private static final String GROUP_PROTOCOL_ATTR_IMPL = Config.getProperty( GROUP_PROTOCOL_ATTR );
+ private String GROUP_PROTOCOL_ATTR_IMPL;
private static final String GROUP_PROPERTY_ATTR = "group.properties";
- private static final String GROUP_PROPERTY_ATTR_IMPL = Config.getProperty( GROUP_PROPERTY_ATTR );
- private static final String GROUP_OBJ_CLASS[] =
- { SchemaConstants.TOP_OC, GROUP_OBJECT_CLASS_IMPL };
- private static final String[] GROUP_ATRS =
- {
- SchemaConstants.CN_AT,
- SchemaConstants.DESCRIPTION_AT,
- GROUP_PROTOCOL_ATTR_IMPL,
- GROUP_PROPERTY_ATTR_IMPL,
- SchemaConstants.MEMBER_AT };
-
+ private String GROUP_PROPERTY_ATTR_IMPL;
+ private String[] GROUP_OBJ_CLASS;
+ private String[] GROUP_ATRS;
/**
* Package private default constructor.
*/
GroupDAO()
{
+ super();
+ GROUP_OBJECT_CLASS_IMPL = Config.getInstance().getProperty( GROUP_OBJECT_CLASS );
+ GROUP_PROTOCOL_ATTR_IMPL = Config.getInstance().getProperty( GROUP_PROTOCOL_ATTR );
+ GROUP_PROPERTY_ATTR_IMPL = Config.getInstance().getProperty( GROUP_PROPERTY_ATTR );
+
+ GROUP_OBJ_CLASS = new String[]{SchemaConstants.TOP_OC, GROUP_OBJECT_CLASS_IMPL };
+
+ GROUP_ATRS = new String[]
+ {
+ SchemaConstants.CN_AT,
+ SchemaConstants.DESCRIPTION_AT,
+ GROUP_PROTOCOL_ATTR_IMPL,
+ GROUP_PROPERTY_ATTR_IMPL,
+ SchemaConstants.MEMBER_AT };
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
index dce47e2..acd2e67 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
@@ -44,8 +44,12 @@ import org.apache.directory.fortress.core.model.User;
public class GroupMgrImpl extends Manageable implements GroupMgr, Serializable
{
private static final String CLS_NM = GroupMgrImpl.class.getName();
- private static final GroupP GROUP_P = new GroupP();
+ private GroupP GROUP_P;
+ public GroupMgrImpl() {
+ GROUP_P = new GroupP();
+ }
+
/**
* {@inheritDoc}
*/
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/GroupP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/GroupP.java b/src/main/java/org/apache/directory/fortress/core/impl/GroupP.java
index 680c06d..856d201 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/GroupP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/GroupP.java
@@ -20,18 +20,18 @@
package org.apache.directory.fortress.core.impl;
+import java.util.List;
+
import org.apache.directory.api.util.Strings;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.ValidationException;
import org.apache.directory.fortress.core.model.Group;
import org.apache.directory.fortress.core.model.User;
+import org.apache.directory.fortress.core.util.VUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.util.VUtil;
-
-import java.util.List;
/**
@@ -44,9 +44,12 @@ final class GroupP
{
private static final String CLS_NM = GroupP.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
- private static GroupDAO gDao = new GroupDAO();
-
+ private GroupDAO gDao;
+ public GroupP(){
+ gDao = new GroupDAO();
+ }
+
/**
* Add a group node to the Directory Information Tree (DIT).
*
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java
index 1ae4ccb..c1e4dc1 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java
@@ -40,19 +40,19 @@ import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
-import org.apache.directory.fortress.core.model.Graphable;
-import org.apache.directory.fortress.core.model.OrgUnit;
-import org.apache.directory.ldap.client.api.LdapConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.CreateException;
import org.apache.directory.fortress.core.FinderException;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
import org.apache.directory.fortress.core.ldap.LdapDataProvider;
+import org.apache.directory.fortress.core.model.Graphable;
+import org.apache.directory.fortress.core.model.ObjectFactory;
+import org.apache.directory.fortress.core.model.OrgUnit;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -123,7 +123,10 @@ final class OrgUnitDAO extends LdapDataProvider
SchemaConstants.OU_AT
};
-
+ public OrgUnitDAO(){
+ super();
+ }
+
/**
* @param entity
* @return
@@ -706,13 +709,13 @@ final class OrgUnitDAO extends LdapDataProvider
{
entity.setType( OrgUnit.Type.PERM );
//entity.setParents(PsoUtil.getParents(entity.getName().toUpperCase(), contextId));
- entity.setChildren( PsoUtil.getChildren( entity.getName().toUpperCase(), contextId ) );
+ entity.setChildren( PsoUtil.getInstance().getChildren( entity.getName().toUpperCase(), contextId ) );
}
else if ( dn.contains( getRootDn( contextId, GlobalIds.OSU_ROOT ) ) )
{
entity.setType( OrgUnit.Type.USER );
//entity.setParents(UsoUtil.getParents(entity.getName().toUpperCase(), contextId));
- entity.setChildren( UsoUtil.getChildren( entity.getName().toUpperCase(), contextId ) );
+ entity.setChildren( UsoUtil.getInstance().getChildren( entity.getName().toUpperCase(), contextId ) );
}
entity.setParents( getAttributeSet( le, GlobalIds.PARENT_NODES ) );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitP.java b/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitP.java
index 3c87d7d..4f96316 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitP.java
@@ -26,16 +26,16 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.model.Graphable;
-import org.apache.directory.fortress.core.model.OrgUnit;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.model.Graphable;
+import org.apache.directory.fortress.core.model.OrgUnit;
import org.apache.directory.fortress.core.util.VUtil;
import org.apache.directory.fortress.core.util.cache.Cache;
import org.apache.directory.fortress.core.util.cache.CacheMgr;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -70,13 +70,15 @@ public final class OrgUnitP
private static Cache ouCache;
// DAO class for OU data sets must be initializer before the other statics:
- private static final OrgUnitDAO oDao = new OrgUnitDAO();
+ private OrgUnitDAO oDao;
private static final String USER_OUS = "user.ous";
private static final String PERM_OUS = "perm.ous";
private static final String FORTRESS_OUS = "fortress.ous";
- static
+ public void init()
{
+ oDao = new OrgUnitDAO();
+
CacheMgr cacheMgr = CacheMgr.getInstance();
OrgUnitP.ouCache = cacheMgr.getCache( FORTRESS_OUS );
}
@@ -87,6 +89,7 @@ public final class OrgUnitP
*/
OrgUnitP()
{
+ init();
}
@@ -143,7 +146,7 @@ public final class OrgUnitP
* @param orgUnit The orgUnit
* @return The set of associated User
*/
- private static Set<String> loadUserSet( OrgUnit orgUnit )
+ private Set<String> loadUserSet( OrgUnit orgUnit )
{
Set<String> ouUserSet = null;
@@ -168,7 +171,7 @@ public final class OrgUnitP
* @param orgUnit The orgUnit
* @return The set of associated Perms
*/
- private static Set<String> loadPermSet( OrgUnit orgUnit )
+ private Set<String> loadPermSet( OrgUnit orgUnit )
{
Set<String> ouPermSet = null;
@@ -193,7 +196,7 @@ public final class OrgUnitP
* @param orgUnit will be a Perm OU.
* @return Set containing the OU mapping to a Perm type and tenant.
*/
- private static Set<String> getPermSet( OrgUnit orgUnit )
+ private Set<String> getPermSet( OrgUnit orgUnit )
{
@SuppressWarnings("unchecked")
Set<String> permSet = ( Set<String> ) ouCache.get( getKey( PERM_OUS, orgUnit.getContextId() ) );
@@ -212,7 +215,7 @@ public final class OrgUnitP
* @param orgUnit will be a User OU
* @return Set containing the OU mapping to the user type and tenant.
*/
- private static Set<String> getUserSet( OrgUnit orgUnit )
+ private Set<String> getUserSet( OrgUnit orgUnit )
{
@SuppressWarnings("unchecked")
Set<String> userSet = ( Set<String> ) ouCache.get( getKey( USER_OUS, orgUnit.getContextId() ) );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
index e6bf4ca..7e53530 100644
--- a/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
@@ -27,14 +27,14 @@ import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.fortress.core.CreateException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.RemoveException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.OrganizationalUnit;
import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
/**
@@ -75,6 +75,7 @@ final class OrganizationalUnitDAO extends LdapDataProvider
*/
OrganizationalUnitDAO()
{
+ super();
}
/**
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
index a461aac..bcf7718 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
@@ -42,23 +42,23 @@ import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueEx
import org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.fortress.core.CreateException;
+import org.apache.directory.fortress.core.FinderException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.RemoveException;
+import org.apache.directory.fortress.core.UpdateException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.AdminRole;
+import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.model.OrgUnit;
import org.apache.directory.fortress.core.model.PermObj;
import org.apache.directory.fortress.core.model.Permission;
+import org.apache.directory.fortress.core.model.PropUtil;
import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
-import org.apache.directory.fortress.core.model.PropUtil;
import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.fortress.core.CreateException;
-import org.apache.directory.fortress.core.FinderException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
-import org.apache.directory.fortress.core.RemoveException;
-import org.apache.directory.fortress.core.UpdateException;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
/**
@@ -203,7 +203,10 @@ final class PermDAO extends LdapDataProvider
GlobalIds.PROPS
};
-
+ public PermDAO(){
+ super();
+ }
+
/**
* @param entity
* @return
@@ -917,7 +920,7 @@ final class PermDAO extends LdapDataProvider
throws FinderException
{
// Audit can be turned off here with fortress config param: 'disable.audit=true'
- if ( GlobalIds.IS_OPENLDAP && ! GlobalIds.IS_AUDIT_DISABLED )
+ if ( GlobalIds.getInstance().IS_OPENLDAP && ! GlobalIds.getInstance().IS_AUDIT_DISABLED )
{
try
{
@@ -985,7 +988,7 @@ final class PermDAO extends LdapDataProvider
else
{
// RBAC Permission check include's User's inherited roles:
- Set<String> activatedRoles = RoleUtil.getInheritedRoles( session.getRoles(), permission.getContextId() );
+ Set<String> activatedRoles = RoleUtil.getInstance().getInheritedRoles( session.getRoles(), permission.getContextId() );
for ( String role : roles )
{
@@ -1385,7 +1388,7 @@ final class PermDAO extends LdapDataProvider
}
else
{
- roles = RoleUtil.getAscendants( role.getName(), role.getContextId() );
+ roles = RoleUtil.getInstance().getAscendants( role.getName(), role.getContextId() );
}
}
if ( CollectionUtils.isNotEmpty( roles ) )
@@ -1461,7 +1464,7 @@ final class PermDAO extends LdapDataProvider
filterbuf.append( GlobalIds.FILTER_PREFIX );
filterbuf.append( PERM_OP_OBJECT_CLASS_NAME );
filterbuf.append( ")(|" );
- Set<String> roles = RoleUtil.getInheritedRoles( user.getRoles(), user.getContextId() );
+ Set<String> roles = RoleUtil.getInstance().getInheritedRoles( user.getRoles(), user.getContextId() );
if ( CollectionUtils.isNotEmpty( roles ) )
{
@@ -1594,7 +1597,7 @@ final class PermDAO extends LdapDataProvider
}
else
{
- roles = RoleUtil.getInheritedRoles( session.getRoles(), session.getContextId() );
+ roles = RoleUtil.getInstance().getInheritedRoles( session.getRoles(), session.getContextId() );
}
if ( CollectionUtils.isNotEmpty( roles ) )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermP.java b/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
index d806b60..fa39098 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermP.java
@@ -62,8 +62,8 @@ final class PermP
/**
* Description of the Field
*/
- private static final PermDAO pDao = new PermDAO();
- private final OrgUnitP orgUnitP = new OrgUnitP();
+ private PermDAO pDao;
+ private OrgUnitP orgUnitP;
/**
@@ -71,6 +71,8 @@ final class PermP
*/
PermP()
{
+ pDao = new PermDAO();
+ orgUnitP = new OrgUnitP();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java
index 2e4c15d..c58c4a5 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java
@@ -38,16 +38,16 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
-import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.fortress.core.CreateException;
import org.apache.directory.fortress.core.FinderException;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
import org.apache.directory.fortress.core.ldap.LdapDataProvider;
+import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.model.PwPolicy;
+import org.apache.directory.ldap.client.api.LdapConnection;
/**
@@ -143,6 +143,9 @@ final class PolicyDAO extends LdapDataProvider
SchemaConstants.CN_AT
};
+ public PolicyDAO(){
+ super();
+ }
/**
* @param entity
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/PolicyP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PolicyP.java b/src/main/java/org/apache/directory/fortress/core/impl/PolicyP.java
index 827e758..83e82f6 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PolicyP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PolicyP.java
@@ -26,15 +26,15 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.lang.StringUtils;
-import org.apache.directory.fortress.core.model.PwPolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
import org.apache.directory.fortress.core.SecurityException;
import org.apache.directory.fortress.core.ValidationException;
+import org.apache.directory.fortress.core.model.PwPolicy;
import org.apache.directory.fortress.core.util.cache.Cache;
import org.apache.directory.fortress.core.util.cache.CacheMgr;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -63,7 +63,7 @@ final class PolicyP
private static final int MAX_AGE = 157680000;
// DAO class for ol pw policy data sets must be initialized before the other statics:
- private static final PolicyDAO olDao = new PolicyDAO();
+ private PolicyDAO olDao;
// this field is used to synchronize access to the above static data set:
private static final ReadWriteLock policySetLock = new ReentrantReadWriteLock();
// static field holds the list of names for all valid pw policies in effect:
@@ -75,8 +75,10 @@ final class PolicyP
private static final String POLICIES = "policies";
private static final String FORTRESS_POLICIES = "fortress.policies";
- static
+ private void init()
{
+ olDao = new PolicyDAO();
+
CacheMgr cacheMgr = CacheMgr.getInstance();
PolicyP.policyCache = cacheMgr.getCache( FORTRESS_POLICIES );
}
@@ -87,6 +89,7 @@ final class PolicyP
*/
PolicyP()
{
+ init();
}
@@ -371,7 +374,7 @@ final class PolicyP
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of unique names.
*/
- private static Set<String> loadPolicySet( String contextId )
+ private Set<String> loadPolicySet( String contextId )
{
Set<String> policySet = null;
@@ -396,7 +399,7 @@ final class PolicyP
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return set containing list of policy names active.
*/
- private static Set<String> getPolicySet( String contextId )
+ private Set<String> getPolicySet( String contextId )
{
try
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/PsoUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PsoUtil.java b/src/main/java/org/apache/directory/fortress/core/impl/PsoUtil.java
index 6145818..6c4618b 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PsoUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PsoUtil.java
@@ -63,19 +63,38 @@ import org.slf4j.LoggerFactory;
*/
final class PsoUtil
{
- private static final Cache psoCache;
- private static OrgUnitP orgUnitP = new OrgUnitP();
+ private Cache psoCache;
+ private OrgUnitP orgUnitP;
private static final String CLS_NM = PsoUtil.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+ private static volatile PsoUtil INSTANCE = null;
+
+ public static PsoUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (PsoUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new PsoUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ public PsoUtil(){
+ init();
+ }
+
/**
* Initialize the Perm OU hierarchies. This will read the {@link org.apache.directory.fortress.core.model.Hier} data set from ldap and load into
* the JGraphT simple digraph that referenced statically within this class.
*/
- static
+ private void init()
{
+ orgUnitP = new OrgUnitP();
+
CacheMgr cacheMgr = CacheMgr.getInstance();
- psoCache = cacheMgr.getCache( "fortress.pso" );
+ psoCache = cacheMgr.getCache( "fortress.pso" );
}
@@ -86,7 +105,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of names of descendants {@link org.apache.directory.fortress.core.model.OrgUnit}s of given parent.
*/
- static Set<String> getDescendants( String name, String contextId )
+ Set<String> getDescendants( String name, String contextId )
{
return HierUtil.getDescendants( name, getGraph( contextId ) );
}
@@ -99,7 +118,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of ou names that are ascendants of given child.
*/
- static Set<String> getAscendants( String name, String contextId )
+ Set<String> getAscendants( String name, String contextId )
{
return HierUtil.getAscendants( name, getGraph( contextId ) );
}
@@ -112,7 +131,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of names of children {@link org.apache.directory.fortress.core.model.OrgUnit}s of given parent.
*/
- public static Set<String> getChildren( String name, String contextId )
+ public Set<String> getChildren( String name, String contextId )
{
return HierUtil.getChildren( name, getGraph( contextId ) );
}
@@ -125,7 +144,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of ou names that are parents of given child.
*/
- static Set<String> getParents( String name, String contextId )
+ Set<String> getParents( String name, String contextId )
{
return HierUtil.getParents( name, getGraph( contextId ) );
}
@@ -138,7 +157,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return int value contains the number of children of a given parent ou.
*/
- static int numChildren( String name, String contextId )
+ int numChildren( String name, String contextId )
{
return HierUtil.numChildren( name, getGraph( contextId ) );
}
@@ -151,7 +170,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return contains Set of all descendants.
*/
- static Set<String> getInherited( List<OrgUnit> ous, String contextId )
+ Set<String> getInherited( List<OrgUnit> ous, String contextId )
{
// create Set with case insensitive comparator:
Set<String> iOUs = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
@@ -190,7 +209,7 @@ final class PsoUtil
* @throws org.apache.directory.fortress.core.ValidationException
* in the event it fails one of the 3 checks.
*/
- static void validateRelationship( OrgUnit child, OrgUnit parent, boolean mustExist )
+ void validateRelationship( OrgUnit child, OrgUnit parent, boolean mustExist )
throws ValidationException
{
HierUtil.validateRelationship( getGraph( child.getContextId() ), child.getName(), parent.getName(), mustExist );
@@ -206,7 +225,7 @@ final class PsoUtil
* @param op used to pass the ldap op {@link org.apache.directory.fortress.core.model.Hier.Op#ADD}, {@link org.apache.directory.fortress.core.model.Hier.Op#MOD}, {@link org.apache.directory.fortress.core.model.Hier.Op#REM}
* @throws org.apache.directory.fortress.core.SecurityException in the event of a system error.
*/
- static void updateHier( String contextId, Relationship relationship, Hier.Op op ) throws SecurityException
+ void updateHier( String contextId, Relationship relationship, Hier.Op op ) throws SecurityException
{
HierUtil.updateHier( getGraph( contextId ), relationship, op );
}
@@ -219,7 +238,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return handle to simple digraph containing perm ou hierarchies.
*/
- private static synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
+ private synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
{
Hier inHier = new Hier( Hier.Type.ROLE );
inHier.setContextId( contextId );
@@ -252,7 +271,7 @@ final class PsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return handle to simple digraph containing perm ou hierarchies.
*/
- private static SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
+ private SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
{
String key = getKey( contextId );
LOG.debug("Getting graph for key " + contextId);
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/PwPolicyMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PwPolicyMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/PwPolicyMgrImpl.java
index 0c7746a..b936a7a 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PwPolicyMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PwPolicyMgrImpl.java
@@ -19,6 +19,8 @@
*/
package org.apache.directory.fortress.core.impl;
+import java.util.List;
+
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.PwPolicyMgr;
import org.apache.directory.fortress.core.SecurityException;
@@ -26,8 +28,6 @@ import org.apache.directory.fortress.core.model.PwPolicy;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.util.VUtil;
-import java.util.List;
-
/**
* This class is used to perform administrative and review functions on the PWPOLICIES and USERS data sets.
* <h3></h3>
@@ -66,9 +66,14 @@ import java.util.List;
public class PwPolicyMgrImpl extends Manageable implements PwPolicyMgr
{
private static final String CLS_NM = PwPolicyMgrImpl.class.getName();
- private static final PolicyP policyP = new PolicyP();
- private static final UserP userP = new UserP();
-
+ private PolicyP policyP;
+ private UserP userP;
+
+ public PwPolicyMgrImpl() {
+ policyP = new PolicyP();
+ userP = new UserP();
+ }
+
/**
* {@inheritDoc}
*/
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
index 88882e6..1600d17 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ReviewMgrImpl.java
@@ -80,11 +80,18 @@ import org.apache.directory.fortress.core.util.VUtil;
public class ReviewMgrImpl extends Manageable implements ReviewMgr, Serializable
{
private static final String CLS_NM = ReviewMgrImpl.class.getName();
- private static final UserP userP = new UserP();
- private static final RoleP roleP = new RoleP();
- private static final PermP permP = new PermP();
- private static final SdP ssdP = new SdP();
-
+ private UserP userP = new UserP();
+ private RoleP roleP = new RoleP();
+ private PermP permP = new PermP();
+ private SdP ssdP = new SdP();
+
+ public ReviewMgrImpl() {
+ userP = new UserP();
+ roleP = new RoleP();
+ permP = new PermP();
+ ssdP = new SdP();
+ }
+
/**
* {@inheritDoc}
*/
@@ -376,7 +383,7 @@ public class ReviewMgrImpl extends Manageable implements ReviewMgr, Serializable
Set<String> iRoles = null;
if (CollectionUtils.isNotEmpty( roles ))
{
- iRoles = RoleUtil.getInheritedRoles( roles, this.contextId );
+ iRoles = RoleUtil.getInstance().getInheritedRoles( roles, this.contextId );
}
return iRoles;
}
@@ -529,7 +536,7 @@ public class ReviewMgrImpl extends Manageable implements ReviewMgr, Serializable
if (assignedRoles != null)
{
// Get the descendant roles of all assigned roles from jgrapht hierarchical roles data set:
- authorizedRoles = RoleUtil.getDescendantRoles(assignedRoles, this.contextId);
+ authorizedRoles = RoleUtil.getInstance().getDescendantRoles(assignedRoles, this.contextId);
}
return authorizedRoles;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java
index d942ad5..e21e916 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java
@@ -36,18 +36,18 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
-import org.apache.directory.fortress.core.model.ConstraintUtil;
-import org.apache.directory.fortress.core.model.Graphable;
-import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.fortress.core.CreateException;
import org.apache.directory.fortress.core.FinderException;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
import org.apache.directory.fortress.core.ldap.LdapDataProvider;
+import org.apache.directory.fortress.core.model.ConstraintUtil;
+import org.apache.directory.fortress.core.model.Graphable;
+import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.model.Role;
+import org.apache.directory.ldap.client.api.LdapConnection;
/**
@@ -130,7 +130,10 @@ final class RoleDAO extends LdapDataProvider
GlobalIds.FT_MODIFIER_AUX_OBJECT_CLASS_NAME
};
-
+ public RoleDAO() {
+ super();
+ }
+
/**
* @param entity
* @return
@@ -648,7 +651,7 @@ final class RoleDAO extends LdapDataProvider
entity.setDescription( getAttribute( le, SchemaConstants.DESCRIPTION_AT ) );
entity.setOccupants( getAttributes( le, SchemaConstants.ROLE_OCCUPANT_AT ) );
//entity.setParents(RoleUtil.getParents(entity.getName().toUpperCase(), contextId));
- entity.setChildren( RoleUtil.getChildren( entity.getName().toUpperCase(), contextId ) );
+ entity.setChildren( RoleUtil.getInstance().getChildren( entity.getName().toUpperCase(), contextId ) );
entity.setParents( getAttributeSet( le, GlobalIds.PARENT_NODES ) );
unloadTemporal( le, entity );
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/RoleP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/RoleP.java b/src/main/java/org/apache/directory/fortress/core/impl/RoleP.java
index fccc075..da01dbb 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/RoleP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/RoleP.java
@@ -56,7 +56,7 @@ import org.apache.directory.fortress.core.util.VUtil;
*/
final class RoleP
{
- private static RoleDAO rDao = new RoleDAO();
+ private RoleDAO rDao;
private static final ConstraintValidator constraintValidator = VUtil.getConstraintValidator();
@@ -65,6 +65,7 @@ final class RoleP
*/
RoleP()
{
+ rDao = new RoleDAO();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java b/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java
index cf7052c..f966f3b 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/RoleUtil.java
@@ -64,17 +64,36 @@ import org.slf4j.LoggerFactory;
*/
final class RoleUtil implements ParentUtil
{
- private static final Cache roleCache;
- private static final RoleP roleP = new RoleP();
+ private Cache roleCache;
+ private RoleP roleP = new RoleP();
private static final String CLS_NM = RoleUtil.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+ private static volatile RoleUtil INSTANCE = null;
+
+ public static RoleUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (RoleUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new RoleUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ public RoleUtil(){
+ init();
+ }
+
/**
* Initialize the Role hierarchies. This will read the {@link org.apache.directory.fortress.core.model.Hier} data set from ldap and load into
* the JGraphT simple digraph that referenced statically within this class.
*/
- static
+ private void init()
{
+ roleP = new RoleP();
+
CacheMgr cacheMgr = CacheMgr.getInstance();
roleCache = cacheMgr.getCache( "fortress.roles" );
}
@@ -97,7 +116,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return boolean result, 'true' indicates parent/child relationship exists.
*/
- static boolean isParent( String child, String parent, String contextId )
+ boolean isParent( String child, String parent, String contextId )
{
boolean result = false;
Set<String> parents = getAscendants( child, contextId );
@@ -116,7 +135,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of Role names are descendants {@link org.apache.directory.fortress.core.model.Role}s of given parent.
*/
- static Set<String> getDescendants( String roleName, String contextId )
+ Set<String> getDescendants( String roleName, String contextId )
{
return HierUtil.getDescendants( roleName.toUpperCase(), getGraph( contextId ) );
}
@@ -129,7 +148,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of Role names are children {@link org.apache.directory.fortress.core.model.Role}s of given parent.
*/
- static Set<String> getChildren( String roleName, String contextId )
+ Set<String> getChildren( String roleName, String contextId )
{
return HierUtil.getChildren( roleName.toUpperCase(), getGraph( contextId ) );
}
@@ -142,7 +161,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of Role names that are ascendants of given child.
*/
- static Set<String> getAscendants( String roleName, String contextId )
+ Set<String> getAscendants( String roleName, String contextId )
{
return HierUtil.getAscendants( roleName.toUpperCase(), getGraph( contextId ) );
}
@@ -155,7 +174,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of Role names that are parents of given child.
*/
- static Set<String> getParents( String roleName, String contextId )
+ Set<String> getParents( String roleName, String contextId )
{
return HierUtil.getParents( roleName.toUpperCase(), getGraph( contextId ) );
}
@@ -181,7 +200,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return int value contains the number of children of a given parent nRole.
*/
- static int numChildren( String roleName, String contextId )
+ int numChildren( String roleName, String contextId )
{
return HierUtil.numChildren( roleName.toUpperCase(), getGraph( contextId ) );
}
@@ -195,7 +214,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return contains Set of all authorized RBAC Roles for a given User.
*/
- static Set<String> getInheritedRoles( List<UserRole> uRoles, String contextId )
+ Set<String> getInheritedRoles( List<UserRole> uRoles, String contextId )
{
// create Set with case insensitive comparator:
Set<String> iRoles = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
@@ -222,7 +241,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return set of ascendant roles associated with this entry.
*/
- static Set<String> getAscendantRoles( List<String> roles, String contextId )
+ Set<String> getAscendantRoles( List<String> roles, String contextId )
{
// create Set with case insensitive comparator:
Set<String> iRoles = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
@@ -248,7 +267,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return set of descendant roles associated with this entry.
*/
- static Set<String> getDescendantRoles( Set<String> roles, String contextId )
+ Set<String> getDescendantRoles( Set<String> roles, String contextId )
{
// create Set with case insensitive comparator:
Set<String> iRoles = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
@@ -277,7 +296,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return Set of names that are parents of given child.
*/
- static Set<String> getAscendants( String childName, String parentName, boolean isInclusive, String contextId )
+ Set<String> getAscendants( String childName, String parentName, boolean isInclusive, String contextId )
{
return HierUtil.getAscendants( childName, parentName, isInclusive, getGraph( contextId ) );
}
@@ -300,7 +319,7 @@ final class RoleUtil implements ParentUtil
* @throws org.apache.directory.fortress.core.ValidationException
* in the event it fails one of the 3 checks.
*/
- static void validateRelationship( Role childRole, Role parentRole, boolean mustExist )
+ void validateRelationship( Role childRole, Role parentRole, boolean mustExist )
throws ValidationException
{
HierUtil.validateRelationship( getGraph( childRole.getContextId() ), childRole.getName(), parentRole.getName(),
@@ -317,7 +336,7 @@ final class RoleUtil implements ParentUtil
* @param op used to pass the ldap op {@link org.apache.directory.fortress.core.model.Hier.Op#ADD}, {@link org.apache.directory.fortress.core.model.Hier.Op#MOD}, {@link org.apache.directory.fortress.core.model.Hier.Op#REM}
* @throws org.apache.directory.fortress.core.SecurityException in the event of a system error.
*/
- static void updateHier( String contextId, Relationship relationship, Hier.Op op ) throws SecurityException
+ void updateHier( String contextId, Relationship relationship, Hier.Op op ) throws SecurityException
{
HierUtil.updateHier( getGraph( contextId ), relationship, op );
}
@@ -330,7 +349,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return handle to simple digraph containing role hierarchies.
*/
- private static synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
+ private synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
{
Hier inHier = new Hier( Hier.Type.ROLE );
inHier.setContextId( contextId );
@@ -361,7 +380,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return key to this tenant's cache entry.
*/
- private static String getKey( String contextId )
+ private String getKey( String contextId )
{
String key = HierUtil.Type.ROLE.toString();
@@ -379,7 +398,7 @@ final class RoleUtil implements ParentUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return handle to simple digraph containing role hierarchies.
*/
- private static SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
+ private SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
{
String key = getKey( contextId );
LOG.debug("Getting graph for key " + contextId);
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/SDUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/SDUtil.java b/src/main/java/org/apache/directory/fortress/core/impl/SDUtil.java
index 7986f68..635e62b 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/SDUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/SDUtil.java
@@ -19,33 +19,33 @@
*/
package org.apache.directory.fortress.core.impl;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sf.ehcache.search.Attribute;
+import net.sf.ehcache.search.Query;
+import net.sf.ehcache.search.Result;
+import net.sf.ehcache.search.Results;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.ReviewMgr;
import org.apache.directory.fortress.core.ReviewMgrFactory;
import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.ReviewMgr;
-import org.apache.directory.fortress.core.util.Config;
+import org.apache.directory.fortress.core.model.Constraint;
import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.SDSet;
import org.apache.directory.fortress.core.model.Session;
import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserRole;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.fortress.core.util.cache.Cache;
import org.apache.directory.fortress.core.util.cache.CacheMgr;
import org.apache.directory.fortress.core.util.cache.DsdCacheEntry;
-import org.apache.directory.fortress.core.model.Constraint;
-
-import net.sf.ehcache.search.Attribute;
-import net.sf.ehcache.search.Query;
-import net.sf.ehcache.search.Result;
-import net.sf.ehcache.search.Results;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
/**
* This utilty provides functionality necessary for SSD and DSD processing and cannot be called by components outside fortress.
@@ -58,18 +58,33 @@ import java.util.Set;
*/
final class SDUtil
{
- private static final Cache m_dsdCache;
+ private Cache m_dsdCache;
private static final String FORTRESS_DSDS = "fortress.dsd";
- private static final Cache m_ssdCache;
+ private Cache m_ssdCache;
private static final String FORTRESS_SSDS = "fortress.ssd";
- private static final SdP sp = new SdP();
+ private SdP sp;
private static final String IS_DSD_CACHE_DISABLED_PARM = "enable.dsd.cache";
private static final String DSD_NAME = "name";
private static final String EMPTY_ELEMENT = "empty";
private static final String CONTEXT_ID = "contextId";
- static
+ private static volatile SDUtil INSTANCE = null;
+
+ public static SDUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (SDUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new SDUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ private void init()
{
+ sp = new SdP();
+
// Get a reference to the CacheManager Singleton object:
CacheMgr cacheMgr = CacheMgr.getInstance();
// This cache contains a wrapper entry for DSD and is searchable by both DSD and Role name:
@@ -82,8 +97,9 @@ final class SDUtil
* Private constructor
*
*/
- private SDUtil()
+ private SDUtil()
{
+ init();
}
/**
@@ -94,7 +110,7 @@ final class SDUtil
* @throws org.apache.directory.fortress.core.SecurityException
*
*/
- static void validateSSD(UserRole uRole)
+ void validateSSD(UserRole uRole)
throws SecurityException
{
validateSSD(new User(uRole.getUserId()), new Role(uRole.getName()));
@@ -109,7 +125,7 @@ final class SDUtil
* @throws org.apache.directory.fortress.core.SecurityException
*
*/
- static void validateSSD(User user, Role role)
+ void validateSSD(User user, Role role)
throws SecurityException
{
int matchCount;
@@ -156,7 +172,7 @@ final class SDUtil
* @throws org.apache.directory.fortress.core.SecurityException
*
*/
- static void validateDSD(Session session, Constraint role)
+ void validateDSD(Session session, Constraint role)
throws SecurityException
{
// get all activated roles from user's session:
@@ -198,7 +214,7 @@ final class SDUtil
else // Check the parents of activated role for DSD match:
{
// Now pull the activated role's list of parents.
- Set<String> parentSet = RoleUtil.getAscendants(actRole.getName(), session.getContextId());
+ Set<String> parentSet = RoleUtil.getInstance().getAscendants(actRole.getName(), session.getContextId());
// Iterate over the list of parent roles:
for (String parentRole : parentSet)
@@ -228,7 +244,7 @@ final class SDUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com. *
* @throws SecurityException in the event of system or rule violation.
*/
- static void clearDsdCacheEntry(String name, String contextId)
+ void clearDsdCacheEntry(String name, String contextId)
{
Attribute<String> context = m_dsdCache.getSearchAttribute(CONTEXT_ID);
Attribute<String> dsdName = m_dsdCache.getSearchAttribute(DSD_NAME);
@@ -251,7 +267,7 @@ final class SDUtil
* @return un-ordered set of matching DSD's.
* @throws SecurityException in the event of system or rule violation.
*/
- private static Set<SDSet> getDsdCache(String name, String contextId)
+ private Set<SDSet> getDsdCache(String name, String contextId)
throws SecurityException
{
contextId = getContextId(contextId);
@@ -294,7 +310,7 @@ final class SDUtil
* @return un-ordered set of matching DSD's.
* @throws SecurityException in the event of system or rule violation.
*/
- static Set<SDSet> getDsdCache(Set<String> authorizedRoleSet, String contextId)
+ Set<SDSet> getDsdCache(Set<String> authorizedRoleSet, String contextId)
throws SecurityException
{
contextId = getContextId(contextId);
@@ -305,7 +321,7 @@ final class SDUtil
return dsdRetSets;
}
// Was the DSD Cache switched off?
- boolean isCacheDisabled = Config.getBoolean(IS_DSD_CACHE_DISABLED_PARM, false);
+ boolean isCacheDisabled = Config.getInstance().getBoolean(IS_DSD_CACHE_DISABLED_PARM, false);
// If so, get DSD's from LDAP:
if (isCacheDisabled)
{
@@ -357,7 +373,7 @@ final class SDUtil
* @return List of DSD's who have matching Role members.
* @throws SecurityException in the event of system or rule violation.
*/
- private static Set<SDSet> putDsdCache(Set<String> authorizedRoleSet, String contextId)
+ private Set<SDSet> putDsdCache(Set<String> authorizedRoleSet, String contextId)
throws SecurityException
{
contextId = getContextId(contextId);
@@ -415,7 +431,7 @@ final class SDUtil
* @return Set of DSD's who have matching Role member.
* @throws SecurityException in the event of system or rule violation.
*/
- private static Set<SDSet> putDsdCache(String roleName, String contextId)
+ private Set<SDSet> putDsdCache(String roleName, String contextId)
throws SecurityException
{
contextId = getContextId(contextId);
@@ -465,7 +481,7 @@ final class SDUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @throws SecurityException in the event of system or rule violation.
*/
- static void clearSsdCacheEntry(String name, String contextId)
+ void clearSsdCacheEntry(String name, String contextId)
{
contextId = getContextId(contextId);
m_ssdCache.clear(getKey(name, contextId));
@@ -479,7 +495,7 @@ final class SDUtil
* @return List of SSD's who have matching Role member.
* @throws SecurityException in the event of system or rule violation.
*/
- private static List<SDSet> putSsdCache(String name, String contextId)
+ private List<SDSet> putSsdCache(String name, String contextId)
throws SecurityException
{
Role role = new Role(name);
@@ -497,7 +513,7 @@ final class SDUtil
* @return List of SSD's who have matching Role member.
* @throws SecurityException in the event of system or rule violation.
*/
- private static List<SDSet> getSsdCache(String name, String contextId)
+ private List<SDSet> getSsdCache(String name, String contextId)
throws SecurityException
{
List<SDSet> ssdSets = (List<SDSet>) m_ssdCache.get(getKey(name, contextId));
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java
index 53bb1a7..7ed5ad7 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java
@@ -39,17 +39,17 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
-import org.apache.directory.fortress.core.model.SDSet;
-import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.fortress.core.CreateException;
import org.apache.directory.fortress.core.FinderException;
import org.apache.directory.fortress.core.GlobalErrIds;
import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.RemoveException;
import org.apache.directory.fortress.core.UpdateException;
import org.apache.directory.fortress.core.ldap.LdapDataProvider;
+import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.model.Role;
+import org.apache.directory.fortress.core.model.SDSet;
+import org.apache.directory.ldap.client.api.LdapConnection;
/**
@@ -137,6 +137,9 @@ final class SdDAO extends LdapDataProvider
GlobalIds.FT_IID, SD_SET_NM, SchemaConstants.DESCRIPTION_AT, ROLES, SD_SET_CARDINALITY
};
+ public SdDAO() {
+ super();
+ }
/**
* @param entity
@@ -448,7 +451,7 @@ final class SdDAO extends LdapDataProvider
filterbuf.append( ")(" );
// Include any parents target role may have:
- Set<String> roles = RoleUtil.getAscendants( role.getName(), role.getContextId() );
+ Set<String> roles = RoleUtil.getInstance().getAscendants( role.getName(), role.getContextId() );
if ( CollectionUtils.isNotEmpty( roles ) )
{
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/SdP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/SdP.java b/src/main/java/org/apache/directory/fortress/core/impl/SdP.java
index e4362f0..594a1e0 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/SdP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/SdP.java
@@ -58,7 +58,7 @@ public final class SdP
/**
* Get the DAO created:
*/
- private static final SdDAO sdDao = new SdDAO();
+ private SdDAO sdDao;
/**
@@ -66,6 +66,7 @@ public final class SdP
*/
SdP()
{
+ sdDao = new SdDAO();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/SuffixDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/SuffixDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/SuffixDAO.java
index d6f4ba8..5ddd3e5 100644
--- a/src/main/java/org/apache/directory/fortress/core/impl/SuffixDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/SuffixDAO.java
@@ -26,14 +26,14 @@ import org.apache.directory.api.ldap.model.cursor.CursorException;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.fortress.core.CreateException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.RemoveException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.Suffix;
import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.CreateException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.RemoveException;
/**
@@ -80,6 +80,7 @@ final class SuffixDAO extends LdapDataProvider
*/
SuffixDAO()
{
+ super();
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
index eed8bb4..c547fc5 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
@@ -49,10 +49,21 @@ import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.BindResponse;
import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.fortress.core.CreateException;
+import org.apache.directory.fortress.core.FinderException;
+import org.apache.directory.fortress.core.GlobalErrIds;
+import org.apache.directory.fortress.core.GlobalIds;
+import org.apache.directory.fortress.core.PasswordException;
+import org.apache.directory.fortress.core.RemoveException;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.UpdateException;
+import org.apache.directory.fortress.core.ldap.LdapDataProvider;
import org.apache.directory.fortress.core.model.Address;
import org.apache.directory.fortress.core.model.AdminRole;
import org.apache.directory.fortress.core.model.ConstraintUtil;
+import org.apache.directory.fortress.core.model.ObjectFactory;
import org.apache.directory.fortress.core.model.OrgUnit;
+import org.apache.directory.fortress.core.model.PropUtil;
import org.apache.directory.fortress.core.model.PwMessage;
import org.apache.directory.fortress.core.model.Role;
import org.apache.directory.fortress.core.model.Session;
@@ -60,21 +71,10 @@ import org.apache.directory.fortress.core.model.User;
import org.apache.directory.fortress.core.model.UserAdminRole;
import org.apache.directory.fortress.core.model.UserRole;
import org.apache.directory.fortress.core.model.Warning;
-import org.apache.directory.fortress.core.model.PropUtil;
+import org.apache.directory.fortress.core.util.Config;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.fortress.core.CreateException;
-import org.apache.directory.fortress.core.FinderException;
-import org.apache.directory.fortress.core.GlobalErrIds;
-import org.apache.directory.fortress.core.GlobalIds;
-import org.apache.directory.fortress.core.model.ObjectFactory;
-import org.apache.directory.fortress.core.PasswordException;
-import org.apache.directory.fortress.core.RemoveException;
-import org.apache.directory.fortress.core.SecurityException;
-import org.apache.directory.fortress.core.UpdateException;
-import org.apache.directory.fortress.core.util.Config;
-import org.apache.directory.fortress.core.ldap.LdapDataProvider;
/**
@@ -163,14 +163,9 @@ final class UserDAO extends LdapDataProvider
// The Fortress User entity attributes are stored within standard LDAP object classes along with custom auxiliary
// object classes:
- private static final String USER_OBJ_CLASS[] =
- { SchemaConstants.TOP_OC, Config.getProperty( USER_OBJECT_CLASS ),
- USERS_AUX_OBJECT_CLASS_NAME, GlobalIds.PROPS_AUX_OBJECT_CLASS_NAME, GlobalIds
- .FT_MODIFIER_AUX_OBJECT_CLASS_NAME, USERS_EXTENSIBLE_OBJECT,
- // POSIX_ACCOUNT_OBJECT_CLASS_NAME
- };
-
- private static final String objectClassImpl = Config.getProperty( USER_OBJECT_CLASS );
+ private String[] USER_OBJ_CLASS;
+
+ private String objectClassImpl;
private static final String SYSTEM_USER = "ftSystem";
/**
@@ -222,14 +217,23 @@ final class UserDAO extends LdapDataProvider
private static String[] authnAtrs = null;
private static String[] defaultAtrs = null;
- static
+ private void init()
{
- LOG.debug( "GlobalIds.IS_OPENLDAP: " + GlobalIds.IS_OPENLDAP );
- LOG.debug( "GlobalIds.IS_OPENLDAP ? OPENLDAP_PW_RESET : null: " + ( GlobalIds.IS_OPENLDAP ? OPENLDAP_PW_RESET
+ objectClassImpl = Config.getInstance().getProperty( USER_OBJECT_CLASS );
+
+ USER_OBJ_CLASS = new String[]
+ { SchemaConstants.TOP_OC, Config.getInstance().getProperty( USER_OBJECT_CLASS ),
+ USERS_AUX_OBJECT_CLASS_NAME, GlobalIds.PROPS_AUX_OBJECT_CLASS_NAME, GlobalIds
+ .FT_MODIFIER_AUX_OBJECT_CLASS_NAME, USERS_EXTENSIBLE_OBJECT,
+ // POSIX_ACCOUNT_OBJECT_CLASS_NAME
+ };
+
+ LOG.debug( "GlobalIds.IS_OPENLDAP: " + GlobalIds.getInstance().IS_OPENLDAP );
+ LOG.debug( "GlobalIds.IS_OPENLDAP ? OPENLDAP_PW_RESET : null: " + ( GlobalIds.getInstance().IS_OPENLDAP ? OPENLDAP_PW_RESET
: null ) );
- LOG.debug( "GlobalIds.IS_OPENLDAP: " + GlobalIds.IS_OPENLDAP );
+ LOG.debug( "GlobalIds.IS_OPENLDAP: " + GlobalIds.getInstance().IS_OPENLDAP );
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
// This default set of attributes contains all and is used for search operations.
defaultAtrs = new String[]
@@ -395,6 +399,11 @@ final class UserDAO extends LdapDataProvider
{ GlobalIds.USER_ADMINROLE_DATA };
+ public UserDAO() {
+ super();
+ init();
+ }
+
/**
* @param entity
* @return
@@ -488,7 +497,7 @@ final class UserDAO extends LdapDataProvider
myEntry.add( SYSTEM_USER, entity.isSystem().toString().toUpperCase() );
}
- if ( GlobalIds.IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
+ if ( GlobalIds.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
{
String pwdPolicyDn = GlobalIds.POLICY_NODE_TYPE + "=" + entity.getPwPolicy() + "," + getRootDn(
entity.getContextId(), GlobalIds.PPOLICY_ROOT );
@@ -593,7 +602,7 @@ final class UserDAO extends LdapDataProvider
entity.getTitle() ) );
}
- if ( GlobalIds.IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
+ if ( GlobalIds.getInstance().IS_OPENLDAP && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
{
String szDn = GlobalIds.POLICY_NODE_TYPE + "=" + entity.getPwPolicy() + "," + getRootDn( entity
.getContextId(), GlobalIds.PPOLICY_ROOT );
@@ -1047,7 +1056,7 @@ final class UserDAO extends LdapDataProvider
case CHANGE_AFTER_RESET:
// Don't throw exception if authenticating in J2EE Realm - The Web application must
// give user a chance to modify their password.
- if ( !GlobalIds.IS_REALM )
+ if ( !GlobalIds.getInstance().IS_REALM )
{
errMsg = msgHdr + "PASSWORD HAS BEEN RESET BY LDAP_ADMIN_POOL_UID";
rc = GlobalErrIds.USER_PW_RESET;
@@ -1271,7 +1280,7 @@ final class UserDAO extends LdapDataProvider
filterbuf.append( USERS_AUX_OBJECT_CLASS_NAME );
filterbuf.append( ")(" );
- Set<String> roles = RoleUtil.getDescendants( role.getName(), role.getContextId() );
+ Set<String> roles = RoleUtil.getInstance().getDescendants( role.getName(), role.getContextId() );
if ( CollectionUtils.isNotEmpty( roles ) )
{
@@ -1703,7 +1712,7 @@ final class UserDAO extends LdapDataProvider
modify( ld, userDn, mods );
// This modify update audit attributes on the User entry (if enabled):
- if ( GlobalIds.IS_OPENLDAP && ! GlobalIds.IS_AUDIT_DISABLED )
+ if ( GlobalIds.getInstance().IS_OPENLDAP && ! GlobalIds.getInstance().IS_AUDIT_DISABLED )
{
mods = new ArrayList<>();
modify( ld, userDn, mods, entity );
@@ -2079,7 +2088,7 @@ final class UserDAO extends LdapDataProvider
entity.addProperties( PropUtil.getProperties( getAttributes( entry, GlobalIds.PROPS ) ) );
- if ( GlobalIds.IS_OPENLDAP )
+ if ( GlobalIds.getInstance().IS_OPENLDAP )
{
szBoolean = getAttribute( entry, OPENLDAP_PW_RESET );
if ( szBoolean != null && szBoolean.equalsIgnoreCase( "true" ) )
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserP.java b/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
index f5be195..f089540 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserP.java
@@ -390,7 +390,7 @@ final class UserP
throw new PasswordException( session.getErrorId(), info );
}
- VUtil.validateConstraints( session, VUtil.ConstraintType.USER, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false );
return session;
}
@@ -453,7 +453,7 @@ final class UserP
// Create the impl session without authentication of password.
session = createSessionTrusted( user );
// Check user temporal constraints. This op usually performed during authentication.
- VUtil.validateConstraints( session, VUtil.ConstraintType.USER, false );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.USER, false );
}
else
{
@@ -480,7 +480,7 @@ final class UserP
}
}
// Check role temporal constraints + activate roles:
- VUtil.validateConstraints( session, VUtil.ConstraintType.ROLE, true );
+ VUtil.getInstance().validateConstraints( session, VUtil.ConstraintType.ROLE, true );
return session;
}
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/908a0734/src/main/java/org/apache/directory/fortress/core/impl/UsoUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UsoUtil.java b/src/main/java/org/apache/directory/fortress/core/impl/UsoUtil.java
index 6bec8f1..93939ee 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UsoUtil.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UsoUtil.java
@@ -62,17 +62,33 @@ import org.slf4j.LoggerFactory;
*/
final class UsoUtil
{
- private static final Cache usoCache;
- private static final OrgUnitP orgUnitP = new OrgUnitP();
+ private Cache usoCache;
+ private OrgUnitP orgUnitP;
private static final String CLS_NM = UsoUtil.class.getName();
private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
+ private static volatile UsoUtil INSTANCE = null;
+
+ public static UsoUtil getInstance() {
+ if(INSTANCE == null) {
+ synchronized (UsoUtil.class) {
+ if(INSTANCE == null){
+ INSTANCE = new UsoUtil();
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+
/**
* Initialize the User OU hierarchies. This will read the {@link org.apache.directory.fortress.core.model.Hier} data set from ldap and load into
* the JGraphT simple digraph that referenced statically within this class.
*/
- static
+ private void init()
{
+ orgUnitP = new OrgUnitP();
+
CacheMgr cacheMgr = CacheMgr.getInstance();
usoCache = cacheMgr.getCache( "fortress.uso" );
}
@@ -83,6 +99,7 @@ final class UsoUtil
*/
private UsoUtil()
{
+ init();
}
/**
@@ -91,7 +108,7 @@ final class UsoUtil
* @param name {@link org.apache.directory.fortress.core.model.OrgUnit#name} on 'ftOrgUnit' object class.
* @return Set of names of descendants {@link org.apache.directory.fortress.core.model.OrgUnit}s of given parent.
*/
- static Set<String> getDescendants( String name, String contextId )
+ Set<String> getDescendants( String name, String contextId )
{
return HierUtil.getDescendants( name, getGraph( contextId ) );
}
@@ -103,7 +120,7 @@ final class UsoUtil
* @param name maps to logical {@link org.apache.directory.fortress.core.model.OrgUnit#name} on 'ftOrgUnit' object class.
* @return Set of ou names that are ascendants of given child.
*/
- static Set<String> getAscendants( String name, String contextId )
+ Set<String> getAscendants( String name, String contextId )
{
return HierUtil.getAscendants( name, getGraph( contextId ) );
}
@@ -115,7 +132,7 @@ final class UsoUtil
* @param name {@link org.apache.directory.fortress.core.model.OrgUnit#name} maps on 'ftOrgUnit' object class.
* @return Set of names of children {@link org.apache.directory.fortress.core.model.OrgUnit}s of given parent.
*/
- public static Set<String> getChildren( String name, String contextId )
+ public Set<String> getChildren( String name, String contextId )
{
return HierUtil.getChildren( name, getGraph( contextId ) );
}
@@ -127,7 +144,7 @@ final class UsoUtil
* @param name maps to logical {@link org.apache.directory.fortress.core.model.OrgUnit#name} on 'ftOrgUnit' object class.
* @return Set of ou names that are parents of given child.
*/
- static Set<String> getParents( String name, String contextId )
+ Set<String> getParents( String name, String contextId )
{
return HierUtil.getParents( name, getGraph( contextId ) );
}
@@ -139,7 +156,7 @@ final class UsoUtil
* @param name maps to logical {@link org.apache.directory.fortress.core.model.OrgUnit#name} on 'ftOrgUnit' object class.
* @return int value contains the number of children of a given parent ou.
*/
- static int numChildren( String name, String contextId )
+ int numChildren( String name, String contextId )
{
return HierUtil.numChildren( name, getGraph( contextId ) );
}
@@ -151,7 +168,7 @@ final class UsoUtil
* @param ous contains list of {@link org.apache.directory.fortress.core.model.OrgUnit}s.
* @return contains Set of all descendants.
*/
- static Set<String> getInherited( List<OrgUnit> ous, String contextId )
+ Set<String> getInherited( List<OrgUnit> ous, String contextId )
{
// create Set with case insensitive comparator:
Set<String> iOUs = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
@@ -192,7 +209,7 @@ final class UsoUtil
* @throws org.apache.directory.fortress.core.ValidationException
* in the event it fails one of the 3 checks.
*/
- static void validateRelationship( OrgUnit child, OrgUnit parent, boolean mustExist )
+ void validateRelationship( OrgUnit child, OrgUnit parent, boolean mustExist )
throws ValidationException
{
HierUtil.validateRelationship( getGraph( child.getContextId() ), child.getName(), parent.getName(), mustExist );
@@ -208,7 +225,7 @@ final class UsoUtil
* @param op used to pass the ldap op {@link org.apache.directory.fortress.core.model.Hier.Op#ADD}, {@link org.apache.directory.fortress.core.model.Hier.Op#MOD}, {@link org.apache.directory.fortress.core.model.Hier.Op#REM}
* @throws org.apache.directory.fortress.core.SecurityException in the event of a system error.
*/
- static void updateHier( String contextId, Relationship relationship, Hier.Op op ) throws SecurityException
+ void updateHier( String contextId, Relationship relationship, Hier.Op op ) throws SecurityException
{
HierUtil.updateHier( getGraph( contextId ), relationship, op );
}
@@ -221,7 +238,7 @@ final class UsoUtil
* @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
* @return handle to simple digraph containing user ou hierarchies.
*/
- private static synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
+ private synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
{
Hier inHier = new Hier( Hier.Type.ROLE );
inHier.setContextId( contextId );
@@ -254,7 +271,7 @@ final class UsoUtil
*
* @return handle to simple digraph containing user ou hierarchies.
*/
- private static SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
+ private SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
{
String key = getKey( contextId );
LOG.debug("Getting graph for key " + contextId);
@@ -273,7 +290,7 @@ final class UsoUtil
}
- private static String getKey( String contextId )
+ private String getKey( String contextId )
{
String key = HierUtil.Type.USO.toString();
if ( StringUtils.isNotEmpty( contextId ) && !contextId.equalsIgnoreCase( GlobalIds.NULL ) )