tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlmonte...@apache.org
Subject tomee git commit: TOMEE-1509 Fix bad PropertyPlaceHolderHelper
Date Fri, 06 Feb 2015 23:13:55 GMT
Repository: tomee
Updated Branches:
  refs/heads/develop 4127ae53f -> 2d4b68005


TOMEE-1509 Fix bad PropertyPlaceHolderHelper


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2d4b6800
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2d4b6800
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2d4b6800

Branch: refs/heads/develop
Commit: 2d4b68005b134685740584726bfddee39647a8af
Parents: 4127ae5
Author: Jean-Louis Monteiro <jeanouii@gmail.com>
Authored: Sat Feb 7 00:13:48 2015 +0100
Committer: Jean-Louis Monteiro <jeanouii@gmail.com>
Committed: Sat Feb 7 00:13:48 2015 +0100

----------------------------------------------------------------------
 .../openejb/util/PropertyPlaceHolderHelper.java      |  2 +-
 .../apache/openejb/util/PropertyPlaceHolderTest.java |  8 ++++++++
 .../apache/openejb/util/ReversePasswordCipher.java   | 15 +++++++++++++++
 .../org.apache.openejb.cipher.PasswordCipher/reverse |  1 +
 4 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2d4b6800/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
b/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
index d1732b2..adb13aa 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/PropertyPlaceHolderHelper.java
@@ -78,7 +78,7 @@ public final class PropertyPlaceHolderHelper {
                     throw new IllegalArgumentException(e);
                 }
             }
-            return cipher.decrypt(replace.substring(CIPHER_PREFIX.length() + algo.length()).toCharArray());
+            return cipher.decrypt(replace.substring(CIPHER_PREFIX.length() + algo.length()
+ 1).toCharArray());
         }
         return replace;
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2d4b6800/container/openejb-core/src/test/java/org/apache/openejb/util/PropertyPlaceHolderTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/util/PropertyPlaceHolderTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/util/PropertyPlaceHolderTest.java
index af19f7a..b23ff0a 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/util/PropertyPlaceHolderTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/util/PropertyPlaceHolderTest.java
@@ -39,6 +39,14 @@ public class PropertyPlaceHolderTest {
     }
 
     @Test
+    public void tomee1509() {
+        final String expected = "shuttt don't tell!";
+        final char[] encoded = new ReversePasswordCipher().encrypt(expected);
+        assertEquals(expected, PropertyPlaceHolderHelper.simpleValue("cipher:reverse:" +
new String(encoded)));
+        assertEquals(expected, PropertyPlaceHolderHelper.simpleValue("cipher:" + ReversePasswordCipher.class.getName()
+ ":" + new String(encoded)));
+    }
+
+    @Test
     public void simpleReplace() {
         SystemInstance.get().setProperty("PropertyPlaceHolderTest", "ok");
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/2d4b6800/container/openejb-core/src/test/java/org/apache/openejb/util/ReversePasswordCipher.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/util/ReversePasswordCipher.java
b/container/openejb-core/src/test/java/org/apache/openejb/util/ReversePasswordCipher.java
new file mode 100644
index 0000000..2eee3dd
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/util/ReversePasswordCipher.java
@@ -0,0 +1,15 @@
+package org.apache.openejb.util;
+
+import org.apache.openejb.cipher.PasswordCipher;
+
+public class ReversePasswordCipher implements PasswordCipher {
+    @Override
+    public char[] encrypt(final String s) {
+        return new StringBuffer().append(s).reverse().toString().toCharArray();
+    }
+
+    @Override
+    public String decrypt(char[] chars) {
+        return new StringBuffer().append(chars).reverse().toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/2d4b6800/container/openejb-core/src/test/resources/META-INF/org.apache.openejb.cipher.PasswordCipher/reverse
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/resources/META-INF/org.apache.openejb.cipher.PasswordCipher/reverse
b/container/openejb-core/src/test/resources/META-INF/org.apache.openejb.cipher.PasswordCipher/reverse
new file mode 100644
index 0000000..8c7ea94
--- /dev/null
+++ b/container/openejb-core/src/test/resources/META-INF/org.apache.openejb.cipher.PasswordCipher/reverse
@@ -0,0 +1 @@
+org.apache.openejb.util.ReversePasswordCipher


Mime
View raw message