You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by in...@apache.org on 2010/05/11 12:29:06 UTC

svn commit: r943075 - in /synapse/trunk/java: modules/commons/src/main/java/org/apache/synapse/commons/datasource/ modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/ modules/commons/src/main/java/org/apache/synapse/commons/jmx...

Author: indika
Date: Tue May 11 10:29:05 2010
New Revision: 943075

URL: http://svn.apache.org/viewvc?rev=943075&view=rev
Log:
add support for multiple protected tokens 
fix some bug of early refractoring
tested password security and ciphertool

Added:
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/PasswordManager.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolver.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolverFactory.java
Modified:
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformationRepository.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceRepositoryHolder.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationFactory.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationRepositoryFactory.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxConfigurationConstants.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformationFactory.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxSecretAuthenticator.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/BaseCipher.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/ICACertsLoader.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecurityConstants.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SymmetricCipher.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/AbstractKeyStoreLoader.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/IdentityKeyStoreWrapper.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/KeyStoreWrapper.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/PKCS8KeyStoreLoader.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformation.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformationFactory.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretLoadingModule.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/HardCodedSecretCallbackHandler.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/JMXSecretCallbackHandler.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/SharedSecretCallbackHandler.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProvider.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProviderMBean.java
    synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/JmxAdapter.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerManager.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceFactory.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceSerializer.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java
    synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat
    synapse/trunk/java/repository/conf/synapse.properties

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformationRepository.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformationRepository.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformationRepository.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformationRepository.java Tue May 11 10:29:05 2010
@@ -21,6 +21,9 @@ package org.apache.synapse.commons.datas
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.commons.SynapseCommonsException;
+import org.apache.synapse.commons.security.SecretResolver;
+import org.apache.synapse.commons.security.SecretResolverFactory;
+import org.apache.synapse.commons.security.secret.SecretInformation;
 
 import java.util.HashMap;
 import java.util.Iterator;
@@ -41,14 +44,21 @@ public class DataSourceInformationReposi
     private DataSourceInformationRepositoryListener listener;
 
     /**
+     * The global secret resolver of the datasources
+     */
+    private SecretResolver secretResolver;
+
+    /**
      * Configuring DataSourceInformationRepository
      *
      * @param configurationProperties properties to be used for configure
      */
-    public void setConfigurationProperties(Properties configurationProperties) {
+    public void configure(Properties configurationProperties) {
         if (listener != null) {
             listener.reConfigure(configurationProperties);
         }
+        secretResolver = SecretResolverFactory.create(configurationProperties,
+                DataSourceConstants.PROP_SYNAPSE_PREFIX_DS);
     }
 
     /**
@@ -62,6 +72,12 @@ public class DataSourceInformationReposi
             throw new SynapseCommonsException("DataSource information is null", log);
         }
 
+        // Sets the global secret resolver
+        SecretInformation secretInformation = dataSourceInformation.getSecretInformation();
+        if (secretInformation != null) {
+            secretInformation.setGlobalSecretResolver(secretResolver);
+        }
+
         dataSourceInformationMap.put(dataSourceInformation.getAlias(), dataSourceInformation);
         if (assertListerNotNull()) {
             listener.addDataSourceInformation(dataSourceInformation);

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceRepositoryHolder.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceRepositoryHolder.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceRepositoryHolder.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceRepositoryHolder.java Tue May 11 10:29:05 2010
@@ -33,7 +33,7 @@ public class DataSourceRepositoryHolder 
 
     private static final Log log = LogFactory.getLog(DataSourceRepositoryHolder.class);
 
-    private static final DataSourceRepositoryHolder DATA_SOURCE_REPOSITORY_HOLDER 
+    private static final DataSourceRepositoryHolder DATA_SOURCE_REPOSITORY_HOLDER
             = new DataSourceRepositoryHolder();
 
     private DataSourceInformationRepository dataSourceInformationRepository;
@@ -95,7 +95,7 @@ public class DataSourceRepositoryHolder 
                     DataSourceInformationRepositoryFactory.createDataSourceInformationRepository(
                             repositoryListener, properties);
         } else {
-            DataSourceInformationRepositoryFactory.setupDatasourceInformationRepository(
+            DataSourceInformationRepositoryFactory.setupDataSourceInformationRepository(
                     repository, properties);
         }
         dataSourceInformationRepository = repository;

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationFactory.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationFactory.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationFactory.java Tue May 11 10:29:05 2010
@@ -198,7 +198,7 @@ public class DataSourceInformationFactor
                 MiscellaneousUtil.getProperty(properties,
                         prefix +
                                 DataSourceConstants.
-                                    PROP_ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED,
+                                        PROP_ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED,
                         false, Boolean.class);
 
         boolean removeAbandoned = MiscellaneousUtil.getProperty(properties,
@@ -272,7 +272,7 @@ public class DataSourceInformationFactor
 
         SecretInformation secretInformation = SecretInformationFactory.createSecretInformation(
                 properties, prefix, passwordPrompt);
-
+        secretInformation.setToken(dsName + "." + SecurityConstants.PROP_PASSWORD);
         datasourceInformation.setSecretInformation(secretInformation);
 
         return datasourceInformation;

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationRepositoryFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationRepositoryFactory.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationRepositoryFactory.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/factory/DataSourceInformationRepositoryFactory.java Tue May 11 10:29:05 2010
@@ -64,7 +64,7 @@ public class DataSourceInformationReposi
                 new DataSourceInformationRepository();
 
         datasourceInformationRepository.setRepositoryListener(listener);
-        setupDatasourceInformationRepository(datasourceInformationRepository, properties);
+        setupDataSourceInformationRepository(datasourceInformationRepository, properties);
 
         return datasourceInformationRepository;
     }
@@ -77,12 +77,12 @@ public class DataSourceInformationReposi
      *                   an existing data source information repository
      * @param properties DataSource properties
      */
-    public static void setupDatasourceInformationRepository(
+    public static void setupDataSourceInformationRepository(
             DataSourceInformationRepository datasourceInformationRepository,
             Properties properties) {
 
         if (properties != null) {
-            datasourceInformationRepository.setConfigurationProperties(properties);
+            datasourceInformationRepository.configure(properties);
         }
         List<DataSourceInformation> sourceInformationList =
                 DataSourceInformationListFactory.createDataSourceInformationList(properties);

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxConfigurationConstants.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxConfigurationConstants.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxConfigurationConstants.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxConfigurationConstants.java Tue May 11 10:29:05 2010
@@ -21,9 +21,11 @@ package org.apache.synapse.commons.jmx;
 
 public class JmxConfigurationConstants {
     
-    /** Prefix for all properties in property file*/
+     /** Token for jmx password*/
+    public static final String JMX_PROTECTED_TOKEN = "jmx.password";
+     /** Prefix for all properties in property file*/
     public static final String PROP_SYNAPSE_PREFIX_JMX = "synapse.jmx.";
-    
+
     /** JNDI port property used for the JMX naming directory (RMI registry) */
     public static final String PROP_JNDI_PORT = "jndiPort";
     

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformationFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformationFactory.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformationFactory.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformationFactory.java Tue May 11 10:29:05 2010
@@ -38,7 +38,7 @@ import java.util.Properties;
 public class JmxInformationFactory {
 
     private static final Log log = LogFactory.getLog(JmxInformationFactory.class);
-    
+
     private JmxInformationFactory() {
     }
 
@@ -49,25 +49,26 @@ public class JmxInformationFactory {
      * @return DataSourceInformation instance
      */
     public static JmxInformation createJmxInformation(Properties properties, String defaultHostName) {
-        
+
         // Prefix for getting particular JMX properties
         String prefix = JmxConfigurationConstants.PROP_SYNAPSE_PREFIX_JMX;
-        
+
         JmxInformation jmxInformation = new JmxInformation();
 
         SecretInformation secretInformation = SecretInformationFactory.createSecretInformation(
                 properties, prefix, null);
+        secretInformation.setToken(JmxConfigurationConstants.JMX_PROTECTED_TOKEN);
 
         jmxInformation.setSecretInformation(secretInformation);
-        
+
         int jndiPort = MiscellaneousUtil.getProperty(
                 properties, prefix + JmxConfigurationConstants.PROP_JNDI_PORT, -1, Integer.class);
         jmxInformation.setJndiPort(jndiPort);
-        
+
         int rmiPort = MiscellaneousUtil.getProperty(
                 properties, prefix + JmxConfigurationConstants.PROP_RMI_PORT, 0, Integer.class);
         jmxInformation.setRmiPort(rmiPort);
-        
+
         String jmxHostName = MiscellaneousUtil.getProperty(
                 properties, prefix + JmxConfigurationConstants.PROP_HOSTNAME, null);
         if (jmxHostName == null || jmxHostName.trim().length() == 0) {
@@ -77,7 +78,7 @@ public class JmxInformationFactory {
 
         // begin of special JMX security options
         Properties managementProperties = readManagementProperties();
-        
+
         Boolean authenticate;
         String value = getConfigProperty(
                 managementProperties, "com.sun.management.jmxremote.authenticate");
@@ -91,7 +92,7 @@ public class JmxInformationFactory {
             }
         }
         jmxInformation.setAuthenticate(authenticate);
-        
+
         value = getConfigProperty(managementProperties, "com.sun.management.jmxremote.access.file");
         if (value == null || value.trim().length() == 0) {
             value = MiscellaneousUtil.getProperty(
@@ -100,33 +101,33 @@ public class JmxInformationFactory {
         if (value != null && value.trim().length() > 0) {
             jmxInformation.setRemoteAccessFile(value);
         }
-        
+
         value = getConfigProperty(managementProperties, "com.sun.management.jmxremote.password.file");
         if (value != null && value.trim().length() > 0) {
             jmxInformation.setRemotePasswordFile(value);
         }
-        
+
         Boolean remoteSSL;
         value = getConfigProperty(managementProperties, "com.sun.management.jmxremote.ssl");
         if (value != null) {
             remoteSSL = Boolean.valueOf(value);
         } else {
-            remoteSSL = MiscellaneousUtil.getProperty( properties, 
+            remoteSSL = MiscellaneousUtil.getProperty( properties,
                 prefix + JmxConfigurationConstants.PROP_REMOTE_SSL, Boolean.FALSE, Boolean.class);
         }
         jmxInformation.setRemoteSSL(remoteSSL);
-        
+
         return jmxInformation;
     }
-    
+
     /**
      * Retrieves the management properties if a JMX config file has been specified via the system
      * property <code>com.sun.management.config.file</code>.
-     * 
+     *
      * @return JMX management properties
      */
     private static Properties readManagementProperties() {
-        
+
         Properties managementProperties = new Properties();
         String configFileName = System.getProperty("com.sun.management.config.file");
         if (configFileName != null) {
@@ -153,7 +154,7 @@ public class JmxInformationFactory {
         }
         return managementProperties;
     }
-    
+
     /**
      * Retrieves a JMX configuration property (first by looking for a Java system property and if
      * not present by looking for a management property specified in a file specified via<code>

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxSecretAuthenticator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxSecretAuthenticator.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxSecretAuthenticator.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxSecretAuthenticator.java Tue May 11 10:29:05 2010
@@ -33,11 +33,11 @@ import java.util.Collections;
 public class JmxSecretAuthenticator implements JMXAuthenticator {
 
     private SecretInformation secretInformation;
-    
+
     public JmxSecretAuthenticator(SecretInformation secretInformation) {
         this.secretInformation = secretInformation;
     }
-    
+
     public Subject authenticate(Object credentials) {
 
         if (credentials == null) {
@@ -58,7 +58,8 @@ public class JmxSecretAuthenticator impl
         String password = (aCredentials[1] != null ? aCredentials[1] : "");
 
         // perform authentication
-        if (secretInformation.getUser().equals(username) && password.equals(secretInformation.getResolvedSecret())) {
+        if (secretInformation.getUser().equals(username) &&
+                password.equals(secretInformation.getResolvedSecret())) {
             return new Subject(true,
                 Collections.singleton(new JMXPrincipal(username)),
                 Collections.EMPTY_SET,

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/BaseCipher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/BaseCipher.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/BaseCipher.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/BaseCipher.java Tue May 11 10:29:05 2010
@@ -28,6 +28,7 @@ import org.apache.synapse.commons.securi
 import org.apache.synapse.commons.security.keystore.IdentityKeyStoreWrapper;
 import org.apache.synapse.commons.security.keystore.KeyStoreWrapper;
 import org.apache.synapse.commons.security.keystore.TrustKeyStoreWrapper;
+import org.apache.synapse.commons.security.secret.SecretInformation;
 
 import javax.crypto.Cipher;
 import javax.crypto.CipherOutputStream;
@@ -64,9 +65,14 @@ public abstract class BaseCipher impleme
                     (TrustKeyStoreInformation) keystoreInformation);
         } else {
             keyStoreWrapper = new IdentityKeyStoreWrapper();
-            ((IdentityKeyStoreWrapper) keyStoreWrapper).init(
-                    (IdentityKeyStoreInformation) keystoreInformation,
-                    ((IdentityKeyStoreInformation) keystoreInformation).getKeyPasswordProvider().getResolvedSecret());
+            IdentityKeyStoreInformation identityKeyStore =
+                    (IdentityKeyStoreInformation) keystoreInformation;
+
+            SecretInformation secretInformation = identityKeyStore.getKeyPasswordProvider();
+            if (secretInformation != null) { //TODO validate
+                ((IdentityKeyStoreWrapper) keyStoreWrapper).init(identityKeyStore,
+                        secretInformation.getResolvedSecret());
+            }
         }
         init();
     }
@@ -96,12 +102,12 @@ public abstract class BaseCipher impleme
                     "'" + algorithm + "' in mode '" + opMode + "'");
         }
         try {
-            String provdier = cipherInformation.getProvider();
-            if (provdier != null && !"".equals(provdier)) {
+            String provider = cipherInformation.getProvider();
+            if (provider != null && !"".equals(provider)) {
                 try {
-                    cipher = Cipher.getInstance(algorithm, provdier.trim());
+                    cipher = Cipher.getInstance(algorithm, provider.trim());
                 } catch (NoSuchProviderException e) {
-                    throw new SynapseCommonsException("Invalid Provider : " + provdier, log);
+                    throw new SynapseCommonsException("Invalid Provider : " + provider, log);
                 }
             } else {
                 cipher = Cipher.getInstance(algorithm);
@@ -129,7 +135,7 @@ public abstract class BaseCipher impleme
         return cipherInformation;
     }
 
-    public KeyStoreInformation getKeystoreInformation() {
+    public KeyStoreInformation getKeyStoreInformation() {
         return keystoreInformation;
     }
 
@@ -142,7 +148,7 @@ public abstract class BaseCipher impleme
     public abstract Key getKey(CipherOperationMode operationMode);
 
     /**
-     * Do crypto graphic operation
+     * Do cryptographic operation
      *
      * @param inputStream Input Stream
      * @return result

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/ICACertsLoader.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/ICACertsLoader.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/ICACertsLoader.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/ICACertsLoader.java Tue May 11 10:29:05 2010
@@ -22,7 +22,7 @@ import java.security.KeyStore;
 
 /**
  * ICACertsLoader provides an uniform interface to create a keyStore containing CA certs
- * (truststore)
+ * (trust store)
  */
 public interface ICACertsLoader {
     /**

Added: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/PasswordManager.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/PasswordManager.java?rev=943075&view=auto
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/PasswordManager.java (added)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/PasswordManager.java Tue May 11 10:29:05 2010
@@ -0,0 +1,94 @@
+/*
+ *  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.synapse.commons.security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.commons.SynapseCommonsException;
+
+import java.util.Properties;
+
+/**
+ * Wraps a SecretResolver  and exposes as a singleton PasswordManager
+ * TODO - more doc
+ */
+public class PasswordManager {
+
+    private static final Log log = LogFactory.getLog(PasswordManager.class);
+
+    private static PasswordManager ourInstance = new PasswordManager();
+
+    private SecretResolver secretResolver;
+
+    private boolean initialized = false;
+
+    public static PasswordManager getInstance() {
+        return ourInstance;
+    }
+
+    private PasswordManager() {
+    }
+
+    public void init(Properties properties, String prefix) {
+        secretResolver = SecretResolverFactory.create(properties, prefix);
+        initialized = secretResolver.isInitialized();
+    }
+
+    public String resolve(String encryptedPassword) {
+        assertInitialized();
+        return secretResolver.resolve(encryptedPassword);
+    }
+
+    public boolean isInitialized() {
+        return initialized;
+    }
+
+    public void addProtectedToken(String token) {
+        assertInitialized();
+        secretResolver.addProtectedToken(token);
+
+    }
+
+    public boolean isTokenProtected(String token) {
+        assertInitialized();
+        return secretResolver.isTokenProtected(token);
+    }
+
+    public void shutDown() {
+        assertInitialized();
+        initialized = false;
+        secretResolver = null;
+    }
+
+    private void assertInitialized() {
+        if (!initialized) {
+            handleException("PasswordManager has not been initialized");
+        }
+    }
+
+    private void handleException(String msg) {
+        log.error(msg);
+        throw new SynapseCommonsException(msg);
+    }
+
+    public SecretResolver getSecretResolver() {
+        assertInitialized();
+        return secretResolver;
+    }
+}

Added: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolver.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolver.java?rev=943075&view=auto
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolver.java (added)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolver.java Tue May 11 10:29:05 2010
@@ -0,0 +1,165 @@
+/*
+ *  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.synapse.commons.security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.commons.SynapseCommonsException;
+import org.apache.synapse.commons.security.secret.SecretCallback;
+import org.apache.synapse.commons.security.secret.SecretCallbackHandler;
+import org.apache.synapse.commons.security.secret.SecretLoadingModule;
+import org.apache.synapse.commons.security.secret.SingleSecretCallback;
+
+import java.util.ArrayList;
+
+/**
+ * Responsible for resolving secrets such as password. The secrets this SecretResolver should be
+ * resolved , can be  given as protected Tokens and the use of this class can explicitly check
+ * whether a token is protected.
+ */
+public class SecretResolver {
+
+    private static Log log = LogFactory.getLog(SecretResolver.class);
+
+    private boolean initialized = false;
+
+    private final ArrayList<String> protectedTokens = new ArrayList<String>();
+
+    private SecretLoadingModule secretLoadingModule;
+
+    private final static String DEFAULT_PROMPT = "password > ";
+
+    /**
+     * Initializes by giving an instance of <code>SecretCallbackHandler </code> to be used to
+     * retrieve secrets
+     *
+     * @param secretCallbackHandler <code>SecretCallbackHandler </code> instance
+     */
+    public void init(SecretCallbackHandler secretCallbackHandler) {
+
+        if (initialized) {
+            if (log.isDebugEnabled()) {
+                log.debug("SecretResolver already has been started.");
+            }
+            return;
+        }
+
+        if (secretCallbackHandler == null) {
+            throw new SynapseCommonsException("SecretResolver cannot be initialized. " +
+                    "The provided SecretCallbackHandler is null", log);
+
+        }
+
+        this.secretLoadingModule = new SecretLoadingModule();
+        this.secretLoadingModule.init(new SecretCallbackHandler[]{secretCallbackHandler});
+        this.initialized = true;
+    }
+
+    /**
+     * Resolved given password using an instance of a PasswordProvider
+     *
+     * @param encryptedPassword Encrypted password
+     * @return resolved password
+     */
+    public String resolve(String encryptedPassword) {
+
+        return resolve(encryptedPassword, DEFAULT_PROMPT);
+    }
+
+    /**
+     * Resolved given password using an instance of a PasswordProvider
+     *
+     * @param encryptedPassword Encrypted password
+     * @param prompt            to be used to interact with user
+     * @return resolved password
+     */
+    public String resolve(String encryptedPassword, String prompt) {
+
+        assertInitialized();
+
+        if (encryptedPassword == null || "".equals(encryptedPassword)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Given Encrypted Password is empty or null. Returning itself");
+            }
+            return encryptedPassword;
+        }
+
+        SingleSecretCallback secretCallback = new SingleSecretCallback(encryptedPassword);
+
+        secretCallback.setPrompt(prompt);
+
+        secretLoadingModule.load(new SecretCallback[]{secretCallback});
+
+        String plainText = secretCallback.getSecret();
+
+        log.info("Secret : " + encryptedPassword + " PlainText : " + plainText);
+
+        return plainText;
+    }
+
+    /**
+     * Registers a token as a Protected Token
+     *
+     * @param token <code>String</code> representation of a token
+     */
+    public void addProtectedToken(String token) {
+        assertInitialized();
+        if (token != null && !"".equals(token)) {
+            protectedTokens.add(token.trim());
+        }
+    }
+
+    /**
+     * Checks whether a token is a Protected Token
+     *
+     * @param token <code>String</code> representation of a token
+     * @return <code>true</code> if the token is a Protected Token
+     */
+    public boolean isTokenProtected(String token) {
+        assertInitialized();
+        return token != null && !"".equals(token) && protectedTokens.contains(token.trim());
+    }
+
+    /**
+     * Checks the state of the rule engine.
+     * It is recommended to check state of the this component prior to access any methods of this
+     *
+     * @return <code>true<code> if the rule engine has been initialized
+     */
+    public boolean isInitialized() {
+        return initialized;
+    }
+
+    private void assertInitialized() {
+        if (!initialized) {
+            throw new SynapseCommonsException("SecretResolver has not been initialized, " +
+                    "it requires to be initialized, with the required " +
+                    "configurations before starting", log);
+        }
+    }
+
+    /**
+     * Shutdown the secret resolver
+     */
+    public void shutDown() {
+        initialized = false;
+        secretLoadingModule = null;
+        protectedTokens.clear();
+    }
+}

Added: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolverFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolverFactory.java?rev=943075&view=auto
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolverFactory.java (added)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecretResolverFactory.java Tue May 11 10:29:05 2010
@@ -0,0 +1,176 @@
+/*
+ *  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.synapse.commons.security;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.commons.security.secret.SecretCallbackHandler;
+import org.apache.synapse.commons.security.secret.SecretCallbackHandlerFactory;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Factory for creating <code>SecretResolver</code> instances
+ */
+public class SecretResolverFactory {
+
+    /**
+     * Creates an <code>SecretResolver</code> instance from an XML
+     *
+     * @param configuration <code>SecretResolver</code> configuration as XML object
+     * @param isCapLetter   whether the XML element begins with a cap letter
+     * @return an <code>SecretResolver</code> instance
+     */
+    public static SecretResolver create(OMElement configuration, boolean isCapLetter) {
+
+        SecretResolver secretResolver = new SecretResolver();
+
+        QName pwProviderQName;
+        QName protectedTokensQName;
+        QName pwManagerQName;
+
+        QName parentQName = configuration.getQName();
+        String nsURI = parentQName != null ? parentQName.getNamespaceURI() :
+                XMLConstants.NULL_NS_URI;
+        String nsPrefix = parentQName != null ? parentQName.getPrefix() :
+                XMLConstants.DEFAULT_NS_PREFIX;
+
+        if (!isCapLetter) {
+            pwManagerQName = new QName(nsURI, SecurityConstants.PASSWORD_MANAGER_SIMPLE, nsPrefix);
+            pwProviderQName = new QName(nsURI, SecurityConstants.PASSWORD_PROVIDER_SIMPLE,
+                    nsPrefix);
+            protectedTokensQName = new QName(nsURI, SecurityConstants.PROTECTED_TOKENS_SIMPLE,
+                    nsPrefix);
+        } else {
+            pwManagerQName = new QName(nsURI, SecurityConstants.PASSWORD_MANAGER_CAP, nsPrefix);
+            pwProviderQName = new QName(nsURI, SecurityConstants.PASSWORD_PROVIDER_CAP, nsPrefix);
+            protectedTokensQName = new QName(nsURI, SecurityConstants.PROTECTED_TOKENS_CAP,
+                    nsPrefix);
+        }
+
+        OMElement child = configuration.getFirstChildWithName(pwManagerQName);
+        if (child == null) {
+            return secretResolver;
+        }
+        OMElement passwordProviderElement = child.getFirstChildWithName(pwProviderQName);
+
+        if (passwordProviderElement != null) {
+            initPasswordManager(secretResolver, passwordProviderElement.getText());
+            if (secretResolver.isInitialized()) {
+                OMElement protectedTokensElement =
+                        child.getFirstChildWithName(protectedTokensQName);
+                if (protectedTokensElement != null) {
+                    String value = protectedTokensElement.getText();
+                    if (value != null && value.trim().length() > 0) {
+                        List<String> protectedTokens = new ArrayList<String>(Arrays
+                                .asList(value.split(",")));
+                        for (String token : protectedTokens) {
+                            secretResolver.addProtectedToken(token);
+                        }
+                    }
+                }
+            }
+        }
+        return secretResolver;
+    }
+
+    /**
+     * Creates an <code>SecretResolver</code> instance from a set of property
+     *
+     * @param properties     configuration properties
+     * @param propertyPrefix prefix to identify suitable configuration properties
+     * @return an <code>SecretResolver</code> instance
+     */
+    public static SecretResolver create(Properties properties, String propertyPrefix) {
+
+        SecretResolver secretResolver = new SecretResolver();
+
+        String prefix = propertyPrefix;
+        if (propertyPrefix != null && !"".equals(propertyPrefix) && !propertyPrefix.endsWith(".")) {
+            prefix += ".";
+        }
+        initPasswordManager(secretResolver, properties.getProperty(prefix +
+                SecurityConstants.PASSWORD_PROVIDER_SIMPLE));
+
+        if (secretResolver.isInitialized()) {
+            String protectedTokens = properties.getProperty(prefix +
+                    SecurityConstants.PROTECTED_TOKENS_SIMPLE);
+            if (protectedTokens != null && !"".equals(protectedTokens.trim())) {
+                ArrayList<String> tokens = new ArrayList<String>(Arrays
+                        .asList(protectedTokens.split(",")));
+                for (String token : tokens) {
+                    secretResolver.addProtectedToken(token);
+                }
+            }
+        }
+        return secretResolver;
+    }
+
+    /**
+     * Creates an <code>SecretResolver</code> instance from a set of DOM Node
+     *
+     * @param namedNodeMap DOM node set
+     * @return an <code>SecretResolver</code> instance
+     */
+    public static SecretResolver create(NamedNodeMap namedNodeMap) {
+
+        SecretResolver secretResolver = new SecretResolver();
+
+        Node namedItem = namedNodeMap.getNamedItem(SecurityConstants.PASSWORD_PROVIDER_SIMPLE);
+        if (namedItem != null) {
+            String passwordProvider = namedItem.getNodeValue();
+            if (passwordProvider != null && passwordProvider.trim().length() > 0) {
+                initPasswordManager(secretResolver, passwordProvider);
+            }
+        }
+
+        if (secretResolver.isInitialized()) {
+            Node protectedTokenAttr = namedNodeMap.getNamedItem(
+                    SecurityConstants.PROTECTED_TOKENS_SIMPLE);
+            ArrayList<String> protectedTokenList;
+            if (protectedTokenAttr != null) {
+                String protectedTokens = protectedTokenAttr.getNodeValue();
+                if (protectedTokens != null && protectedTokens.trim().length() > 0) {
+                    protectedTokenList = new ArrayList<String>(Arrays.asList(protectedTokens
+                            .split(",")));
+                    for (String token : protectedTokenList) {
+                        if (token != null && !"".equals(token)) {
+                            secretResolver.addProtectedToken(token);
+                        }
+                    }
+                }
+            }
+        }
+        return secretResolver;
+    }
+
+    private static void initPasswordManager(SecretResolver secretResolver, String provider) {
+        SecretCallbackHandler callbackHandler =
+                SecretCallbackHandlerFactory.createSecretCallbackHandler(provider);
+        if (callbackHandler != null) {
+            secretResolver.init(callbackHandler);
+        }
+    }
+}

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecurityConstants.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecurityConstants.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecurityConstants.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SecurityConstants.java Tue May 11 10:29:05 2010
@@ -20,12 +20,16 @@ package org.apache.synapse.commons.secur
 
 public class SecurityConstants {
 
-    public static final String GLOBAL_PREFIX = "synapse.";
     public static final String PROP_USER_NAME = "username";
     public static final String PROP_PASSWORD = "password";
-    public static final String PROP_SECRET_PROVIDER = "secretProvider";
     public static final String PROP_PASSWORD_PROMPT = "passwordPrompt";
     public static final String PROP_SECRET_CALLBACK_HANDLER = "SharedSecretCallbackHandler";
     public static final String PROP_SECURITY_ADMIN_SERVICES = "SecurityAdminServices";
     public static final String PROP_SECRET_MANAGER_ADMIN_MBEAN = "SecretManagerAdmin";
+    public static final String PASSWORD_MANAGER_SIMPLE = "passwordManager";
+    public static final String PASSWORD_PROVIDER_SIMPLE = "passwordProvider";
+    public static final String PROTECTED_TOKENS_SIMPLE = "protectedTokens";
+    public static final String PASSWORD_MANAGER_CAP = "PasswordManager";
+    public static final String PASSWORD_PROVIDER_CAP = "PasswordProvider";
+    public static final String PROTECTED_TOKENS_CAP = "ProtectedTokens";
 }

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SymmetricCipher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SymmetricCipher.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SymmetricCipher.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/SymmetricCipher.java Tue May 11 10:29:05 2010
@@ -27,7 +27,7 @@ import javax.crypto.spec.SecretKeySpec;
 import java.security.Key;
 
 /**
- * The Cipher doing symmetric cryptographic operations  
+ * The Cipher doing symmetric cryptographic operations
  * Uses default key when these is no SecretKey
  */
 public class SymmetricCipher extends BaseCipher {
@@ -60,7 +60,7 @@ public class SymmetricCipher extends Bas
     }
 
     private SecretKeySpec createDefaultKey() {
-        //TODO use key generator
+        //TODO use akey generator
         byte[] keyBytes = new byte[]{
                 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/AbstractKeyStoreLoader.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/AbstractKeyStoreLoader.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/AbstractKeyStoreLoader.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/AbstractKeyStoreLoader.java Tue May 11 10:29:05 2010
@@ -54,7 +54,9 @@ public abstract class AbstractKeyStoreLo
      * @param provider      Provider
      * @return KeyStore Instance
      */
-    protected KeyStore getKeyStore(String location, String storePassword, String storeType, String provider) {
+    protected KeyStore getKeyStore(String location, String storePassword,
+                                   String storeType,
+                                   String provider) {
 
         File keyStoreFile = new File(location);
         if (!keyStoreFile.exists()) {

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/IdentityKeyStoreWrapper.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/IdentityKeyStoreWrapper.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/IdentityKeyStoreWrapper.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/IdentityKeyStoreWrapper.java Tue May 11 10:29:05 2010
@@ -31,10 +31,6 @@ import java.security.PrivateKey;
  */
 public class IdentityKeyStoreWrapper extends KeyStoreWrapper {
 
-    /**
-     * @see KeyStoreWrapper
-     *      #init(KeyStoreInformation, String, String)
-     */
     public void init(IdentityKeyStoreInformation information, String keyPassword) {
         super.init(information, keyPassword);
     }

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/KeyStoreWrapper.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/KeyStoreWrapper.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/KeyStoreWrapper.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/KeyStoreWrapper.java Tue May 11 10:29:05 2010
@@ -47,7 +47,7 @@ public abstract class KeyStoreWrapper {
     }
 
     /**
-     * Initialize the KeyStore wrapper based on provided KeyStoreinformation and passwords
+     * Initialize the KeyStore wrapper based on provided KeyStoreInformation and passwords
      *
      * @param information The object that has encapsulated all information for a
      *                    keyStore excepts passwords

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/PKCS8KeyStoreLoader.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/PKCS8KeyStoreLoader.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/PKCS8KeyStoreLoader.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/keystore/PKCS8KeyStoreLoader.java Tue May 11 10:29:05 2010
@@ -39,7 +39,9 @@ public class PKCS8KeyStoreLoader impleme
      *                            back from the keystore.
      * @param entryAlias          - alias for the given entry within the keystore.
      */
-    public PKCS8KeyStoreLoader(String pkcs8PrivateKeyPath, String certFilePath, String keyPass, String entryAlias) {
+    public PKCS8KeyStoreLoader(String pkcs8PrivateKeyPath, String certFilePath,
+                               String keyPass,
+                               String entryAlias) {
         pkPath = pkcs8PrivateKeyPath;
         certPath = certFilePath;
         keyPassword = keyPass;

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformation.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformation.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformation.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformation.java Tue May 11 10:29:05 2010
@@ -18,16 +18,21 @@
  */
 package org.apache.synapse.commons.security.secret;
 
+import org.apache.synapse.commons.security.SecretResolver;
+
 
 /**
  * Encapsulates the All information related to a DataSource
+ * TODO - properly remove SecretResolve instances
  */
 public class SecretInformation {
 
     private String user;
     private String aliasSecret;
     private String secretPrompt;
-    private SecretCallbackHandler secretProvider;
+    private SecretResolver localSecretResolver;
+    private SecretResolver globalSecretResolver;
+    private String token;
 
     public String getUser() {
         return user;
@@ -61,33 +66,48 @@ public class SecretInformation {
      */
     public String getResolvedSecret() {
 
-        if (secretProvider != null) {
+        SecretResolver secretResolver = null;
+
+        if (localSecretResolver != null && localSecretResolver.isInitialized()) {
+            secretResolver = localSecretResolver;
+        } else if (globalSecretResolver != null && globalSecretResolver.isInitialized()
+                && globalSecretResolver.isTokenProtected(token)) {
+            secretResolver = globalSecretResolver;
+        }
+
+        if (secretResolver != null) {
             if (aliasSecret != null && !"".equals(aliasSecret)) {
-                return getSecret(secretProvider, aliasSecret, secretPrompt);
+                if (secretPrompt == null) {
+                    return secretResolver.resolve(aliasSecret);
+                } else {
+                    return secretResolver.resolve(aliasSecret, secretPrompt);
+                }
             }
         }
         return aliasSecret;
     }
 
-    public SecretCallbackHandler getSecretProvider() {
-        return secretProvider;
+    public SecretResolver getLocalSecretResolver() {
+        return localSecretResolver;
     }
 
-    public void setSecretProvider(SecretCallbackHandler secretProvider) {
-        this.secretProvider = secretProvider;
+    public void setLocalSecretResolver(SecretResolver localSecretResolver) {
+        this.localSecretResolver = localSecretResolver;
     }
 
-    private String getSecret(SecretCallbackHandler secretCallbackHanlder,
-                             String encryptedPassword, String prompt) {
-        SecretLoadingModule secretLoadingModule = new SecretLoadingModule();
-        secretLoadingModule.init(new SecretCallbackHandler[]{secretCallbackHanlder});
-        SingleSecretCallback secretCallback = new SingleSecretCallback(encryptedPassword);
-        if (prompt != null) {
-            secretCallback.setPrompt(prompt);
-        }
-        secretLoadingModule.load(new SecretCallback[]{secretCallback});
-        return secretCallback.getSecret();
+    public SecretResolver getGlobalSecretResolver() {
+        return globalSecretResolver;
     }
 
+    public void setGlobalSecretResolver(SecretResolver globalSecretResolver) {
+        this.globalSecretResolver = globalSecretResolver;
+    }
+
+    public String getToken() {
+        return token;
+    }
 
+    public void setToken(String token) {
+        this.token = token;
+    }
 }

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformationFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformationFactory.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformationFactory.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretInformationFactory.java Tue May 11 10:29:05 2010
@@ -20,6 +20,8 @@ package org.apache.synapse.commons.secur
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.commons.security.SecretResolver;
+import org.apache.synapse.commons.security.SecretResolverFactory;
 import org.apache.synapse.commons.security.SecurityConstants;
 import org.apache.synapse.commons.util.MiscellaneousUtil;
 
@@ -65,19 +67,9 @@ public class SecretInformationFactory {
             secretInformation.setAliasSecret(password);
         }
 
-        // set specific password provider if configured
-        SecretCallbackHandler passwordProvider =
-                SecretCallbackHandlerFactory.createSecretCallbackHandler(properties,
-                        configurationPrefix + SecurityConstants.PROP_SECRET_PROVIDER);
-
-        // if no specific password provider configured, use default password provider
-        if (passwordProvider == null) {
-            passwordProvider = SecretCallbackHandlerFactory.createSecretCallbackHandler(
-                    properties,
-                    SecurityConstants.GLOBAL_PREFIX
-                            + SecurityConstants.PROP_SECRET_PROVIDER);
-        }
-        secretInformation.setSecretProvider(passwordProvider);
+        SecretResolver secretResolver = SecretResolverFactory.create(properties,
+                configurationPrefix);
+        secretInformation.setLocalSecretResolver(secretResolver);
         secretInformation.setSecretPrompt(passwordPrompt);
 
         return secretInformation;
@@ -98,8 +90,10 @@ public class SecretInformationFactory {
 
         SecretInformation secretInformation = new SecretInformation();
         secretInformation.setAliasSecret(aliasPassword);
-        secretInformation.setSecretProvider(
+        SecretResolver secretResolver = new SecretResolver();
+        secretResolver.init(
                 SecretCallbackHandlerFactory.createSecretCallbackHandler(secretProvider));
+        secretInformation.setLocalSecretResolver(secretResolver);
         secretInformation.setSecretPrompt(passwordPrompt);
         return secretInformation;
     }

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretLoadingModule.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretLoadingModule.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretLoadingModule.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/SecretLoadingModule.java Tue May 11 10:29:05 2010
@@ -43,13 +43,13 @@ public class SecretLoadingModule {
     }
 
     /**
-     * Load secrets into given clasbacks. Use all registered call back handlers
+     * Load secrets into given call backs. Use all registered call back handlers
      *
      * @param secretCallbacks SecretCallbacks
      */
     public void load(SecretCallback[] secretCallbacks) {
         for (SecretCallbackHandler secretCallbackHandler : secretCallbackHandlers) {
-            if (secretCallbackHandler != null) {
+            if (secretCallbackHandler != null) {    //TODO
                 secretCallbackHandler.handle(secretCallbacks);
             }
         }

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/HardCodedSecretCallbackHandler.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/HardCodedSecretCallbackHandler.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/HardCodedSecretCallbackHandler.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/HardCodedSecretCallbackHandler.java Tue May 11 10:29:05 2010
@@ -24,7 +24,7 @@ import org.apache.synapse.commons.securi
 /**
  * Hard-coded passwords as secrets .This is just a demonstration example and need to be adopted
  * as user requirements. In the production environment, this may be 'close sourced' - only provided
- * a binary contains implementation class. Then, it is needed to use de- compliers to see password.
+ * a binary contains implementation class. Then, it is needed to use de- compilers to see password.
  */
 public class HardCodedSecretCallbackHandler extends AbstractSecretCallbackHandler {
 

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/JMXSecretCallbackHandler.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/JMXSecretCallbackHandler.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/JMXSecretCallbackHandler.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/JMXSecretCallbackHandler.java Tue May 11 10:29:05 2010
@@ -24,7 +24,7 @@ import org.apache.synapse.commons.securi
 import org.apache.synapse.commons.security.secret.mbean.JMXSecretsProvider;
 
 /**
- * Get and propagates secrets that have been colleted through JMX Mean
+ * Get and propagates secrets that have been collected through JMX Mean
  */
 public class JMXSecretCallbackHandler extends AbstractSecretCallbackHandler {
 

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/SharedSecretCallbackHandler.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/SharedSecretCallbackHandler.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/SharedSecretCallbackHandler.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/handler/SharedSecretCallbackHandler.java Tue May 11 10:29:05 2010
@@ -37,7 +37,7 @@ public class SharedSecretCallbackHandler
         if (secretCallbackHandler == null) {
             if (log.isWarnEnabled()) {
                 log.warn("There is no shared SecretCallbackHandler. " +
-                        "Please use any other SecretCallbackHandler implementaions");
+                        "Please use any other SecretCallbackHandler implementations");
             }
             return;
         }

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProvider.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProvider.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProvider.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProvider.java Tue May 11 10:29:05 2010
@@ -26,7 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * SecretsMBean implemetaion
+ * SecretsMBean implementation
  */
 public class JMXSecretsProvider implements JMXSecretsProviderMBean {
 

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProviderMBean.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProviderMBean.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProviderMBean.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/mbean/JMXSecretsProviderMBean.java Tue May 11 10:29:05 2010
@@ -19,7 +19,7 @@
 package org.apache.synapse.commons.security.secret.mbean;
 
 /**
- * Managing MBean for secrct
+ * Managing MBean for secret
  */
 public interface JMXSecretsProviderMBean {
 
@@ -32,7 +32,7 @@ public interface JMXSecretsProviderMBean
     public void addSecret(String id, String secret);
 
     /**
-     * Remove a Secect for given ID
+     * Remove a Secret for given ID
      *
      * @param id identify for what this secret is
      */

Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java Tue May 11 10:29:05 2010
@@ -131,7 +131,7 @@ public final class CipherTool {
             String source = getArgument(cmd, SOURCE_IN_LINED, null);
             assertEmpty(source, SOURCE_IN_LINED);
 
-            Key key = findKey(cmd,cipherInformation);
+            Key key = findKey(cmd, cipherInformation);
 
             boolean isEncrypt = (cipherInformation.getCipherOperationMode() ==
                     CipherOperationMode.ENCRYPT);
@@ -176,9 +176,9 @@ public final class CipherTool {
 
             PrintStream out = System.out;
             if (isEncrypt) {
-                out.println("Output : " + encryptionProvider.encrypt(source.getBytes()));
+                out.println("Output : " + new String(encryptionProvider.encrypt(source.getBytes())));
             } else {
-                out.println("Output : " + decryptionProvider.decrypt(source.getBytes()));
+                out.println("Output : " + new String(decryptionProvider.decrypt(source.getBytes())));
             }
 
         } catch (ParseException e) {
@@ -416,7 +416,7 @@ public final class CipherTool {
      * @return an valid <code>Key</code> if found , otherwise
      */
     private static Key findKey(CommandLine cmd, CipherInformation cipherInformation) {
-         // if pass phrase is specified, use simple symmetric en-/decryption
+        // if pass phrase is specified, use simple symmetric en-/decryption
         String passPhrase = getArgument(cmd, PASSPHRASE, null);
 
         Key key = null;

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/JmxAdapter.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/JmxAdapter.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/JmxAdapter.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/JmxAdapter.java Tue May 11 10:29:05 2010
@@ -20,6 +20,9 @@ package org.apache.synapse;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.commons.jmx.JmxConfigurationConstants;
+import org.apache.synapse.commons.security.PasswordManager;
+import org.apache.synapse.commons.security.secret.SecretInformation;
 import org.apache.synapse.commons.util.RMIRegistryController;
 import org.apache.synapse.commons.jmx.JmxInformation;
 import org.apache.synapse.commons.jmx.JmxSecretAuthenticator;
@@ -203,14 +206,21 @@ public class JmxAdapter {
         Map<String, Object> env = new HashMap<String, Object>();
 
         if (jmxInformation.isAuthenticate()) {
-            
+
             if (jmxInformation.getRemotePasswordFile() != null) {
                 env.put("jmx.remote.x.password.file", jmxInformation.getRemotePasswordFile());
             } else {
-                env.put(JMXConnectorServer.AUTHENTICATOR, 
+                SecretInformation secretInformation = jmxInformation.getSecretInformation();
+                // Get the global secret resolver
+                //TODO This should be properly implemented if JMX adapter is going to use out side synapse
+                PasswordManager pwManager = PasswordManager.getInstance();
+                if (pwManager.isInitialized()) {
+                    secretInformation.setGlobalSecretResolver(pwManager.getSecretResolver());
+                }
+                env.put(JMXConnectorServer.AUTHENTICATOR,
                         new JmxSecretAuthenticator(jmxInformation.getSecretInformation()));
             }
-            
+
             if (jmxInformation.getRemoteAccessFile() != null) {
                 env.put("jmx.remote.x.access.file", jmxInformation.getRemoteAccessFile());
             }

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerManager.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerManager.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerManager.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerManager.java Tue May 11 10:29:05 2010
@@ -21,7 +21,9 @@ package org.apache.synapse;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.commons.jmx.MBeanRegistrar;
+import org.apache.synapse.commons.security.PasswordManager;
 import org.apache.synapse.commons.security.SecurityConstants;
+import org.apache.synapse.config.SynapsePropertiesLoader;
 import org.apache.synapse.core.axis2.SynapseCallbackReceiver;
 
 import javax.management.NotCompliantMBeanException;
@@ -415,6 +417,10 @@ public class ServerManager {
             // register the ServerManager MBean
             registerMBean();
 
+            // initialize global PasswordManager instance used in synapse
+            PasswordManager.getInstance().init(
+                    SynapsePropertiesLoader.loadSynapseProperties(), SynapseConstants.SYNAPSE);
+
             // initializes the SynapseController
             this.synapseController.init(serverConfigurationInformation, serverContextInformation);
 
@@ -443,6 +449,12 @@ public class ServerManager {
 
         if (serverState == ServerState.INITIALIZED || serverState == ServerState.STOPPED) {
 
+            // Shutdown global PasswordManager instance used in synapse
+            PasswordManager passwordManager = PasswordManager.getInstance();
+            if (passwordManager.isInitialized()) {
+                PasswordManager.getInstance().shutDown();
+            }
+
             // unregister the ServerManager MBean
             unRegisterMBean();
 

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java Tue May 11 10:29:05 2010
@@ -28,6 +28,9 @@ import javax.xml.namespace.QName;
  * Global constants for the Apache Synapse project
  */
 public final class SynapseConstants {
+
+    /** Keyword synapse */
+    public static final String SYNAPSE = "synapse";
     public static final String TRUE = "TRUE";
     /** The Synapse namespace */
     public static final String SYNAPSE_NAMESPACE = "http://synapse.apache.org/ns/2010/04/configuration";

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceFactory.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceFactory.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceFactory.java Tue May 11 10:29:05 2010
@@ -25,9 +25,9 @@ import org.apache.axis2.databinding.util
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.SynapseException;
+import org.apache.synapse.commons.security.PasswordManager;
 import org.apache.synapse.config.xml.XMLConfigConstants;
 import org.apache.synapse.eventing.SynapseEventSource;
-import org.apache.synapse.eventing.SynapseEventingConstants;
 import org.apache.synapse.eventing.SynapseSubscription;
 import org.wso2.eventing.SubscriptionManager;
 import org.wso2.eventing.exceptions.EventException;
@@ -100,7 +100,24 @@ public class EventSourceFactory {
                                 propElem.getAttribute(new QName("name")).getAttributeValue();
                         String propValue =
                                 propElem.getAttribute(new QName("value")).getAttributeValue();
-                        manager.addProperty(propName, propValue);
+                        if (propName != null && !"".equals(propName.trim()) &&
+                                propValue != null && !"".equals(propValue.trim())) {
+
+                            propName = propName.trim();
+                            propValue = propValue.trim();
+
+                            PasswordManager passwordManager =
+                                    PasswordManager.getInstance();
+                            String key = eventSource.getName() + "." + propName;
+
+                            if (passwordManager.isInitialized()
+                                    && passwordManager.isTokenProtected(key)) {
+                                eventSource.putConfigurationProperty(propName, propValue);
+                                propValue = passwordManager.resolve(propValue);
+                            }
+
+                            manager.addProperty(propName, propValue);
+                        }
                     }
                     eventSource.setSubscriptionManager(manager);
                     eventSource.getSubscriptionManager()

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceSerializer.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceSerializer.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceSerializer.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventSourceSerializer.java Tue May 11 10:29:05 2010
@@ -63,13 +63,19 @@ public class EventSourceSerializer {
                     XMLConfigConstants.SYNAPSE_OMNAMESPACE);
             subManagerElem.addAttribute(fac.createOMAttribute("class", nullNS,
                     eventSource.getSubscriptionManager().getClass().getName()));
-            for (String name : (Collection<String>)eventSource.getSubscriptionManager().getPropertyNames()) {
+            Collection<String> names =
+                    (Collection<String>) eventSource.getSubscriptionManager().getPropertyNames();
+            for (String name : names) {
+                String value;
+                if (eventSource.isContainsConfigurationProperty(name)) {
+                    value = eventSource.getConfigurationProperty(name);
+                } else {
+                    value = eventSource.getSubscriptionManager().getPropertyValue(name);
+                }
                 OMElement propElem =
                         fac.createOMElement("property", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                 propElem.addAttribute(fac.createOMAttribute("name", nullNS, name));
-                propElem.addAttribute(fac.createOMAttribute(
-                        "value", nullNS,
-                        eventSource.getSubscriptionManager().getPropertyValue(name)));
+                propElem.addAttribute(fac.createOMAttribute("value", nullNS, value));
                 subManagerElem.addChild(propElem);
             }
             evenSourceElem.addChild(subManagerElem);

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/eventing/SynapseEventSource.java Tue May 11 10:29:05 2010
@@ -49,16 +49,18 @@ import org.wso2.eventing.SubscriptionMan
 import org.wso2.eventing.exceptions.EventException;
 
 import javax.xml.namespace.QName;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
- * Eventsource that accepts the event requests using a message reciver.
+ * Eventsource that accepts the event requests using a message receiver.
  * Eventsource is responsible on two tasks accepting the subscriptions and subscription related
  * reqests and dispatching events.
- * Subscriptions conatines operations listed in the WS-Eventing specification. {SubscribeOP,
+ * Subscriptions contains operations listed in the WS-Eventing specification. {SubscribeOP,
  * UnsubscribeOP, RenewOP, GetstatusOP, SubscriptionEndOP}
  * based on the action in the request eventsource identify the operation and send it for processing.
- * Eventsource link with a suscription manager to store the subscriptions. 
+ * Eventsource link with a subscription manager to store the subscriptions.
  */
 public class SynapseEventSource extends SynapseMessageReceiver {
 
@@ -66,6 +68,9 @@ public class SynapseEventSource extends 
     private SubscriptionManager subscriptionManager;
     private static final Log log = LogFactory.getLog(SynapseEventSource.class);
     private String fileName;
+    /* Contains properties used in the configuration and possess confidential information such as
+     encrypted passwords  */
+    private Map<String, String> configurationProperties = new HashMap<String, String>();
 
     public SynapseEventSource(String name) {
         this.name = name;
@@ -109,7 +114,7 @@ public class SynapseEventSource extends 
     }
 
     /**
-     * Override the Message reciver method to accept subscriptions and events
+     * Override the Message receiver method to accept subscriptions and events
      *
      * @param mc message context
      * @throws AxisFault
@@ -121,7 +126,7 @@ public class SynapseEventSource extends 
         SynapseEnvironment synEnv = (SynapseEnvironment) mc.getConfigurationContext()
                 .getAxisConfiguration().getParameter(SynapseConstants.SYNAPSE_ENV).getValue();
         org.apache.synapse.MessageContext smc = new Axis2MessageContext(mc, synCfg, synEnv);
-        // initialisze the response message builder using the message context
+        // initialize the response message builder using the message context
         ResponseMessageBuilder messageBuilder = new ResponseMessageBuilder(mc);
         try {
             if (EventingConstants.WSE_SUBSCRIBE.equals(mc.getWSAAction())) {
@@ -131,7 +136,7 @@ public class SynapseEventSource extends 
                 // Unsubscribe the matching subscription
                 processUnSubscribeRequest(mc, messageBuilder);
             } else if (EventingConstants.WSE_GET_STATUS.equals(mc.getWSAAction())) {
-                // Responce with the status of the subscription
+                // Response with the status of the subscription
                 processGetStatusRequest(mc, messageBuilder);
             } else if (EventingConstants.WSE_RENEW.equals(mc.getWSAAction())) {
                 // Renew subscription
@@ -139,7 +144,7 @@ public class SynapseEventSource extends 
             } else {
                 // Treat as an Event
                 if (log.isDebugEnabled()) {
-                    log.debug("Event recived");
+                    log.debug("Event received");
                 }
                 dispatchEvents(smc);
             }
@@ -460,6 +465,20 @@ public class SynapseEventSource extends 
         
     }
 
+    // Methods for accessing configuration properties - self-explainable
+
+    public void putConfigurationProperty(String name, String value) {
+        configurationProperties.put(name, value);
+    }
+
+    public String getConfigurationProperty(String name) {
+        return configurationProperties.get(name);
+    }
+
+    public boolean isContainsConfigurationProperty(String name) {
+        return configurationProperties.containsKey(name);
+    }
+
     private void handleException(String message, Exception e) {
         log.error(message, e);
         throw new SynapseException(message, e);

Modified: synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat (original)
+++ synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat Tue May 11 10:29:05 2010
@@ -28,6 +28,7 @@ rem
 rem   JAVA_OPTS       (Optional) Java runtime options
 rem ---------------------------------------------------------------------------
 set CURRENT_DIR=%cd%
+set _XDEBUG="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
 
 rem Make sure prerequisite environment variables are set
 if not "%JAVA_HOME%" == "" goto gotJavaHome
@@ -82,7 +83,7 @@ set _RUNJAVA="%JAVA_HOME%\bin\java"
 
 set JAVA_ENDORSED=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed"
 
-%_RUNJAVA% %JAVA_OPTS% -cp "%SYNAPSE_CLASSPATH%" -Djava.endorsed.dirs=%JAVA_ENDORSED%  org.apache.synapse.commons.security.tool.CipherTool %*
+%_RUNJAVA% %JAVA_OPTS% -cp "%SYNAPSE_CLASSPATH%"  %_XDEBUG% -Djava.endorsed.dirs=%JAVA_ENDORSED% org.apache.synapse.commons.security.tool.CipherTool %*
 endlocal
 :end
 

Modified: synapse/trunk/java/repository/conf/synapse.properties
URL: http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/synapse.properties?rev=943075&r1=943074&r2=943075&view=diff
==============================================================================
--- synapse/trunk/java/repository/conf/synapse.properties (original)
+++ synapse/trunk/java/repository/conf/synapse.properties Tue May 11 10:29:05 2010
@@ -43,13 +43,15 @@
 # Security Configuration
 #############################################################################
 # The following property specifies a global password provider implementation
-# which will be used globally if not overriden in specific configurations
-# synapse.secretProvider=<any implementation of org.apache.synapse.commons.security.secret.SecretCallbackHandler>
+# which will be used globally if not overridden in specific configurations
+# synapse.passwordProvider=<any implementation of org.apache.synapse.commons.security.secret.SecretCallbackHandler>
 #Examples:
-#synapse.secretProvider=org.apache.synapse.commons.security.secret.handler.SecretManagerSecretCallbackHandler
-#synapse.secretProvider=org.apache.synapse.commons.security.secret.handler.JMXSecretCallbackHandler
-#synapse.secretProvider=org.apache.synapse.commons.security.secret.handler.JlineSecretCallbackHandler
-#synapse.secretProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
+#synapse.passwordProvider=org.apache.synapse.commons.security.secret.handler.SecretManagerSecretCallbackHandler
+#synapse.passwordProvider=org.apache.synapse.commons.security.secret.handler.JMXSecretCallbackHandler
+#synapse.passwordProvider=org.apache.synapse.commons.security.secret.handler.JlineSecretCallbackHandler
+#synapse.passwordProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
+
+#synapse.protectedTokens=
 #
 #secretRepositories=file
 #secretRepositories.file.provider=org.apache.synapse.commons.security.secret.repository.FileBaseSecretRepositoryProvider
@@ -83,8 +85,8 @@
 #synapse.datasources.lookupds.type=BasicDataSource
 #synapse.datasources.lookupds.driverClassName=org.apache.derby.jdbc.ClientDriver
 #synapse.datasources.lookupds.url=jdbc:derby://localhost:1527/lookupdb;create=false
-# Optionally you can specifiy a specific password provider implementation which overrides any globally configured provider
-#synapse.datasources.lookupds.secretProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
+# Optionally you can specify a specific password provider implementation which overrides any globally configured provider
+#synapse.datasources.lookupds.passwordProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
 #synapse.datasources.lookupds.username=synapse
 # Depending on the password provider used, you may have to use an encrypted password here!
 #synapse.datasources.lookupds.password=synapse
@@ -101,8 +103,8 @@
 #synapse.datasources.reportds.dsName=reportdb
 #synapse.datasources.reportds.driverClassName=org.apache.derby.jdbc.ClientDriver
 #synapse.datasources.reportds.url=jdbc:derby://localhost:1527/reportdb;create=false
-# Optionally you can specifiy a specific password provider implementation which overrides any globally configured provider
-#synapse.datasources.reportds.secretProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
+# Optionally you can specify a specific password provider implementation which overrides any globally configured provider
+#synapse.datasources.reportds.passwordProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
 #synapse.datasources.reportds.username=synapse
 # Depending on the password provider used, you may have to use an encrypted password here!
 #synapse.datasources.reportds.password=synapse
@@ -119,8 +121,8 @@ synapse.jmx.jndiPort=0
 #synapse.jmx.rmiPort=1101
 # By default the hostname will be detected, but you can force to use another network interface
 #synapse.jmx.hostname=
-# Optionally you can specifiy a specific secret provider implementation which overrides any globally configured provider
-#synapse.jmx.secretProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
+# Optionally you can specify a specific secret provider implementation which overrides any globally configured provider
+#synapse.jmx.passwordProvider=org.apache.synapse.commons.security.secret.handler.JBossEncryptionSecretCallbackHandler
 # By default no authentication is required, but you may enforce this by specifying a username and password
 #synapse.jmx.username=admin
 # Depending on the secret provider used, you may have to use an encrypted password here!
@@ -129,7 +131,7 @@ synapse.jmx.jndiPort=0
 #synapse.jmx.remote.access.file=
 
 #################################################################################################
-# Proxy Settings For URL Connections, these are used when synpase retrieves resources from URLs
+# Proxy Settings For URL Connections, these are used when synapse retrieves resources from URLs
 # i.e. Creating proxy services from WSDL URLs, endpoints using WSDL urls etc.
 #################################################################################################
 # Proxy server
@@ -140,5 +142,5 @@ synapse.jmx.jndiPort=0
 #synapse.http.proxy.user=
 # Proxy server user password, this is used for HTTP basic authentication
 #synapse.http.proxy.password=
-#list of host address exclueded from going through the proxy, list is comma seperated
+#list of host address excluded from going through the proxy, list is comma separated
 #synapse.http.proxy.excluded.hosts=localhost, 127.0.0.1
\ No newline at end of file