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:19 UTC
[02/15] directory-fortress-core git commit: refactored to not use
static initialization blocks
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" ) );