cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r490048 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/conf/ConfigSaver.java main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java test/java/org/apache/cayenne/conf/ConfigSaverTest.java
Date Sun, 24 Dec 2006 17:14:07 GMT
Author: aadamchik
Date: Sun Dec 24 09:14:06 2006
New Revision: 490048

URL: http://svn.apache.org/viewvc?view=rev&rev=490048
Log:
CAY-642: Add support for encrypted JDBC passwords
(fixing build errors)

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/conf/ConfigSaverTest.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/ConfigSaver.java?view=diff&rev=490048&r1=490047&r2=490048
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/ConfigSaver.java
Sun Dec 24 09:14:06 2006
@@ -186,42 +186,43 @@
 
         if (info.getUserName() != null) {
             pw.print("\t<login" + attribute("userName", info.getUserName()));
+        }
 
-            if (info.getPasswordLocation().equals(DataSourceInfo.PASSWORD_LOCATION_MODEL))
{
+        if (info.getPasswordLocation().equals(DataSourceInfo.PASSWORD_LOCATION_MODEL)) {
+            PasswordEncoding encoder = info.getPasswordEncoder();
+            if (encoder != null)
+                pw.print(attribute("password", encoder.encodePassword(
+                        info.getPassword(),
+                        info.getPasswordEncoderSalt())));
+        }
+        else if (info.getPasswordLocation().equals(
+                DataSourceInfo.PASSWORD_LOCATION_CLASSPATH)) {
+            if (info.getPasswordSource() != null) {
+                File passwordFile = new File(project.getProjectDirectory()
+                        + File.separator
+                        + info.getPasswordSource());
                 PasswordEncoding encoder = info.getPasswordEncoder();
-                if (encoder != null)
-                    pw.print(attribute("password", encoder.encodePassword(info
-                            .getPassword(), info.getPasswordEncoderSalt())));
-            }
-            else if (info.getPasswordLocation().equals(
-                    DataSourceInfo.PASSWORD_LOCATION_CLASSPATH)) {
-                if (info.getPasswordSource() != null) {
-                    File passwordFile = new File(project.getProjectDirectory()
-                            + File.separator
-                            + info.getPasswordSource());
-                    PasswordEncoding encoder = info.getPasswordEncoder();
-                    if (encoder != null && passwordFile != null) {
-                        try {
-                            PrintStream out = new PrintStream(new FileOutputStream(
-                                    passwordFile));
-                            out.print(encoder.encodePassword(info.getPassword(), info
-                                    .getPasswordEncoderSalt()));
-                            out.close();
-                        }
-                        catch (FileNotFoundException exception) {
-                            // TODO Auto-generated catch block
-                            exception.printStackTrace();
-                        }
+                if (encoder != null && passwordFile != null) {
+                    try {
+                        PrintStream out = new PrintStream(new FileOutputStream(
+                                passwordFile));
+                        out.print(encoder.encodePassword(info.getPassword(), info
+                                .getPasswordEncoderSalt()));
+                        out.close();
+                    }
+                    catch (FileNotFoundException exception) {
+                        // TODO Auto-generated catch block
+                        exception.printStackTrace();
                     }
                 }
             }
-
-            pw.println(attribute("encoderClass", info.getPasswordEncoderClass())
-                    + attribute("encoderSalt", info.getPasswordEncoderSalt())
-                    + attribute("passwordLocation", info.getPasswordLocation())
-                    + attribute("passwordSource", info.getPasswordSource())
-                    + "/>");
         }
+
+        pw.println(attribute("encoderClass", info.getPasswordEncoderClass())
+                + attribute("encoderSalt", info.getPasswordEncoderSalt())
+                + attribute("passwordLocation", info.getPasswordLocation())
+                + attribute("passwordSource", info.getPasswordSource())
+                + "/>");
 
         pw.println("</driver>");
     }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java?view=diff&rev=490048&r1=490047&r2=490048
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
Sun Dec 24 09:14:06 2006
@@ -307,13 +307,14 @@
 
             // Replace {} in passwordSource with encoderSalt -- useful for EXECUTABLE &
             // URL options
-            if (encoderSalt != null)
-                passwordSource = passwordSource.replace("\\{\\}", encoderSalt);
+            if (encoderSalt != null) {
+                passwordSource = passwordSource.replaceAll("\\{\\}", encoderSalt);
+            }
 
             PasswordEncoding passwordEncoder = driverInfo.getPasswordEncoder();
 
             if (passwordLocation != null) // New style model (v1.2), process extra
-                                            // locations
+            // locations
             {
                 if (passwordLocation.equals(DataSourceInfo.PASSWORD_LOCATION_CLASSPATH))
{
                     URL url = parentConfiguration.getResourceLocator().findResource(

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/conf/ConfigSaverTest.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/conf/ConfigSaverTest.java?view=diff&rev=490048&r1=490047&r2=490048
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/conf/ConfigSaverTest.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/conf/ConfigSaverTest.java
Sun Dec 24 09:14:06 2006
@@ -73,7 +73,7 @@
 		StringWriter str = new StringWriter();
 		PrintWriter out = new PrintWriter(str);
 
-	    saver.storeDataNode(out, info);
+	    saver.storeDataNode(out, null, info);
 
 		out.close();
 		str.close();



Mime
View raw message