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:18:02 GMT
Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x d38423fa6 -> 521ea067a


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/521ea067
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/521ea067
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/521ea067

Branch: refs/heads/tomee-1.7.x
Commit: 521ea067a0cad8171d2f8d10662a523b30e8f4b2
Parents: d38423f
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:17:43 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/521ea067/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 7430482..b3d0283 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
@@ -79,7 +79,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/521ea067/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 1c9a354..cbb51c4 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
@@ -32,6 +32,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/521ea067/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/521ea067/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