directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cp...@apache.org
Subject [10/15] directory-fortress-core git commit: made globalIds not a singleton and moved instance vars into config class
Date Thu, 05 May 2016 13:49:27 GMT
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 <clp207@psu.edu>
Authored: Mon May 2 14:13:20 2016 -0400
Committer: clp207 <clp207@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" ) );


Mime
View raw message