cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r647195 - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConfigSaver.java cayenne-modeler/src/main/resources/pref/HSQLNode.driver.xml
Date Fri, 11 Apr 2008 15:21:30 GMT
Author: aadamchik
Date: Fri Apr 11 08:21:28 2008
New Revision: 647195

URL: http://svn.apache.org/viewvc?rev=647195&view=rev
Log:
preventing ConfigSaver from storing defaults for a number of 3.0 password encoding attributes

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/pref/HSQLNode.driver.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConfigSaver.java?rev=647195&r1=647194&r2=647195&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
Fri Apr 11 08:21:28 2008
@@ -26,6 +26,7 @@
 import java.io.PrintWriter;
 import java.util.Iterator;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.project.Project;
 import org.apache.cayenne.util.Util;
@@ -159,10 +160,12 @@
     }
 
     private String attribute(String key, String value) {
-        if (value != null)
+        if (value != null) {
             return " " + key + "=\"" + Util.encodeXmlAttribute(value) + "\"";
-        else
+        }
+        else {
             return "";
+        }
     }
 
     /**
@@ -185,17 +188,18 @@
                 + "/>");
 
         pw.print("\t<login");
-        
+
         if (info.getUserName() != null) {
             pw.print(attribute("userName", info.getUserName()));
         }
 
         if (info.getPasswordLocation().equals(DataSourceInfo.PASSWORD_LOCATION_MODEL)) {
             PasswordEncoding encoder = info.getPasswordEncoder();
-            if (encoder != null)
+            if (encoder != null) {
                 pw.print(attribute("password", encoder.encodePassword(
                         info.getPassword(),
                         info.getPasswordEncoderKey())));
+            }
         }
         else if (info.getPasswordLocation().equals(
                 DataSourceInfo.PASSWORD_LOCATION_CLASSPATH)) {
@@ -212,19 +216,39 @@
                                 .getPasswordEncoderKey()));
                         out.close();
                     }
-                    catch (FileNotFoundException exception) {
-                        // TODO Auto-generated catch block
-                        exception.printStackTrace();
+                    catch (FileNotFoundException ex) {
+                        throw new CayenneRuntimeException(ex);
                     }
                 }
             }
         }
 
-        pw.println(attribute("encoderClass", info.getPasswordEncoderClass())
-                + attribute("encoderKey", info.getPasswordEncoderKey())
-                + attribute("passwordLocation", info.getPasswordLocation())
-                + attribute("passwordSource", info.getPasswordSource())
-                + "/>");
+        if (info.getPasswordEncoderClass() != null
+                && !PlainTextPasswordEncoder.class.getName().equals(
+                        info.getPasswordEncoderClass())) {
+            pw.print(attribute("encoderClass", info.getPasswordEncoderClass()));
+        }
+
+        if (info.getPasswordEncoderKey() != null
+                && info.getPasswordEncoderKey().length() > 0) {
+            pw.print(attribute("encoderKey", info.getPasswordEncoderKey()));
+        }
+
+        if (info.getPasswordLocation() != null
+                && !info.getPasswordLocation().equals(
+                        DataSourceInfo.PASSWORD_LOCATION_MODEL)) {
+            pw.print(attribute("passwordLocation", info.getPasswordLocation()));
+        }
+
+        // TODO: this is very not nice... we need to clean up the whole DataSourceInfo to
+        // avoid returning arbitrary labels...
+        if (info.getPasswordSource() != null
+                && info.getPasswordSource().length() > 0
+                && !"Not Applicable".equals(info.getPasswordSource())) {
+            pw.print(attribute("passwordSource", info.getPasswordSource()));
+        }
+
+        pw.println("/>");
 
         pw.println("</driver>");
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/pref/HSQLNode.driver.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/pref/HSQLNode.driver.xml?rev=647195&r1=647194&r2=647195&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/pref/HSQLNode.driver.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/pref/HSQLNode.driver.xml
Fri Apr 11 08:21:28 2008
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <driver project-version="3.0" class="org.hsqldb.jdbcDriver">
 	<connectionPool min="1" max="1"/>
-	<login userName="sa" encoderClass="org.apache.cayenne.conf.PlainTextPasswordEncoder"
passwordLocation="model" passwordSource="Not Applicable"/>
+	<login userName="sa"/>
 </driver>



Mime
View raw message