You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2013/05/13 22:04:51 UTC

svn commit: r1482056 - in /ofbiz/trunk/framework: base/config/passwords.properties entity/dtd/entity-config.xsd entity/src/org/ofbiz/entity/config/EntityConfigUtil.java

Author: doogie
Date: Mon May 13 20:04:51 2013
New Revision: 1482056

URL: http://svn.apache.org/r1482056
Log:
FEATURE: Allow for passwords in entityengine.xml to come from an
external passwords.properties file; nothing actually uses this yet,
however.

Added:
    ofbiz/trunk/framework/base/config/passwords.properties
Modified:
    ofbiz/trunk/framework/entity/dtd/entity-config.xsd
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java

Added: ofbiz/trunk/framework/base/config/passwords.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/passwords.properties?rev=1482056&view=auto
==============================================================================
--- ofbiz/trunk/framework/base/config/passwords.properties (added)
+++ ofbiz/trunk/framework/base/config/passwords.properties Mon May 13 20:04:51 2013
@@ -0,0 +1,19 @@
+###############################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+###############################################################################
+

Modified: ofbiz/trunk/framework/entity/dtd/entity-config.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/dtd/entity-config.xsd?rev=1482056&r1=1482055&r2=1482056&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/dtd/entity-config.xsd (original)
+++ ofbiz/trunk/framework/entity/dtd/entity-config.xsd Mon May 13 20:04:51 2013
@@ -439,7 +439,8 @@ under the License.
         <xs:attribute type="xs:string" name="jdbc-driver" use="required"/>
         <xs:attribute type="xs:string" name="jdbc-uri" use="required"/>
         <xs:attribute type="xs:string" name="jdbc-username" use="required"/>
-        <xs:attribute type="xs:string" name="jdbc-password" use="required"/>
+        <xs:attribute type="xs:string" name="jdbc-password"/>
+        <xs:attribute type="xs:string" name="jdbc-password-lookup"/>
         <xs:attribute name="isolation-level">
             <xs:simpleType>
                 <xs:restriction base="xs:token">

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java?rev=1482056&r1=1482055&r2=1482056&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java Mon May 13 20:04:51 2013
@@ -25,6 +25,8 @@ import java.util.concurrent.atomic.Atomi
 import org.ofbiz.base.config.GenericConfigException;
 import org.ofbiz.base.config.ResourceLoader;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.entity.GenericEntityConfException;
 import org.ofbiz.entity.GenericEntityException;
@@ -251,6 +253,21 @@ public class EntityConfigUtil {
     }
 
     public static String getJdbcPassword(Element inlineJdbcElement) {
-        return inlineJdbcElement.getAttribute("jdbc-password");
+        String jdbcPassword = inlineJdbcElement.getAttribute("jdbc-password");
+        if (UtilValidate.isNotEmpty(jdbcPassword)) {
+            return jdbcPassword;
+        }
+        String jdbcPasswordLookup = inlineJdbcElement.getAttribute("jdbc-password-lookup");
+        if (UtilValidate.isEmpty(jdbcPasswordLookup)) {
+            Debug.logError("no @jdbc-password or @jdbc-password-lookup specified for inline-jdbc element: %s@%d:%d", module, inlineJdbcElement.getUserData("systemId"), inlineJdbcElement.getUserData("startLine"), inlineJdbcElement.getUserData("startColumn"));
+            return null;
+        }
+        String key = "jdbc-password." + jdbcPasswordLookup;
+        jdbcPassword = UtilProperties.getPropertyValue("passwords.properties", key);
+        if (UtilValidate.isEmpty(jdbcPassword)) {
+            // This is a warning, not an error, as the
+            Debug.logError("Could not find password %s specified for inline-jdbc element: %s@%d:%d", module, key, inlineJdbcElement.getUserData("systemId"), inlineJdbcElement.getUserData("startLine"), inlineJdbcElement.getUserData("startColumn"));
+        }
+        return jdbcPassword;
     }
 }