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-163 - fortress.properties is not required
Date Mon, 28 Mar 2016 02:55:00 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master b7fab76f3 -> b5b7df50a


 FC-163 - fortress.properties is not required


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

Branch: refs/heads/master
Commit: b5b7df50ac229bfced63456d605ff1802171486c
Parents: b7fab76
Author: Shawn McKinney <smckinney@apache.org>
Authored: Sun Mar 27 21:46:01 2016 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Sun Mar 27 21:46:01 2016 -0500

----------------------------------------------------------------------
 README-CONFIG.md                                | 13 +++++++--
 .../directory/fortress/core/GlobalIds.java      |  2 ++
 .../directory/fortress/core/impl/ConfigDAO.java |  3 +-
 .../core/ldap/ApacheDsDataProvider.java         |  2 +-
 .../directory/fortress/core/util/Config.java    | 30 +++++++++++++-------
 5 files changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b5b7df50/README-CONFIG.md
----------------------------------------------------------------------
diff --git a/README-CONFIG.md b/README-CONFIG.md
index e1ff9ac..d11ec55 100644
--- a/README-CONFIG.md
+++ b/README-CONFIG.md
@@ -84,14 +84,24 @@ The ant config task, **init-fortress-config**, uses the values found within
the
  * fortress.trust.store.password
  * fortress.trust.store.set.prop
  * fortress.config.realm
+ * fortress.config.root
  * fortress.ldap.server.type
 
+ The minimum system.properties to enable fortress apis to work:
+  * fortress.admin.user
+  * fortress.admin.pw=secret
+  * fortress.config.root=ou=Config,dc=example,dc=com
+
+ If the ldap host and port are not localhost:389 set these two:
+ * fortress.host
+ * fortress.port
+
 ___________________________________________________________________________________
 ## SECTION 5.  Precedence of Artifacts found in the Fortress Configuration Subsystem
 
 This subsystem has been hard wired to the following order:
  1. fortress.properties file - found on the classpath of that name.
- 2. Java system properties - to override any of the 13 properties listed above.
+ 2. Java system properties - to override any of the 14 properties listed above.
  3. LDAP configuration node - found by config coordinates set in the fortress.properties
file itself.
 
 __________________________________________________________________________________
@@ -127,7 +137,6 @@ Or B:
 A refreshes the entire LDAP server DIT, deletes of all entries under the suffix, recreating
the DIT node structure, and re-adding of the config node.
 B just updates the config node with the new values, preserving the other data.
 
-
 ### More notes:
  * Use caution when running the **refreshLDAPData.xml** script.  It deletes all nodes below
the suffix before readding.
  * To change values in a config node, use a general purpose ldapbrowser.  Fortress has config
apis for this (ConfigMgr) to perform CRUD on config data.

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b5b7df50/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 f8e8d3c..51bb710 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalIds.java
@@ -38,6 +38,8 @@ import org.apache.directory.fortress.core.util.Config;
  */
 public final class GlobalIds
 {
+    public static final String CONFIG_ROOT_PARAM = "config.root";
+
     /**
      * Private constructor
      *

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b5b7df50/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
index 107724b..021aa29 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/ConfigDAO.java
@@ -84,8 +84,7 @@ final class ConfigDAO extends ApacheDsDataProvider
 {
     private static final String CLS_NM = ConfigDAO.class.getName();
     private static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
-    private static final String CONFIG_ROOT_PARAM = "config.root";
-    private static final String CONFIG_ROOT_DN = Config.getProperty( CONFIG_ROOT_PARAM );
+    private static final String CONFIG_ROOT_DN = Config.getProperty( GlobalIds.CONFIG_ROOT_PARAM
);
 
     private static final String CONFIG_OBJ_CLASS[] =
         {

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b5b7df50/src/main/java/org/apache/directory/fortress/core/ldap/ApacheDsDataProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ldap/ApacheDsDataProvider.java
b/src/main/java/org/apache/directory/fortress/core/ldap/ApacheDsDataProvider.java
index 673fa16..5158aaa 100644
--- a/src/main/java/org/apache/directory/fortress/core/ldap/ApacheDsDataProvider.java
+++ b/src/main/java/org/apache/directory/fortress/core/ldap/ApacheDsDataProvider.java
@@ -149,7 +149,7 @@ public abstract class ApacheDsDataProvider
     static
     {
         String host = Config.getProperty( GlobalIds.LDAP_HOST, "localhost" );
-        int port = Config.getInt( GlobalIds.LDAP_PORT, 10389 );
+        int port = Config.getInt( GlobalIds.LDAP_PORT, 389 );
         int min = Config.getInt( GlobalIds.LDAP_ADMIN_POOL_MIN, 1 );
         int max = Config.getInt( GlobalIds.LDAP_ADMIN_POOL_MAX, 10 );
         int logmin = Config.getInt( LDAP_LOG_POOL_MIN, 1 );

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/b5b7df50/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 e28238b..fa70fae 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
@@ -66,6 +66,7 @@ public final class Config
     private static final String EXT_TRUST_STORE_PW = "fortress.trust.store.password";
     private static final String EXT_SET_TRUST_STORE_PROP = "fortress.trust.store.set.prop";
     private static final String EXT_CONFIG_REALM = "fortress.config.realm";
+    private static final String EXT_CONFIG_ROOT_DN = "fortress.config.root";
     private static final String EXT_SERVER_TYPE = "fortress.ldap.server.type";
     private static final PropertiesConfiguration config;
     private static final String CLS_NM = Config.class.getName();
@@ -77,20 +78,19 @@ public final class Config
         {
             // Load the system config file.
             URL fUrl = Config.class.getClassLoader().getResource( propFile );
-
+            config = new PropertiesConfiguration();
+            config.setDelimiterParsingDisabled( true );
             if ( fUrl == null )
             {
                 String error = "static init: Error, null cfg file: " + propFile;
-                LOG.error( error );
-                throw new java.lang.RuntimeException( error );
+                LOG.warn( error );
+            }
+            else
+            {
+                LOG.info( "static init: found from: {} path: {}", propFile, fUrl.getPath()
);
+                config.load( fUrl );
+                LOG.info( "static init: loading from: {}", propFile );
             }
-
-            LOG.info( "static init: found from: {} path: {}", propFile, fUrl.getPath() );
-
-            config = new PropertiesConfiguration();
-            config.setDelimiterParsingDisabled( true );
-            config.load( fUrl );
-            LOG.info( "static init: loading from: {}", propFile );
 
             URL fUserUrl = Config.class.getClassLoader().getResource( userPropFile );
             if ( fUserUrl != null )
@@ -104,7 +104,7 @@ public final class Config
             getExternalConfig();
 
             // Retrieve parameters from the config node stored in target LDAP DIT:
-            String realmName = config.getString( GlobalIds.CONFIG_REALM );
+            String realmName = config.getString( GlobalIds.CONFIG_REALM, "DEFAULT" );
             if ( realmName != null && realmName.length() > 0 )
             {
                 LOG.info( "static init: load config realm [{}]", realmName );
@@ -493,6 +493,14 @@ public final class Config
             LOG.info( PREFIX, GlobalIds.CONFIG_REALM, szValue );
         }
 
+        // Check to see if the config realm name has been overridden by a system property:
+        szValue = System.getProperty( EXT_CONFIG_ROOT_DN );
+        if( StringUtils.isNotEmpty( szValue ))
+        {
+            config.setProperty( GlobalIds.CONFIG_ROOT_PARAM, szValue );
+            LOG.info( PREFIX, GlobalIds.CONFIG_ROOT_PARAM, szValue );
+        }
+
         // Check to see if the ldap server type has been overridden by a system property:
         szValue = System.getProperty( EXT_SERVER_TYPE  );
         if( StringUtils.isNotEmpty( szValue ))


Mime
View raw message