camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject camel git commit: CAMEL-7849 support encrypted properties inside and outside <camelContext>
Date Thu, 09 Apr 2015 14:25:34 GMT
Repository: camel
Updated Branches:
  refs/heads/master bb4fc742f -> 6c7bdab53


CAMEL-7849 support encrypted properties inside and outside <camelContext>


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6c7bdab5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6c7bdab5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6c7bdab5

Branch: refs/heads/master
Commit: 6c7bdab53efc0777f6f39f09e8b2b66036d6a140
Parents: bb4fc74
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Apr 9 21:53:44 2015 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Apr 9 22:22:40 2015 +0800

----------------------------------------------------------------------
 .../SpringJasyptBridgePropertiesTest.java       |  2 +-
 .../org/apache/camel/component/jasypt/Test.java | 30 ++++++++++++++++++++
 .../jasypt/SpringJasyptBridgePropertiesTest.xml |  5 ++++
 .../BridgePropertyPlaceholderConfigurer.java    | 11 +++++++
 4 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6c7bdab5/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.java
b/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.java
index 2191521..0697d76 100644
--- a/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.java
+++ b/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.java
@@ -28,7 +28,7 @@ public class SpringJasyptBridgePropertiesTest extends CamelSpringTestSupport
{
 
     @Test
     public void testJasyptProperties() throws Exception {
-        getMockEndpoint("mock:tiger").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:tiger").expectedBodiesReceived("Hello World tiger");
 
         template.sendBody("direct:start", "Hello World");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/6c7bdab5/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/Test.java
----------------------------------------------------------------------
diff --git a/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/Test.java
b/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/Test.java
new file mode 100644
index 0000000..fa4abc7
--- /dev/null
+++ b/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/Test.java
@@ -0,0 +1,30 @@
+/**
+ * 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.
+ */
+
+package org.apache.camel.component.jasypt;
+
+public class Test {
+    private String data = "";
+    public void setData(String data) {
+        this.data = data;
+    }
+    
+    public String handleRequst(String request) {
+        return request + " " + data;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/6c7bdab5/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
index 11ec9cf..895b4a2 100644
--- a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
+++ b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
@@ -32,10 +32,15 @@
     <property name="location" value="classpath:org/apache/camel/component/jasypt/myproperties.properties"/>
     <property name="parser" ref="jasyptParser"/>
   </bean>
+  
+  <bean id="test" class="org.apache.camel.component.jasypt.Test">
+     <property name="data" value="${cool.password}" />
+  </bean>
 
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
       <from uri="direct:start"/>
+      <to uri="bean:test" />
       <to uri="{{cool.result}}"/>
     </route>
   </camelContext>

http://git-wip-us.apache.org/repos/asf/camel/blob/6c7bdab5/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
index 67351dc..c30ea65 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BridgePropertyPlaceholderConfigurer.java
@@ -112,6 +112,17 @@ public class BridgePropertyPlaceholderConfigurer extends PropertyPlaceholderConf
         super.setIgnoreResourceNotFound(ignoreResourceNotFound);
         this.ignoreResourceNotFound = ignoreResourceNotFound;
     }
+    
+    @Override
+    protected String resolvePlaceholder(String placeholder, Properties props) {
+        String value = props.getProperty(placeholder);
+        if (parser != null) {
+            // Just apply the parser to the place holder value to avoid configuring the other
placeholder configure twice for the inside and outside camel context
+            return parser.parseProperty(placeholder, value, props);
+        } else {
+            return value;
+        }
+    }
 
     @Override
     public Properties resolveProperties(CamelContext context, boolean ignoreMissingLocation,
String... uri) throws Exception {


Mime
View raw message