camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1128688 [1/2] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/util/jsse/ camel-core/src/test/java/org/apache/camel/util/jsse/ camel-core/src/test/resources/org/apache/camel/util/jsse/ components/camel-blueprint/ components/cam...
Date Sat, 28 May 2011 15:54:33 GMT
Author: davsclaus
Date: Sat May 28 15:54:31 2011
New Revision: 1128688

URL: http://svn.apache.org/viewvc?rev=1128688&view=rev
Log:
CAMEL-3750: Configuring TSL/SSL now supports property placeholders. Thanks to David for all the hard work.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/AbstractJsseParametersTest.java   (with props)
    camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/KeyManagersParametersFactoryBean.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/KeyStoreParametersFactoryBean.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/SSLContextClientParametersFactoryBean.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/SSLContextParametersFactoryBean.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/SSLContextServerParametersFactoryBean.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/SecureRandomParametersFactoryBean.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/TrustManagersParametersFactoryBean.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/util/blueprint/package-info.java   (with props)
    camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/util/
    camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/util/blueprint/
    camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/util/blueprint/jaxb.index
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/JsseUtilTester.java   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-18.xml   (with props)
Removed:
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/ClientAuthenticationDefinition.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/BaseSSLContextParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/FilterParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyManagersParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyStoreParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextClientParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextServerParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SecureRandomParameters.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/TrustManagersParameters.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/FilterParametersTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyManagersParametersTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyStoreParametersTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SSLContextParametersTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SecureRandomParametersTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/TrustManagersParametersTest.java
    camel/trunk/components/camel-blueprint/pom.xml
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractBaseSSLContextParametersFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractJsseUtilFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractKeyManagersParametersFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractKeyStoreParametersFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSSLContextClientParametersFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSSLContextParametersFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSSLContextServerParametersFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSecureRandomParametersFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractTrustManagersParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/util/spring/KeyManagersParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/util/spring/KeyStoreParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/util/spring/SSLContextClientParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/util/spring/SSLContextParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/util/spring/SSLContextServerParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/util/spring/SecureRandomParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/util/spring/TrustManagersParametersFactoryBean.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/util/spring/KeyStoreParametersFactoryBeanTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/util/spring/KeyStoreParametersFactoryBeanTest-context.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest-context.xml
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint2Test.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/BaseSSLContextParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/BaseSSLContextParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/BaseSSLContextParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/BaseSSLContextParameters.java Sat May 28 15:54:31 2011
@@ -53,7 +53,7 @@ import org.slf4j.LoggerFactory;
  * Represents configuration options that can be applied in the client-side
  * or server-side context depending on what they are applied to.
  */
-public abstract class BaseSSLContextParameters {
+public abstract class BaseSSLContextParameters extends JsseParameters {
 
     protected static final List<String> DEFAULT_CIPHER_SUITES_FILTER_INCLUDE =
         Collections.unmodifiableList(Arrays.asList(".*"));
@@ -89,7 +89,7 @@ public abstract class BaseSSLContextPara
     /**
      * The optional {@link SSLSessionContext} timeout time for {@link javax.net.ssl.SSLSession}s in seconds.
      */
-    private Integer sessionTimeout;
+    private String sessionTimeout;
     
 
     /**
@@ -202,7 +202,7 @@ public abstract class BaseSSLContextPara
      * Returns the optional {@link SSLSessionContext} timeout time for {@link javax.net.ssl.SSLSession}s 
      * in seconds.
      */
-    public Integer getSessionTimeout() {
+    public String getSessionTimeout() {
         return sessionTimeout;
     }
 
@@ -212,7 +212,7 @@ public abstract class BaseSSLContextPara
      *
      * @param sessionTimeout the timeout value or {@code null} to use the default
      */
-    public void setSessionTimeout(Integer sessionTimeout) {
+    public void setSessionTimeout(String sessionTimeout) {
         this.sessionTimeout = sessionTimeout;
     }
     
@@ -280,7 +280,7 @@ public abstract class BaseSSLContextPara
     protected List<Configurer<SSLEngine>> getSSLEngineConfigurers(SSLContext context) {
         
         final List<String> enabledCipherSuites = this.getCipherSuites() == null
-                ? null : this.getCipherSuites().getCipherSuite();
+                ? null : this.parsePropertyValues(this.getCipherSuites().getCipherSuite());
         
         final Patterns enabledCipherSuitePatterns;
         final Patterns defaultEnabledCipherSuitePatterns = this.getDefaultCipherSuitesFilter().getPatterns();
@@ -294,7 +294,7 @@ public abstract class BaseSSLContextPara
         ///
         
         final List<String> enabledSecureSocketProtocols = this.getSecureSocketProtocols() == null
-                ? null : this.getSecureSocketProtocols().getSecureSocketProtocol();
+                ? null : this.parsePropertyValues(this.getSecureSocketProtocols().getSecureSocketProtocol());
         
         final Patterns enabledSecureSocketProtocolsPatterns;
         final Patterns defaultEnabledSecureSocketProtocolsPatterns = 
@@ -435,7 +435,7 @@ public abstract class BaseSSLContextPara
      */
     protected List<Configurer<SSLSocket>> getSSLSocketFactorySSLSocketConfigurers(SSLContext context) {
         final List<String> enabledCipherSuites = this.getCipherSuites() == null
-                ? null : this.getCipherSuites().getCipherSuite();
+                ? null : this.parsePropertyValues(this.getCipherSuites().getCipherSuite());
 
         final Patterns enabledCipherSuitePatterns;
         final Patterns defaultEnabledCipherSuitePatterns = this.getDefaultCipherSuitesFilter().getPatterns();
@@ -449,7 +449,7 @@ public abstract class BaseSSLContextPara
         ///
         
         final List<String> enabledSecureSocketProtocols = this.getSecureSocketProtocols() == null
-                ? null : this.getSecureSocketProtocols().getSecureSocketProtocol();
+                ? null : this.parsePropertyValues(this.getSecureSocketProtocols().getSecureSocketProtocol());
         
         final Patterns enabledSecureSocketProtocolsPatterns;
         final Patterns defaultEnabledSecureSocketProtocolsPatterns = 
@@ -513,7 +513,7 @@ public abstract class BaseSSLContextPara
      */
     protected List<Configurer<SSLServerSocket>> getSSLServerSocketFactorySSLServerSocketConfigurers(SSLContext context) {
         final List<String> enabledCipherSuites = this.getCipherSuites() == null
-                ? null : this.getCipherSuites().getCipherSuite();
+                ? null : this.parsePropertyValues(this.getCipherSuites().getCipherSuite());
         
         final Patterns enabledCipherSuitePatterns;
         final Patterns defaultEnabledCipherSuitePatterns = this.getDefaultCipherSuitesFilter().getPatterns();
@@ -527,7 +527,7 @@ public abstract class BaseSSLContextPara
         ///
         
         final List<String> enabledSecureSocketProtocols = this.getSecureSocketProtocols() == null
-                ? null : this.getSecureSocketProtocols().getSecureSocketProtocol();
+                ? null : this.parsePropertyValues(this.getSecureSocketProtocols().getSecureSocketProtocol());
         
         final Patterns enabledSecureSocketProtocolsPatterns;
         final Patterns defaultEnabledSecureSocketProtocolsPatterns = 
@@ -583,10 +583,12 @@ public abstract class BaseSSLContextPara
      * @throws GeneralSecurityException if {@code sessionContext} is {@code null}
      */
     protected void configureSessionContext(
-        SSLSessionContext sessionContext, int sessionTimeout) throws GeneralSecurityException {
+        SSLSessionContext sessionContext, String sessionTimeout) throws GeneralSecurityException {
+        
+        int sessionTimeoutInt = Integer.parseInt(this.parsePropertyValue(sessionTimeout));
         
         if (sessionContext != null) {
-            sessionContext.setSessionTimeout(sessionTimeout);
+            sessionContext.setSessionTimeout(sessionTimeoutInt);
         } else {
             throw new GeneralSecurityException(
                     "The SSLContext does not support SSLSessionContext, "

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/FilterParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/FilterParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/FilterParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/FilterParameters.java Sat May 28 15:54:31 2011
@@ -27,7 +27,7 @@ import java.util.regex.PatternSyntaxExce
  * Represents a set of regular expression based filter patterns for
  * including and excluding content of some type.
  */
-public class FilterParameters {
+public class FilterParameters extends JsseParameters {
 
     protected List<String> include;
     protected List<String> exclude;
@@ -103,7 +103,7 @@ public class FilterParameters {
         List<Pattern> patterns = new ArrayList<Pattern>(patternStrings.size());
         
         for (String expression : patternStrings) {
-            patterns.add(Pattern.compile(expression));
+            patterns.add(Pattern.compile(this.parsePropertyValue(expression)));
         }
         return patterns;
     }
@@ -112,8 +112,8 @@ public class FilterParameters {
      * An immutable collection of compiled includes and excludes filter {@link Pattern}s.
      */
     public static class Patterns {
-        final List<Pattern> includes;
-        final List<Pattern> excludes;
+        private final List<Pattern> includes;
+        private final List<Pattern> excludes;
         
         public Patterns(List<Pattern> includes, List<Pattern> excludes) {
             this.includes = Collections.unmodifiableList(new ArrayList<Pattern>(includes));
@@ -136,6 +136,8 @@ public class FilterParameters {
         builder.append(Arrays.toString(getInclude().toArray(new String[getInclude().size()])));
         builder.append(", exclude=");
         builder.append(Arrays.toString(getExclude().toArray(new String[getExclude().size()])));
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java?rev=1128688&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java Sat May 28 15:54:31 2011
@@ -0,0 +1,172 @@
+/**
+ * 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.util.jsse;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.ClassResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Base class that provides optional integration with core Camel capabilities.
+ */
+public class JsseParameters implements CamelContextAware {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(JsseParameters.class);
+    
+    private CamelContext context;
+
+    /**
+     * @see #setCamelContext(CamelContext)
+     */
+    public CamelContext getCamelContext() {
+        return context;
+    }
+
+    /**
+     * Sets the optional {@link CamelContext} used for integration with core capabilities
+     * such as Camel Property Placeholders and {@link ClassResolver}.
+     *
+     * @param context the context to use
+     */
+    public void setCamelContext(CamelContext context) {
+        this.context = context;
+    }
+    
+    /**
+     * Parses the value using the Camel Property Placeholder capabilities if
+     * a context is provided.  Otherwise returns {@code value} as is.
+     *
+     * @param value the string to replace property tokens in
+     * @return the value
+     * 
+     * @throws RuntimeCamelException if property placeholders were used and there was an error resolving them
+     *
+     * @see #setCamelContext(CamelContext)
+     */
+    protected String parsePropertyValue(String value) throws RuntimeCamelException {
+        if (this.getCamelContext() != null) {
+            try {
+                return this.getCamelContext().resolvePropertyPlaceholders(value);
+            } catch (Exception e) {
+                throw new RuntimeCamelException("Error parsing property value: " + value, e);
+            }
+        } else {
+            return value;
+        }
+    }
+    
+    /**
+     * Parses the values using the Camel Property Placeholder capabilities if
+     * a context is provided.  Otherwise returns {@code values} as is.
+     *
+     * @param values the list of strings to replace property tokens in
+     * @return the list of strings
+     * 
+     * @throws RuntimeCamelException if property placeholders were used and there was an error resolving them
+     *
+     * @see #parsePropertyValue(String)
+     */
+    protected List<String> parsePropertyValues(List<String> values) throws RuntimeCamelException {
+        if (this.getCamelContext() == null) {
+            return values;
+        } else {
+            List<String> parsedValues = new ArrayList<String>(values.size());
+            for (String value : values) {
+                parsedValues.add(this.parsePropertyValue(value));
+            }
+            return parsedValues;
+        }
+    }
+    
+    /**
+     * Attempts to loads a resource using a number of different approaches.
+     * The loading of the resource, is attempted by treating the resource as a file path,
+     * a class path resource, a URL, and using the Camel Context's {@link ClassResolver} 
+     * if a context is available in that order. An exception is thrown if the resource
+     * cannot be resolved to readable input stream using any of the above methods.
+     * 
+     * @param resource the resource location
+     * @return the input stream for the resource
+     *
+     * @throws IOException if the resource cannot be resolved using any of the above methods
+     * 
+     * @see #setCamelContext(CamelContext)
+     */
+    protected InputStream resolveResource(String resource) throws IOException {
+        InputStream is = null;
+
+        try {
+            LOG.trace("Trying to open resource as a file.");
+            is = new FileInputStream(resource);
+        } catch (FileNotFoundException e) {
+            LOG.trace("Could not open resource as a file.", e);
+        }
+        
+        if (is == null && Thread.currentThread().getContextClassLoader() != null) {
+            LOG.trace("Trying to open resource as a class path resource with the TCCL {}.",
+                      Thread.currentThread().getContextClassLoader());
+            is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
+            if (is == null) {
+                LOG.trace("Could not open resource as a class path resource using the TCCL {}.",
+                          Thread.currentThread().getContextClassLoader());
+            }
+        }
+
+        if (is == null) {
+            LOG.trace("Trying to open resource as a class path resource using the classloader {}.",
+                      this.getClass().getClassLoader());
+            is = this.getClass().getResourceAsStream(resource);
+            if (is == null) {
+                LOG.trace("Could not open resource as a class path resource using the classloader {}.",
+                          this.getClass().getClassLoader());
+            }
+        }
+
+        if (is == null) {
+            try {
+                LOG.trace("Trying to open resource as a URL.");
+                is = new URL(resource).openStream();
+            } catch (IOException e) {
+                LOG.trace("Could not open resource as a URL.", e);
+            }
+        }
+        
+        if (is == null && this.context != null) {
+            LOG.trace("Trying to open resource using the CamelContext ClassResolver {}", context.getClassResolver());
+            is = context.getClassResolver().loadResourceAsStream(resource);
+            LOG.trace("Could not to open resource using the CamelContext ClassResolver {}.", context.getClassResolver());
+        }
+
+        if (is == null) {
+            throw new IOException("Could not open " + resource + " as a file, class path resource, or URL.");
+        }
+        
+        return is;
+    }
+
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyManagersParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyManagersParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyManagersParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyManagersParameters.java Sat May 28 15:54:31 2011
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
  * A representation of configuration options for creating and loading
  * {@link KeyManager} instance(s).
  */
-public class KeyManagersParameters {
+public class KeyManagersParameters extends JsseParameters {
 
     private static final Logger LOG = LoggerFactory.getLogger(KeyManagersParameters.class);
 
@@ -85,7 +85,7 @@ public class KeyManagersParameters {
 
         KeyManager[] keyManagers;
 
-        String kmfAlgorithm = this.getAlgorithm();
+        String kmfAlgorithm = this.parsePropertyValue(this.getAlgorithm());
         if (kmfAlgorithm == null) {
             kmfAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
         }
@@ -94,13 +94,13 @@ public class KeyManagersParameters {
         if (this.getProvider() == null) {
             kmf = KeyManagerFactory.getInstance(kmfAlgorithm);
         } else {
-            kmf = KeyManagerFactory.getInstance(kmfAlgorithm, this.getProvider());
+            kmf = KeyManagerFactory.getInstance(kmfAlgorithm, this.parsePropertyValue(this.getProvider()));
         }
 
         
         char[] kmfPassword = null;
         if (this.getKeyPassword() != null) {
-            kmfPassword = this.getKeyPassword().toCharArray();
+            kmfPassword = this.parsePropertyValue(this.getKeyPassword()).toCharArray();
         }
         
         KeyStore ks = this.getKeyStore() == null ? null : this.getKeyStore().createKeyStore();
@@ -199,6 +199,8 @@ public class KeyManagersParameters {
         builder.append(provider);
         builder.append(", algorithm=");
         builder.append(algorithm);
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyStoreParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyStoreParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyStoreParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/KeyStoreParameters.java Sat May 28 15:54:31 2011
@@ -16,11 +16,8 @@
  */
 package org.apache.camel.util.jsse;
 
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 import java.security.Security;
@@ -32,7 +29,7 @@ import org.slf4j.LoggerFactory;
  * A representation of configuration options for creating and loading a
  * {@link KeyStore} instance.
  */
-public class KeyStoreParameters {
+public class KeyStoreParameters extends JsseParameters {
 
     private static final Logger LOG = LoggerFactory.getLogger(KeyStoreParameters.class);
 
@@ -149,66 +146,29 @@ public class KeyStoreParameters {
      *             resource to an input stream
      */
     public KeyStore createKeyStore() throws GeneralSecurityException, IOException {
-
         LOG.debug("Creating KeyStore instance from KeyStoreParameters: {}", this);
 
-        String ksType = this.type;
+        String ksType = this.parsePropertyValue(this.type);
         if (ksType == null) {
             ksType = KeyStore.getDefaultType();
         }
 
         char[] ksPassword = null;
         if (this.password != null) {
-            ksPassword = this.password.toCharArray();
+            ksPassword = this.parsePropertyValue(this.password).toCharArray();
         }
 
         KeyStore ks;
         if (this.provider == null) {
             ks = KeyStore.getInstance(ksType);
         } else {
-            ks = KeyStore.getInstance(ksType, this.provider);
+            ks = KeyStore.getInstance(ksType, this.parsePropertyValue(this.provider));
         }
 
         if (this.resource == null) {
             ks.load(null, ksPassword);
         } else {
-            InputStream is = null;
-
-            try {
-                is = new FileInputStream(this.resource);
-            } catch (FileNotFoundException e) {
-                LOG.debug("Could not open resource as a file, trying as class path resource.", e);
-            }
-
-            if (is == null) {
-                is = this.getClass().getResourceAsStream(this.resource);
-                if (is == null) {
-                    LOG.debug("Could not open resource as a class path resource using the classloader "
-                              + this.getClass().getClassLoader() 
-                              + ". Trying as a class path resource with the TCCL (if set).");
-                }
-            }
-            
-            if (is == null && Thread.currentThread().getContextClassLoader() != null) {
-                is = Thread.currentThread().getContextClassLoader().getResourceAsStream(this.resource);
-                if (is == null) {
-                    LOG.debug("Could not open resource as a class path resource using the TCCL "
-                              + Thread.currentThread().getContextClassLoader() + ".  Trying as a URL.");
-                }
-            }
-
-            if (is == null) {
-                try {
-                    is = new URL(this.resource).openStream();
-                } catch (IOException e) {
-                    LOG.debug("Could not open resource as a URL.", e);
-                }
-            }
-
-            if (is == null) {
-                throw new IOException("Could not open " + this.resource + " as a file, class path resource, or URL.");
-            }
-
+            InputStream is = this.resolveResource(this.parsePropertyValue(this.resource));
             ks.load(is, ksPassword);
         }
 
@@ -226,6 +186,8 @@ public class KeyStoreParameters {
         builder.append(provider);
         builder.append(", resource=");
         builder.append(resource);
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextClientParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextClientParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextClientParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextClientParameters.java Sat May 28 15:54:31 2011
@@ -87,6 +87,8 @@ public class SSLContextClientParameters 
         builder.append(getSecureSocketProtocolsFilter());
         builder.append(", getSessionTimeout()=");
         builder.append(getSessionTimeout());
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextParameters.java Sat May 28 15:54:31 2011
@@ -237,9 +237,10 @@ public class SSLContextParameters extend
 
         SSLContext context;
         if (this.getProvider() == null) {
-            context = SSLContext.getInstance(this.getSecureSocketProtocol());
+            context = SSLContext.getInstance(this.parsePropertyValue(this.getSecureSocketProtocol()));
         } else {
-            context = SSLContext.getInstance(this.getSecureSocketProtocol(), this.getProvider());
+            context = SSLContext.getInstance(this.parsePropertyValue(this.getSecureSocketProtocol()),
+                                             this.parsePropertyValue(this.getProvider()));
         }
         
         context.init(keyManagers, trustManagers, secureRandom);
@@ -352,6 +353,8 @@ public class SSLContextParameters extend
         builder.append(getSecureSocketProtocolsFilter());
         builder.append(", getSessionTimeout()=");
         builder.append(getSessionTimeout());
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextServerParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextServerParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextServerParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextServerParameters.java Sat May 28 15:54:31 2011
@@ -35,24 +35,24 @@ public class SSLContextServerParameters 
     private static final Logger LOG = LoggerFactory.getLogger(SSLContextServerParameters.class);
 
     /**
-     * The optional configuration options for server-side client-authentication
-     * requirements.
+     * The optional configuration options for server-side client-authentication requirements.
      */
-    protected ClientAuthentication clientAuthentication;
+    protected String clientAuthentication;
     
     /**
-     * @see #setClientAuthentication(ClientAuthenticationParameters)   
+     * @see #setClientAuthentication(String)
      */
-    public ClientAuthentication getClientAuthentication() {
+    public String getClientAuthentication() {
         return clientAuthentication;
     }
 
     /**
      * Sets the configuration options for server-side client-authentication requirements.
+     * The value must be one of NONE, WANT, REQUIRE as defined in {@link ClientAuthentication}.
      * 
      * @param value the desired configuration options or {@code null} to use the defaults
      */
-    public void setClientAuthentication(ClientAuthentication value) {
+    public void setClientAuthentication(String value) {
         this.clientAuthentication = value;
     }
     
@@ -91,13 +91,12 @@ public class SSLContextServerParameters 
         
         if (this.getClientAuthentication() != null) { 
             
-            final ClientAuthentication clientAuthValue = this.getClientAuthentication();
+            final ClientAuthentication clientAuthValue = 
+                ClientAuthentication.valueOf(this.parsePropertyValue(this.getClientAuthentication()));
         
             Configurer<SSLEngine> sslEngineConfigurer = new Configurer<SSLEngine>() {
-                
                 @Override
                 public SSLEngine configure(SSLEngine engine) {
-                
                     switch (clientAuthValue) {
                     case NONE:
                         engine.setWantClientAuth(false);
@@ -110,7 +109,7 @@ public class SSLContextServerParameters 
                         engine.setNeedClientAuth(true);
                         break;
                     default:
-                        throw new RuntimeCamelException("Unhandled ClientAuthentication enumeration value: " + clientAuthValue);
+                        throw new RuntimeCamelException("Unknown ClientAuthentication value: " + clientAuthValue);
                     }
                     
                     return engine;
@@ -128,16 +127,14 @@ public class SSLContextServerParameters 
         List<Configurer<SSLServerSocket>> sslServerSocketConfigurers = 
             super.getSSLServerSocketFactorySSLServerSocketConfigurers(context);
         
-
-        if (this.getClientAuthentication() != null) { 
+        if (this.getClientAuthentication() != null) {
             
-            final ClientAuthentication clientAuthValue = this.getClientAuthentication();
+            final ClientAuthentication clientAuthValue =
+                ClientAuthentication.valueOf(this.parsePropertyValue(this.getClientAuthentication()));
         
             Configurer<SSLServerSocket> sslServerSocketConfigurer = new Configurer<SSLServerSocket>() {
-                
                 @Override
                 public SSLServerSocket configure(SSLServerSocket socket) {
-                    
                     switch (clientAuthValue) {
                     case NONE:
                         socket.setWantClientAuth(false);
@@ -150,7 +147,7 @@ public class SSLContextServerParameters 
                         socket.setNeedClientAuth(true);
                         break;
                     default:
-                        throw new RuntimeCamelException("Unhandled ClientAuthentication enumeration value: " + clientAuthValue);
+                        throw new RuntimeCamelException("Unknown ClientAuthentication value: " + clientAuthValue);
                     }
                     
                     return socket;
@@ -159,8 +156,7 @@ public class SSLContextServerParameters 
             
             sslServerSocketConfigurers.add(sslServerSocketConfigurer);
         }
-        
-        
+
         return sslServerSocketConfigurers;
     }
 
@@ -188,6 +184,8 @@ public class SSLContextServerParameters 
         builder.append(getSecureSocketProtocolsFilter());
         builder.append(", getSessionTimeout()=");
         builder.append(getSessionTimeout());
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SecureRandomParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SecureRandomParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SecureRandomParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/SecureRandomParameters.java Sat May 28 15:54:31 2011
@@ -23,7 +23,7 @@ import java.security.Security;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SecureRandomParameters {
+public class SecureRandomParameters extends JsseParameters {
     
     private static final Logger LOG = LoggerFactory.getLogger(SecureRandomParameters.class);
 
@@ -60,9 +60,10 @@ public class SecureRandomParameters {
 
         SecureRandom secureRandom;
         if (this.getProvider() != null) {
-            secureRandom = SecureRandom.getInstance(this.getAlgorithm(), this.getProvider());
+            secureRandom = SecureRandom.getInstance(this.parsePropertyValue(this.getAlgorithm()),
+                                                    this.parsePropertyValue(this.getProvider()));
         } else {
-            secureRandom = SecureRandom.getInstance(this.getAlgorithm());
+            secureRandom = SecureRandom.getInstance(this.parsePropertyValue(this.getAlgorithm()));
         }
 
         return secureRandom;
@@ -118,6 +119,8 @@ public class SecureRandomParameters {
         builder.append(algorithm);
         builder.append(", provider=");
         builder.append(provider);
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/TrustManagersParameters.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/TrustManagersParameters.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/TrustManagersParameters.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/jsse/TrustManagersParameters.java Sat May 28 15:54:31 2011
@@ -27,7 +27,7 @@ import javax.net.ssl.TrustManagerFactory
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TrustManagersParameters {
+public class TrustManagersParameters extends JsseParameters {
 
     private static final Logger LOG = LoggerFactory.getLogger(TrustManagersParameters.class);
     
@@ -76,7 +76,7 @@ public class TrustManagersParameters {
         TrustManager[] trustManagers = null;
 
         if (this.getKeyStore() != null) {
-            String tmfAlgorithm = this.getAlgorithm();
+            String tmfAlgorithm = this.parsePropertyValue(this.getAlgorithm());
             if (tmfAlgorithm == null) {
                 tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
             }
@@ -85,11 +85,10 @@ public class TrustManagersParameters {
             if (this.getProvider() == null) {
                 tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
             } else {
-                tmf = TrustManagerFactory.getInstance(tmfAlgorithm, this.getProvider());
+                tmf = TrustManagerFactory.getInstance(tmfAlgorithm, this.parsePropertyValue(this.getProvider()));
             }
             
             KeyStore ks = this.getKeyStore() == null ? null : this.getKeyStore().createKeyStore();
-    
             tmf.init(ks);
             trustManagers = tmf.getTrustManagers();
         }
@@ -157,6 +156,8 @@ public class TrustManagersParameters {
         builder.append(provider);
         builder.append(", algorithm=");
         builder.append(algorithm);
+        builder.append(", getContext()=");
+        builder.append(getCamelContext());
         builder.append("]");
         return builder.toString();
     }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/AbstractJsseParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/AbstractJsseParametersTest.java?rev=1128688&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/AbstractJsseParametersTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/AbstractJsseParametersTest.java Sat May 28 15:54:31 2011
@@ -0,0 +1,117 @@
+/**
+ * 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.util.jsse;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.TestSupport;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.impl.DefaultCamelContext;
+
+public abstract class AbstractJsseParametersTest extends TestSupport {
+
+    protected CamelContext createPropertiesPlaceholderAwareContext() throws Exception {
+        Properties supplementalProperties = new Properties();
+
+        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+        SecureRandom sr = null;
+        try {
+            sr = SecureRandom.getInstance("SHA1PRNG");
+        } catch (NoSuchAlgorithmException e) {
+            // Ignore
+        }
+
+        SSLContext sslc = SSLContext.getInstance("TLS");
+        sslc.init(null, null, null);
+        SSLSocket socket = (SSLSocket) sslc.getSocketFactory().createSocket();
+
+        supplementalProperties.setProperty("keyStoreParameters.type", KeyStore.getDefaultType());
+        supplementalProperties.setProperty("keyStoreParameters.provider", ks.getProvider().getName());
+
+        supplementalProperties.setProperty("keyManagersParameters.algorithm", KeyManagerFactory.getDefaultAlgorithm());
+        supplementalProperties.setProperty("keyManagersParameters.provider", kmf.getProvider().getName());
+
+        supplementalProperties.setProperty("trustManagersParameters.algorithm", TrustManagerFactory.getDefaultAlgorithm());
+        supplementalProperties.setProperty("trustManagersParameters.provider", tmf.getProvider().getName());
+
+        if (sr != null) {
+            supplementalProperties.setProperty("secureRandomParameters.algorithm", "SHA1PRNG");
+            supplementalProperties.setProperty("secureRandomParameters.provider", sr.getProvider().getName());
+        }
+
+        supplementalProperties.setProperty("sslContextParameters.provider", sslc.getProvider().getName());
+        supplementalProperties.setProperty("cipherSuite.0", socket.getSupportedCipherSuites()[0]);
+
+        // Have to skip this guy because he doesn't work with TLS as the SSLContext protocol
+        String ssp = "";
+        for (String protocol : socket.getSupportedProtocols()) {
+            if (!"SSLv2Hello".equals(protocol)) {
+                ssp = protocol;
+                break;
+            }
+        }
+        supplementalProperties.setProperty("secureSocketProtocol.0", ssp);
+
+
+        return this.createPropertiesPlaceholderAwareContext(supplementalProperties);
+    }
+
+    protected CamelContext createPropertiesPlaceholderAwareContext(Properties supplementalProperties) throws IOException {
+        Properties properties = new Properties(supplementalProperties);
+        properties.load(AbstractJsseParametersTest.class.getResourceAsStream("test.properties"));
+
+        if (supplementalProperties != null) {
+            Properties mergedProps = new Properties();
+
+            Set<String> keys = new HashSet<String>();
+            keys.addAll(properties.stringPropertyNames());
+            keys.addAll(supplementalProperties.stringPropertyNames());
+
+            for (String key : keys) {
+                mergedProps.setProperty(key, properties.getProperty(key));
+            }
+
+            properties = mergedProps;
+        }
+
+        properties.store(new FileOutputStream("./target/jsse-test.properties"),
+                "Generated by " + AbstractJsseParametersTest.class.getName());
+
+        PropertiesComponent pc = new PropertiesComponent();
+        pc.setLocation("file:./target/jsse-test.properties");
+
+        CamelContext context = new DefaultCamelContext();
+        context.addComponent("properties", pc);
+
+        return context;
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/AbstractJsseParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/AbstractJsseParametersTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/FilterParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/FilterParametersTest.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/FilterParametersTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/FilterParametersTest.java Sat May 28 15:54:31 2011
@@ -20,9 +20,36 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
 
-public class FilterParametersTest extends TestCase {
+public class FilterParametersTest extends AbstractJsseParametersTest {
+    
+    public void testPropertyPlaceholders() throws Exception {
+        CamelContext context = this.createPropertiesPlaceholderAwareContext();
+        
+        FilterParameters filter = new FilterParameters();
+        filter.setCamelContext(context);
+        filter.getInclude().add("{{filterParameters.include}}");
+        filter.getExclude().add("{{filterParameters.exclude}}");
+        
+        FilterParameters.Patterns patterns = filter.getPatterns();
+        
+        List<Pattern> includes = patterns.getIncludes();
+        List<Pattern> excludes = patterns.getExcludes();
+        
+        assertNotNull(includes);
+        assertNotNull(excludes);
+        
+        assertEquals(1, includes.size());
+        assertEquals(1, excludes.size());
+        
+        Matcher includeMatcher = includes.get(0).matcher("include");
+        assertTrue(includeMatcher.matches());
+        
+        Matcher excludeMatcher = excludes.get(0).matcher("exclude");
+        assertTrue(excludeMatcher.matches());
+    }
+    
     public void testGetIncludePatterns() {
         FilterParameters filter = new FilterParameters();
         filter.getInclude().add("asdfsadfsadfsadf");

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyManagersParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyManagersParametersTest.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyManagersParametersTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyManagersParametersTest.java Sat May 28 15:54:31 2011
@@ -24,9 +24,9 @@ import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.X509KeyManager;
 
-import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
 
-public class KeyManagersParametersTest extends TestCase {
+public class KeyManagersParametersTest extends AbstractJsseParametersTest {
     
     protected KeyStoreParameters createMinimalKeyStoreParameters() {
         KeyStoreParameters ksp = new KeyStoreParameters();
@@ -45,6 +45,30 @@ public class KeyManagersParametersTest e
         return kmp;
     }
     
+    public void testPropertyPlaceholders() throws Exception {
+        
+        CamelContext context = this.createPropertiesPlaceholderAwareContext();
+        
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setCamelContext(context);
+        
+        ksp.setType("{{keyStoreParameters.type}}");
+        ksp.setProvider("{{keyStoreParameters.provider}}");
+        ksp.setResource("{{keyStoreParameters.resource}}");
+        ksp.setPassword("{{keyStoreParamerers.password}}");
+        
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setCamelContext(context);
+        kmp.setKeyStore(ksp);
+        
+        kmp.setKeyPassword("{{keyManagersParameters.keyPassword}}");
+        kmp.setAlgorithm("{{keyManagersParameters.algorithm}}");
+        kmp.setProvider("{{keyManagersParameters.provider}}");
+        
+        KeyManager[] kms = kmp.createKeyManagers();
+        validateKeyManagers(kms);
+    }
+    
     public void testCreateKeyManagers() throws Exception {
         KeyManagersParameters kmp = this.createMinimalKeyManagersParameters();
         

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyStoreParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyStoreParametersTest.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyStoreParametersTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/KeyStoreParametersTest.java Sat May 28 15:54:31 2011
@@ -24,9 +24,9 @@ import java.security.GeneralSecurityExce
 import java.security.KeyStore;
 import java.security.NoSuchProviderException;
 
-import org.apache.camel.TestSupport;
+import org.apache.camel.CamelContext;
 
-public class KeyStoreParametersTest extends TestSupport {
+public class KeyStoreParametersTest extends AbstractJsseParametersTest {
     
     protected KeyStoreParameters createMinimalKeyStoreParameters() {
         KeyStoreParameters ksp = new KeyStoreParameters();
@@ -37,6 +37,22 @@ public class KeyStoreParametersTest exte
         return ksp;
     }
     
+    public void testPropertyPlaceholders() throws Exception {
+        
+        CamelContext context = this.createPropertiesPlaceholderAwareContext();
+        
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setCamelContext(context);
+        
+        ksp.setType("{{keyStoreParameters.type}}");
+        ksp.setProvider("{{keyStoreParameters.provider}}");
+        ksp.setResource("{{keyStoreParameters.resource}}");
+        ksp.setPassword("{{keyStoreParamerers.password}}");
+        
+        KeyStore ks = ksp.createKeyStore();
+        assertNotNull(ks.getCertificate("server"));
+    }
+    
     public void testValidParameters() throws GeneralSecurityException, IOException, URISyntaxException {
         KeyStoreParameters ksp = this.createMinimalKeyStoreParameters();
         

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SSLContextParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SSLContextParametersTest.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SSLContextParametersTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SSLContextParametersTest.java Sat May 28 15:54:31 2011
@@ -25,9 +25,66 @@ import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLServerSocket;
 import javax.net.ssl.SSLSocket;
 
-import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
 
-public class SSLContextParametersTest extends TestCase {
+public class SSLContextParametersTest extends AbstractJsseParametersTest {
+    
+    public void testPropertyPlaceholders() throws Exception {
+        
+        CamelContext camelContext = this.createPropertiesPlaceholderAwareContext();
+        
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setCamelContext(camelContext);
+        
+        ksp.setType("{{keyStoreParameters.type}}");
+        ksp.setProvider("{{keyStoreParameters.provider}}");
+        ksp.setResource("{{keyStoreParameters.resource}}");
+        ksp.setPassword("{{keyStoreParamerers.password}}");
+        
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setCamelContext(camelContext);
+        kmp.setKeyStore(ksp);
+        
+        kmp.setKeyPassword("{{keyManagersParameters.keyPassword}}");
+        kmp.setAlgorithm("{{keyManagersParameters.algorithm}}");
+        kmp.setProvider("{{keyManagersParameters.provider}}");
+        
+        TrustManagersParameters tmp = new TrustManagersParameters();
+        tmp.setCamelContext(camelContext);
+        tmp.setKeyStore(ksp);
+        
+        tmp.setAlgorithm("{{trustManagersParameters.algorithm}}");
+        tmp.setProvider("{{trustManagersParameters.provider}}");
+        
+        CipherSuitesParameters csp = new CipherSuitesParameters();
+        csp.getCipherSuite().add("{{cipherSuite.0}}");
+        
+        SecureSocketProtocolsParameters sspp = new SecureSocketProtocolsParameters();
+        sspp.getSecureSocketProtocol().add("{{secureSocketProtocol.0}}");
+        
+        SSLContextServerParameters scsp = new SSLContextServerParameters();
+        scsp.setCamelContext(camelContext);
+        scsp.setClientAuthentication("{{sslContextServerParameters.clientAuthentication}}");
+        
+        SSLContextParameters scp = new SSLContextParameters();
+        scp.setCamelContext(camelContext);
+        scp.setKeyManagers(kmp);
+        scp.setTrustManagers(tmp);
+        scp.setServerParameters(scsp);
+        
+        scp.setProvider("{{sslContextParameters.provider}}");
+        scp.setSecureSocketProtocol("{{sslContextParameters.protocol}}");
+        scp.setSessionTimeout("{{sslContextParameters.sessionTimeout}}");
+        
+        scp.setCipherSuites(csp);
+        scp.setSecureSocketProtocols(sspp);
+        
+        SSLContext context = scp.createSSLContext();
+        SSLServerSocket serverSocket = (SSLServerSocket) context.getServerSocketFactory().createServerSocket();
+        assertTrue(serverSocket.getNeedClientAuth());
+        context.getSocketFactory().createSocket();
+        context.createSSLEngine();
+    }
     
     public void testServerParametersClientAuthentication() throws Exception {
         SSLContext controlContext = SSLContext.getInstance("TLS");
@@ -52,7 +109,7 @@ public class SSLContextParametersTest ex
         assertEquals(controlEngine.getNeedClientAuth(), engine.getNeedClientAuth());
         
         // ClientAuthentication - NONE
-        scsp.setClientAuthentication(ClientAuthentication.NONE);
+        scsp.setClientAuthentication(ClientAuthentication.NONE.name());
         context = scp.createSSLContext();
         engine = context.createSSLEngine();
         serverSocket = (SSLServerSocket) context.getServerSocketFactory().createServerSocket();
@@ -63,7 +120,7 @@ public class SSLContextParametersTest ex
         assertEquals(false, engine.getNeedClientAuth());
         
         // ClientAuthentication - WANT
-        scsp.setClientAuthentication(ClientAuthentication.WANT);
+        scsp.setClientAuthentication(ClientAuthentication.WANT.name());
         context = scp.createSSLContext();
         engine = context.createSSLEngine();
         serverSocket = (SSLServerSocket) context.getServerSocketFactory().createServerSocket();
@@ -74,7 +131,7 @@ public class SSLContextParametersTest ex
         assertEquals(false, engine.getNeedClientAuth());
         
         // ClientAuthentication - REQUIRE
-        scsp.setClientAuthentication(ClientAuthentication.REQUIRE);
+        scsp.setClientAuthentication(ClientAuthentication.REQUIRE.name());
         context = scp.createSSLContext();
         engine = context.createSSLEngine();
         serverSocket = (SSLServerSocket) context.getServerSocketFactory().createServerSocket();
@@ -197,7 +254,7 @@ public class SSLContextParametersTest ex
         assertEquals(0, serverSocket.getEnabledProtocols().length);
         
         // Server session timeout only affects server session configuration
-        scsp.setSessionTimeout(12345);
+        scsp.setSessionTimeout("12345");
         context = scp.createSSLContext();
         engine = context.createSSLEngine();
         socket = (SSLSocket) context.getSocketFactory().createSocket();
@@ -317,7 +374,7 @@ public class SSLContextParametersTest ex
         assertTrue(Arrays.equals(controlServerSocket.getEnabledProtocols(), serverSocket.getEnabledProtocols()));      
         
         // Client session timeout only affects client session configuration
-        sccp.setSessionTimeout(12345);
+        sccp.setSessionTimeout("12345");
         context = scp.createSSLContext();
         engine = context.createSSLEngine();
         socket = (SSLSocket) context.getSocketFactory().createSocket();
@@ -610,14 +667,14 @@ public class SSLContextParametersTest ex
     
     public void testSessionTimeout() throws Exception {
         SSLContextParameters scp = new SSLContextParameters();
-        scp.setSessionTimeout(60);
+        scp.setSessionTimeout("60");
         
         SSLContext context = scp.createSSLContext();
         
         assertEquals(60, context.getClientSessionContext().getSessionTimeout());
         assertEquals(60, context.getServerSessionContext().getSessionTimeout());
         
-        scp.setSessionTimeout(0);
+        scp.setSessionTimeout("0");
         
         context = scp.createSSLContext();
         

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SecureRandomParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SecureRandomParametersTest.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SecureRandomParametersTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/SecureRandomParametersTest.java Sat May 28 15:54:31 2011
@@ -20,9 +20,23 @@ import java.security.NoSuchAlgorithmExce
 import java.security.NoSuchProviderException;
 import java.security.SecureRandom;
 
-import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
 
-public class SecureRandomParametersTest extends TestCase {
+public class SecureRandomParametersTest extends AbstractJsseParametersTest {
+    
+    public void testPropertyPlaceholders() throws Exception {
+        if (canTest()) {
+            CamelContext context = this.createPropertiesPlaceholderAwareContext();
+            
+            SecureRandomParameters srp = new SecureRandomParameters();
+            srp.setCamelContext(context);
+            
+            srp.setAlgorithm("{{secureRandomParameters.algorithm}}");
+            srp.setProvider("{{secureRandomParameters.provider}}");
+            
+            srp.createSecureRandom();
+        }
+    }
     
     public void testCreateSecureRandom() throws Exception {
         

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/TrustManagersParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/TrustManagersParametersTest.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/TrustManagersParametersTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/jsse/TrustManagersParametersTest.java Sat May 28 15:54:31 2011
@@ -23,9 +23,9 @@ import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 
-import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
 
-public class TrustManagersParametersTest extends TestCase {
+public class TrustManagersParametersTest extends AbstractJsseParametersTest {
     
     protected KeyStoreParameters createMinimalKeyStoreParameters() {
         KeyStoreParameters ksp = new KeyStoreParameters();
@@ -40,10 +40,32 @@ public class TrustManagersParametersTest
         TrustManagersParameters tmp = new TrustManagersParameters();
         tmp.setKeyStore(this.createMinimalKeyStoreParameters());
         
-        
         return tmp;
     }
     
+    public void testPropertyPlaceholders() throws Exception {
+        
+        CamelContext context = this.createPropertiesPlaceholderAwareContext();
+        
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setCamelContext(context);
+        
+        ksp.setType("{{keyStoreParameters.type}}");
+        ksp.setProvider("{{keyStoreParameters.provider}}");
+        ksp.setResource("{{keyStoreParameters.resource}}");
+        ksp.setPassword("{{keyStoreParamerers.password}}");
+        
+        TrustManagersParameters tmp = new TrustManagersParameters();
+        tmp.setCamelContext(context);
+        tmp.setKeyStore(ksp);
+        
+        tmp.setAlgorithm("{{trustManagersParameters.algorithm}}");
+        tmp.setProvider("{{trustManagersParameters.provider}}");
+        
+        TrustManager[] tms = tmp.createTrustManagers();
+        validateTrustManagers(tms);
+    }
+    
     public void testCreateTrustManagers() throws Exception {
         TrustManagersParameters tmp = this.createMinimalTrustManagersParameters();
         

Added: camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties?rev=1128688&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties (added)
+++ camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties Sat May 28 15:54:31 2011
@@ -0,0 +1,12 @@
+filterParameters.include=include
+filterParameters.exclude=exclude
+
+keyStoreParameters.resource=org/apache/camel/util/jsse/localhost.ks
+keyStoreParamerers.password=changeit
+
+keyManagersParameters.keyPassword=changeit
+
+sslContextParameters.protocol=TLS
+sslContextParameters.sessionTimeout=2
+
+sslContextServerParameters.clientAuthentication=REQUIRE
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/camel-core/src/test/resources/org/apache/camel/util/jsse/test.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: camel/trunk/components/camel-blueprint/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/pom.xml?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/pom.xml (original)
+++ camel/trunk/components/camel-blueprint/pom.xml Sat May 28 15:54:31 2011
@@ -34,12 +34,14 @@
     <properties>
         <camel.osgi.import>
             !org.apache.camel.blueprint.*,
+            !org.apache.camel.util.blueprint.*,
             org.apache.camel.*;${camel.osgi.import.strict.version},
             org.osgi.service.event*;resolution:=optional,
             *
         </camel.osgi.import>
         <camel.osgi.export>
-            org.apache.camel.blueprint*;${camel.osgi.version}
+            org.apache.camel.blueprint*;${camel.osgi.version},
+            org.apache.camel.util.blueprint*;${camel.osgi.version}
         </camel.osgi.export>
 		<camel.osgi.private.pkg>
 			org.apache.camel.core.osgi*,
@@ -250,9 +252,11 @@
                                           <include name="org/apache/camel/blueprint/Camel*.java" />
                                           <include name="org/apache/camel/blueprint/ErrorHandler*.java" />
                                           <include name="org/apache/camel/blueprint/package-info.java" />
+                                          <include name="org/apache/camel/util/blueprint/**/*.java"/>
                                       </fileset>
                                       <fileset dir="${basedir}/../camel-core-xml/src/main/java">
                                           <include name="org/apache/camel/core/xml/*.java" />
+                                          <include name="org/apache/camel/core/xml/util/**/*.java"/>
                                       </fileset>
                                       <fileset dir="${basedir}/../../camel-core/src/main/java">
                                           <include name="org/apache/camel/model/**/*.java" />

Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java?rev=1128688&r1=1128687&r2=1128688&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java (original)
+++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java Sat May 28 15:54:31 2011
@@ -77,6 +77,9 @@ import org.apache.camel.spi.ComponentRes
 import org.apache.camel.spi.DataFormatResolver;
 import org.apache.camel.spi.LanguageResolver;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.blueprint.KeyStoreParametersFactoryBean;
+import org.apache.camel.util.blueprint.SSLContextParametersFactoryBean;
+import org.apache.camel.util.blueprint.SecureRandomParametersFactoryBean;
 import org.osgi.framework.Bundle;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
@@ -95,6 +98,9 @@ public class CamelNamespaceHandler imple
 
     private static final String CAMEL_CONTEXT = "camelContext";
     private static final String ROUTE_CONTEXT = "routeContext";
+    private static final String KEY_STORE_PARAMETERS = "keyStoreParameters";
+    private static final String SECURE_RANDOM_PARAMETERS = "secureRandomParameters";
+    private static final String SSL_CONTEXT_PARAMETERS = "sslContextParameters";
 
     private static final String SPRING_NS = "http://camel.apache.org/schema/spring";
     private static final String BLUEPRINT_NS = "http://camel.apache.org/schema/blueprint";
@@ -128,124 +134,243 @@ public class CamelNamespaceHandler imple
     public Metadata parse(Element element, ParserContext context) {
         renameNamespaceRecursive(element);
         if (element.getNodeName().equals(CAMEL_CONTEXT)) {
-            // Find the id, generate one if needed
-            String contextId = element.getAttribute("id");
-            boolean implicitId = false;
-
-            // lets avoid folks having to explicitly give an ID to a camel context
-            if (ObjectHelper.isEmpty(contextId)) {
-                // if no explicit id was set then use a default auto generated name
-                CamelContextNameStrategy strategy = new DefaultCamelContextNameStrategy();
-                contextId = strategy.getName();
-                element.setAttribute("id", contextId);
-                implicitId = true;
-            }
+            return parseCamelContextNode(element, context);
+        }
+        if (element.getNodeName().equals(ROUTE_CONTEXT)) {
+            return parseRouteContextNode(element, context);
+        }
+        if (element.getNodeName().equals(KEY_STORE_PARAMETERS)) {
+            return parseKeyStoreParametersNode(element, context);
+        }
+        if (element.getNodeName().equals(SECURE_RANDOM_PARAMETERS)) {
+            return parseSecureRandomParametersNode(element, context);
+        }
+        if (element.getNodeName().equals(SSL_CONTEXT_PARAMETERS)) {
+            return parseSSLContextParametersNode(element, context);
+        }
 
-            // now lets parse the routes with JAXB
-            Binder<Node> binder;
-            try {
-                binder = getJaxbContext().createBinder();
-            } catch (JAXBException e) {
-                throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
-            }
-            Object value = parseUsingJaxb(element, context, binder);
-            if (!(value instanceof CamelContextFactoryBean)) {
-                throw new ComponentDefinitionException("Expected an instance of " + CamelContextFactoryBean.class);
-            }
-
-            CamelContextFactoryBean ccfb = (CamelContextFactoryBean) value;
-            ccfb.setImplicitId(implicitId);
-
-            MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
-            factory.setId(".camelBlueprint.passThrough." + contextId);
-            factory.setObject(new PassThroughCallable<Object>(value));
-
-            MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
-            factory2.setId(".camelBlueprint.factory." + contextId);
-            factory2.setFactoryComponent(factory);
-            factory2.setFactoryMethod("call");
-            factory2.setInitMethod("afterPropertiesSet");
-            factory2.setDestroyMethod("destroy");
-            factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
-            factory2.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
-
-            MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
-            ctx.setId(contextId);
-            ctx.setRuntimeClass(BlueprintCamelContext.class);
-            ctx.setFactoryComponent(factory2);
-            ctx.setFactoryMethod("getContext");
-            ctx.setInitMethod("init");
-            ctx.setDestroyMethod("destroy");
-
-            // Register objects
-            registerBeans(context, contextId, ccfb.getEndpoints());
-            registerBeans(context, contextId, ccfb.getThreadPools());
-            registerBeans(context, contextId, ccfb.getBeans());
-
-            // Register processors
-            MutablePassThroughMetadata beanProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
-            beanProcessorFactory.setId(".camelBlueprint.processor.bean.passThrough." + contextId);
-            beanProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelInjector(contextId)));
-
-            MutableBeanMetadata beanProcessor = context.createMetadata(MutableBeanMetadata.class);
-            beanProcessor.setId(".camelBlueprint.processor.bean." + contextId);
-            beanProcessor.setRuntimeClass(CamelInjector.class);
-            beanProcessor.setFactoryComponent(beanProcessorFactory);
-            beanProcessor.setFactoryMethod("call");
-            beanProcessor.setProcessor(true);
-            beanProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
-            context.getComponentDefinitionRegistry().registerComponentDefinition(beanProcessor);
-
-            MutablePassThroughMetadata regProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
-            regProcessorFactory.setId(".camelBlueprint.processor.registry.passThrough." + contextId);
-            regProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelDependenciesFinder(contextId, context)));
-
-            MutableBeanMetadata regProcessor = context.createMetadata(MutableBeanMetadata.class);
-            regProcessor.setId(".camelBlueprint.processor.registry." + contextId);
-            regProcessor.setRuntimeClass(CamelDependenciesFinder.class);
-            regProcessor.setFactoryComponent(regProcessorFactory);
-            regProcessor.setFactoryMethod("call");
-            regProcessor.setProcessor(true);
-            regProcessor.addDependsOn(".camelBlueprint.processor.bean." + contextId);
-            regProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
-            context.getComponentDefinitionRegistry().registerComponentDefinition(regProcessor);
+        return null;
+    }
 
-            return ctx;
+    private Metadata parseCamelContextNode(Element element, ParserContext context) {
+        // Find the id, generate one if needed
+        String contextId = element.getAttribute("id");
+        boolean implicitId = false;
+
+        // lets avoid folks having to explicitly give an ID to a camel context
+        if (ObjectHelper.isEmpty(contextId)) {
+            // if no explicit id was set then use a default auto generated name
+            CamelContextNameStrategy strategy = new DefaultCamelContextNameStrategy();
+            contextId = strategy.getName();
+            element.setAttribute("id", contextId);
+            implicitId = true;
         }
-        if (element.getNodeName().equals(ROUTE_CONTEXT)) {
-            // now lets parse the routes with JAXB
-            Binder<Node> binder;
-            try {
-                binder = getJaxbContext().createBinder();
-            } catch (JAXBException e) {
-                throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
-            }
-            Object value = parseUsingJaxb(element, context, binder);
-            if (!(value instanceof CamelRouteContextFactoryBean)) {
-                throw new ComponentDefinitionException("Expected an instance of " + CamelRouteContextFactoryBean.class);
-            }
-
-            CamelRouteContextFactoryBean rcfb = (CamelRouteContextFactoryBean) value;
-            String id = rcfb.getId();
-
-            MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
-            factory.setId(".camelBlueprint.passThrough." + id);
-            factory.setObject(new PassThroughCallable<Object>(rcfb));
-
-            MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
-            factory2.setId(".camelBlueprint.factory." + id);
-            factory2.setFactoryComponent(factory);
-            factory2.setFactoryMethod("call");
-
-            MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
-            ctx.setId(id);
-            ctx.setRuntimeClass(List.class);
-            ctx.setFactoryComponent(factory2);
-            ctx.setFactoryMethod("getRoutes");
 
-            return ctx;
+        // now lets parse the routes with JAXB
+        Binder<Node> binder;
+        try {
+            binder = getJaxbContext().createBinder();
+        } catch (JAXBException e) {
+            throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
         }
-        return null;
+        Object value = parseUsingJaxb(element, context, binder);
+        if (!(value instanceof CamelContextFactoryBean)) {
+            throw new ComponentDefinitionException("Expected an instance of " + CamelContextFactoryBean.class);
+        }
+
+        CamelContextFactoryBean ccfb = (CamelContextFactoryBean) value;
+        ccfb.setImplicitId(implicitId);
+
+        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
+        factory.setId(".camelBlueprint.passThrough." + contextId);
+        factory.setObject(new PassThroughCallable<Object>(value));
+
+        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
+        factory2.setId(".camelBlueprint.factory." + contextId);
+        factory2.setFactoryComponent(factory);
+        factory2.setFactoryMethod("call");
+        factory2.setInitMethod("afterPropertiesSet");
+        factory2.setDestroyMethod("destroy");
+        factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
+        factory2.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+
+        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
+        ctx.setId(contextId);
+        ctx.setRuntimeClass(BlueprintCamelContext.class);
+        ctx.setFactoryComponent(factory2);
+        ctx.setFactoryMethod("getContext");
+        ctx.setInitMethod("init");
+        ctx.setDestroyMethod("destroy");
+
+        // Register objects
+        registerBeans(context, contextId, ccfb.getEndpoints());
+        registerBeans(context, contextId, ccfb.getThreadPools());
+        registerBeans(context, contextId, ccfb.getBeans());
+
+        // Register processors
+        MutablePassThroughMetadata beanProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
+        beanProcessorFactory.setId(".camelBlueprint.processor.bean.passThrough." + contextId);
+        beanProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelInjector(contextId)));
+
+        MutableBeanMetadata beanProcessor = context.createMetadata(MutableBeanMetadata.class);
+        beanProcessor.setId(".camelBlueprint.processor.bean." + contextId);
+        beanProcessor.setRuntimeClass(CamelInjector.class);
+        beanProcessor.setFactoryComponent(beanProcessorFactory);
+        beanProcessor.setFactoryMethod("call");
+        beanProcessor.setProcessor(true);
+        beanProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
+        context.getComponentDefinitionRegistry().registerComponentDefinition(beanProcessor);
+
+        MutablePassThroughMetadata regProcessorFactory = context.createMetadata(MutablePassThroughMetadata.class);
+        regProcessorFactory.setId(".camelBlueprint.processor.registry.passThrough." + contextId);
+        regProcessorFactory.setObject(new PassThroughCallable<Object>(new CamelDependenciesFinder(contextId, context)));
+
+        MutableBeanMetadata regProcessor = context.createMetadata(MutableBeanMetadata.class);
+        regProcessor.setId(".camelBlueprint.processor.registry." + contextId);
+        regProcessor.setRuntimeClass(CamelDependenciesFinder.class);
+        regProcessor.setFactoryComponent(regProcessorFactory);
+        regProcessor.setFactoryMethod("call");
+        regProcessor.setProcessor(true);
+        regProcessor.addDependsOn(".camelBlueprint.processor.bean." + contextId);
+        regProcessor.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
+        context.getComponentDefinitionRegistry().registerComponentDefinition(regProcessor);
+        return ctx;
+    }
+
+    private Metadata parseRouteContextNode(Element element, ParserContext context) {
+        // now lets parse the routes with JAXB
+        Binder<Node> binder;
+        try {
+            binder = getJaxbContext().createBinder();
+        } catch (JAXBException e) {
+            throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
+        }
+        Object value = parseUsingJaxb(element, context, binder);
+        if (!(value instanceof CamelRouteContextFactoryBean)) {
+            throw new ComponentDefinitionException("Expected an instance of " + CamelRouteContextFactoryBean.class);
+        }
+
+        CamelRouteContextFactoryBean rcfb = (CamelRouteContextFactoryBean) value;
+        String id = rcfb.getId();
+
+        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
+        factory.setId(".camelBlueprint.passThrough." + id);
+        factory.setObject(new PassThroughCallable<Object>(rcfb));
+
+        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
+        factory2.setId(".camelBlueprint.factory." + id);
+        factory2.setFactoryComponent(factory);
+        factory2.setFactoryMethod("call");
+
+        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
+        ctx.setId(id);
+        ctx.setRuntimeClass(List.class);
+        ctx.setFactoryComponent(factory2);
+        ctx.setFactoryMethod("getRoutes");
+
+        return ctx;
+    }
+
+    private Metadata parseKeyStoreParametersNode(Element element, ParserContext context) {
+        // now lets parse the key store parameters with JAXB
+        Binder<Node> binder;
+        try {
+            binder = getJaxbContext().createBinder();
+        } catch (JAXBException e) {
+            throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
+        }
+        Object value = parseUsingJaxb(element, context, binder);
+        if (!(value instanceof KeyStoreParametersFactoryBean)) {
+            throw new ComponentDefinitionException("Expected an instance of " + KeyStoreParametersFactoryBean.class);
+        }
+
+        KeyStoreParametersFactoryBean kspfb = (KeyStoreParametersFactoryBean) value;
+        String id = kspfb.getId();
+
+        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
+        factory.setId(".camelBlueprint.passThrough." + id);
+        factory.setObject(new PassThroughCallable<Object>(kspfb));
+
+        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
+        factory2.setId(".camelBlueprint.factory." + id);
+        factory2.setFactoryComponent(factory);
+        factory2.setFactoryMethod("call");
+
+        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
+        ctx.setId(id);
+        ctx.setRuntimeClass(List.class);
+        ctx.setFactoryComponent(factory2);
+        ctx.setFactoryMethod("getObject");
+
+        return ctx;
+    }
+
+    private Metadata parseSecureRandomParametersNode(Element element, ParserContext context) {
+        // now lets parse the key store parameters with JAXB
+        Binder<Node> binder;
+        try {
+            binder = getJaxbContext().createBinder();
+        } catch (JAXBException e) {
+            throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
+        }
+        Object value = parseUsingJaxb(element, context, binder);
+        if (!(value instanceof SecureRandomParametersFactoryBean)) {
+            throw new ComponentDefinitionException("Expected an instance of " + SecureRandomParametersFactoryBean.class);
+        }
+
+        SecureRandomParametersFactoryBean srfb = (SecureRandomParametersFactoryBean) value;
+        String id = srfb.getId();
+
+        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
+        factory.setId(".camelBlueprint.passThrough." + id);
+        factory.setObject(new PassThroughCallable<Object>(srfb));
+
+        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
+        factory2.setId(".camelBlueprint.factory." + id);
+        factory2.setFactoryComponent(factory);
+        factory2.setFactoryMethod("call");
+
+        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
+        ctx.setId(id);
+        ctx.setRuntimeClass(List.class);
+        ctx.setFactoryComponent(factory2);
+        ctx.setFactoryMethod("getObject");
+
+        return ctx;
+    }
+
+    private Metadata parseSSLContextParametersNode(Element element, ParserContext context) {
+        // now lets parse the key store parameters with JAXB
+        Binder<Node> binder;
+        try {
+            binder = getJaxbContext().createBinder();
+        } catch (JAXBException e) {
+            throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
+        }
+        Object value = parseUsingJaxb(element, context, binder);
+        if (!(value instanceof SSLContextParametersFactoryBean)) {
+            throw new ComponentDefinitionException("Expected an instance of " + SSLContextParametersFactoryBean.class);
+        }
+
+        SSLContextParametersFactoryBean scpfb = (SSLContextParametersFactoryBean) value;
+        String id = scpfb.getId();
+
+        MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
+        factory.setId(".camelBlueprint.passThrough." + id);
+        factory.setObject(new PassThroughCallable<Object>(scpfb));
+
+        MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
+        factory2.setId(".camelBlueprint.factory." + id);
+        factory2.setFactoryComponent(factory);
+        factory2.setFactoryMethod("call");
+
+        MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
+        ctx.setId(id);
+        ctx.setRuntimeClass(List.class);
+        ctx.setFactoryComponent(factory2);
+        ctx.setFactoryMethod("getObject");
+
+        return ctx;
     }
 
     private void registerBeans(ParserContext context, String contextId, List<?> beans) {
@@ -329,6 +454,7 @@ public class CamelNamespaceHandler imple
         classes.add(org.apache.camel.model.dataformat.DataFormatsDefinition.class);
         classes.add(org.apache.camel.model.language.ExpressionDefinition.class);
         classes.add(org.apache.camel.model.loadbalancer.RoundRobinLoadBalancerDefinition.class);
+        classes.add(SSLContextParametersFactoryBean.class);
         return classes;
     }
 



Mime
View raw message