directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject directory-fortress-core git commit: FC-192 - make config api internals private
Date Mon, 10 Oct 2016 21:10:42 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master ca24fb61f -> fa1d126cf


FC-192 - make config api internals private


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/fa1d126c
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/fa1d126c
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/fa1d126c

Branch: refs/heads/master
Commit: fa1d126cfd79bd990e2f05fb18579739056ad746
Parents: ca24fb6
Author: Shawn McKinney <smckinney@apache.org>
Authored: Mon Oct 10 15:49:12 2016 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Mon Oct 10 15:49:12 2016 -0500

----------------------------------------------------------------------
 .../fortress/core/AccelMgrFactory.java          |   7 --
 .../fortress/core/AccessMgrFactory.java         |   7 --
 .../fortress/core/AdminMgrFactory.java          |   7 --
 .../fortress/core/AuditMgrFactory.java          |   7 --
 .../fortress/core/DelAccessMgrFactory.java      |   7 --
 .../fortress/core/DelAdminMgrFactory.java       |   8 --
 .../fortress/core/DelReviewMgrFactory.java      |   7 --
 .../fortress/core/GroupMgrFactory.java          |   8 --
 .../fortress/core/PwPolicyMgrFactory.java       |   7 --
 .../fortress/core/ReviewMgrFactory.java         |   7 --
 .../directory/fortress/core/util/Config.java    | 101 ++++++++-----------
 11 files changed, 42 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
index cfe5a65..601d306 100644
--- a/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccelMgrFactory.java
@@ -71,13 +71,6 @@ public final class AccelMgrFactory
         {
             accelMgr = (AccelMgr) ClassUtil.createInstance(accelClassName);
         }
-        
-        if(accelMgr instanceof AccelMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
 
         accelMgr.setContextId(contextId);
         return accelMgr;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 bbfff04..76f057d 100755
--- a/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AccessMgrFactory.java
@@ -81,13 +81,6 @@ public final class AccessMgrFactory
         {
             accessMgr = (AccessMgr) ClassUtil.createInstance(accessClassName);
         }
-        
-        if(accessMgr instanceof AccessMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
 
         accessMgr.setContextId(contextId);
         return accessMgr;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 1820db6..feca277 100755
--- a/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AdminMgrFactory.java
@@ -85,13 +85,6 @@ public final class AdminMgrFactory
             adminMgr = (AdminMgr) ClassUtil.createInstance(adminClassName);
         }
 
-        if(adminMgr instanceof AdminMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
-        
         adminMgr.setContextId(contextId);
         return adminMgr;
     }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 1f2c26f..9fe3513 100755
--- a/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/AuditMgrFactory.java
@@ -83,13 +83,6 @@ public final class AuditMgrFactory
         {
             auditMgr = (AuditMgr) ClassUtil.createInstance(auditClassName);
         }
-        
-        if(auditMgr instanceof AuditMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
 
         auditMgr.setContextId(contextId);
         return auditMgr;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 18377f7..5486f36 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAccessMgrFactory.java
@@ -83,13 +83,6 @@ public final class DelAccessMgrFactory
         {
             accessMgr = (DelAccessMgr) ClassUtil.createInstance(accessClassName);
         }
-        
-        if(accessMgr instanceof DelAccessMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
 
         accessMgr.setContextId(contextId);
         return accessMgr;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 02594d9..36dd0f2 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelAdminMgrFactory.java
@@ -85,15 +85,7 @@ public final class DelAdminMgrFactory
             delAdminMgr = (DelAdminMgr) ClassUtil.createInstance( dAdminClassName );
         }
 
-        if(delAdminMgr instanceof DelAdminMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
-        
         delAdminMgr.setContextId(contextId);
-        
         return delAdminMgr;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 3c3fbd4..bdc93a0 100755
--- a/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/DelReviewMgrFactory.java
@@ -81,13 +81,6 @@ public final class DelReviewMgrFactory
         {
             delReviewMgr = (DelReviewMgr) ClassUtil.createInstance(dReviewClassName);
         }
-        
-        if(delReviewMgr instanceof DelReviewMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
 
         delReviewMgr.setContextId(contextId);
         return delReviewMgr;

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java b/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
index 6a880bb..8776da8 100755
--- a/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/GroupMgrFactory.java
@@ -38,7 +38,6 @@ import org.apache.directory.fortress.core.util.VUtil;
 public final class GroupMgrFactory
 {    
     private static final String CLS_NM = GroupMgrFactory.class.getName();
-    private static final String CREATE_INSTANCE_METHOD = CLS_NM + ".createInstance";
 
     /**
      * Prevent instantiation.
@@ -91,13 +90,6 @@ public final class GroupMgrFactory
             groupMgr = (GroupMgr) ClassUtil.createInstance( groupClassName );
         }
 
-        if(groupMgr instanceof GroupMgrImpl){
-            Config cfg = Config.getInstance();
-            if(!cfg.isRemoteConfigLoaded()){
-                cfg.loadRemoteConfig();
-            }
-        }
-
         groupMgr.setContextId(contextId);
         return groupMgr;
     }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 06cc2e2..aebebb6 100755
--- a/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/PwPolicyMgrFactory.java
@@ -83,13 +83,6 @@ public final class PwPolicyMgrFactory
             policyMgr = (PwPolicyMgr) ClassUtil.createInstance(policyClassName);
         }
 
-        if(policyMgr instanceof PwPolicyMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
-        
         policyMgr.setContextId(contextId);
         return policyMgr;
     }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 e15249e..c173536 100755
--- a/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
+++ b/src/main/java/org/apache/directory/fortress/core/ReviewMgrFactory.java
@@ -83,13 +83,6 @@ public final class ReviewMgrFactory
             reviewMgr = ( ReviewMgr ) ClassUtil.createInstance(reviewClassName);
         }
 
-        if(reviewMgr instanceof ReviewMgrImpl){
-        	Config cfg = Config.getInstance();
-        	if(!cfg.isRemoteConfigLoaded()){
-        		cfg.loadRemoteConfig();
-        	}
-        }
-        
         reviewMgr.setContextId(contextId);
         return reviewMgr;
     }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/fa1d126c/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 6aa2639..cb3da9f 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
@@ -72,21 +72,6 @@ public final class Config
     private static final String EXT_SERVER_TYPE = "fortress.ldap.server.type";
 
     private boolean remoteConfigLoaded = false;
-    private boolean restEnabled;
-    private boolean auditDisabled;
-    private boolean openldap;
-    /**
-     * This constant is used during authentication to determine if runtime is security realm.
 If IS_REALM == true,
-     * the authentication module will not throw SecurityException on password resets.  This
is to enable the authentication
-     * event to succeed allowing the application to prompt user to change their password.
-     */
-    private boolean realm;
-    /**
-     * Fortress stores complex attribute types within a single attribute in ldap.  Usually
a delimiter of '$' is used for string tokenization.
-     * format: {@code part1$part2$part3....}  Stored in fortress.properties as 'attr.delimiter=$'
-     */
-    private String delimiter;
-
     private static volatile Config sINSTANCE = null;
 
     public static Config getInstance()
@@ -98,12 +83,28 @@ public final class Config
                 if(sINSTANCE == null)
                 {
                     sINSTANCE = new Config();
+                    if( !sINSTANCE.isRemoteConfigLoaded() )
+                    {
+                        sINSTANCE.loadRemoteConfig();
+                    }
                 }
             }
         }
         return sINSTANCE;
     }
 
+    /**
+     * Private constructor
+     *
+     */
+    private Config()
+    {
+        // Load from properties file:
+        loadLocalConfig();
+        // load the system property overrides:
+        getExternalConfig();
+    }
+
     private void loadLocalConfig()
     {
         try
@@ -129,12 +130,7 @@ public final class Config
                 LOG.info( "static init: found user properties from: {} path: {}", USER_PROP_FILE,
fUserUrl.getPath() );
                 config.load( fUserUrl );
             }
-
-            restEnabled = ( ( getProperty( GlobalIds.ENABLE_REST ) != null ) && (
getProperty( GlobalIds.ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
-
-            // Check to see if any of the ldap connection parameters have been overridden:
-            getExternalConfig();
-        }
+       }
         catch ( org.apache.commons.configuration.ConfigurationException ex )
         {
             String error = "static init: Error loading from cfg file: [" + PROP_FILE
@@ -266,7 +262,7 @@ public final class Config
         }
     }
 
-    public void loadRemoteConfig()
+    private void loadRemoteConfig()
     {
         try
         {
@@ -291,7 +287,6 @@ public final class Config
                 LdapUtil.getInstance().setLdapfilterSizeFound(ldapfilterSizeFound);
                 LdapUtil.getInstance().setLdapMetaChars( loadLdapEscapeChars() );
                 LdapUtil.getInstance().setLdapReplVals( loadValidLdapVals() );
-
                 try
                 {
                     String lenProp = getProperty( GlobalIds.LDAP_FILTER_SIZE_PROP );
@@ -302,17 +297,9 @@ public final class Config
                 }
                 catch ( java.lang.NumberFormatException nfe )
                 {
-                    //ignore
+                    String error = "loadRemoteConfig caught NumberFormatException=" + nfe;
+                    LOG.warn( error );
                 }
-
-                auditDisabled = ( ( getProperty( GlobalIds.DISABLE_AUDIT ) != null ) &&
( getProperty( GlobalIds.DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
-
-                realm = GlobalIds.REALM_TYPE.equalsIgnoreCase( getProperty( GlobalIds.AUTHENTICATION_TYPE
) );
-
-                openldap = ( ( getProperty( GlobalIds.SERVER_TYPE ) != null ) &&
( getProperty( GlobalIds.SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
-
-                delimiter = getProperty( "attr.delimiter", "$" );
-
                 remoteConfigLoaded = true;
             }
             else
@@ -329,15 +316,6 @@ public final class Config
         }
     }
 
-    /**
-     * Private constructor
-     *
-     */
-    private Config()
-    {
-        loadLocalConfig();
-    }
-
     private char[] loadLdapEscapeChars()
     {
         char[] ldapMetaChars = new char[LdapUtil.getInstance().getLdapFilterSize()];
@@ -620,27 +598,32 @@ public final class Config
         return props;
     }
 
-    public boolean isRemoteConfigLoaded() {
-        return remoteConfigLoaded;
+    public boolean isRestEnabled()
+    {
+        return ( ( getProperty( GlobalIds.ENABLE_REST ) != null ) && ( getProperty(
GlobalIds.ENABLE_REST ).equalsIgnoreCase( "true" ) ) );
     }
-
-    public boolean isRestEnabled() {
-        return restEnabled;
+    /**
+     * 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 getDelimiter()
+    {
+        return getProperty( "attr.delimiter", "$" );
     }
-
-    public boolean isAuditDisabled() {
-        return auditDisabled;
+    public boolean isAuditDisabled()
+    {
+        return ( ( getProperty( GlobalIds.DISABLE_AUDIT ) != null ) && ( getProperty(
GlobalIds.DISABLE_AUDIT ).equalsIgnoreCase( "true" ) ) );
     }
-
-    public boolean isOpenldap() {
-        return openldap;
+    public boolean isOpenldap()
+    {
+        return ( ( getProperty( GlobalIds.SERVER_TYPE ) != null ) && ( getProperty(
GlobalIds.SERVER_TYPE ).equalsIgnoreCase( "openldap" ) ) );
     }
-
-    public boolean isRealm() {
-        return realm;
+    public boolean isRealm()
+    {
+        return GlobalIds.REALM_TYPE.equalsIgnoreCase( getProperty( GlobalIds.AUTHENTICATION_TYPE
) );
     }
-
-    public String getDelimiter() {
-        return delimiter;
+    private boolean isRemoteConfigLoaded()
+    {
+        return remoteConfigLoaded;
     }
 }
\ No newline at end of file


Mime
View raw message