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/24 17:42:08 UTC
svn commit: r947673 [1/4] - in /synapse/trunk/java: ./ modules/commons/
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/...
Author: indika
Date: Mon May 24 15:42:06 2010
New Revision: 947673
URL: http://svn.apache.org/viewvc?rev=947673&view=rev
Log:
move password security code into securevault new module
Added:
synapse/trunk/java/modules/securevault/
synapse/trunk/java/modules/securevault/pom.xml
synapse/trunk/java/modules/securevault/src/
synapse/trunk/java/modules/securevault/src/main/
synapse/trunk/java/modules/securevault/src/main/java/
synapse/trunk/java/modules/securevault/src/main/java/org/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/AsymmetricCipher.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/BaseCipher.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherFactory.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherOperationMode.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/DecryptionProvider.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingHelper.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingType.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncryptionProvider.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/ICACertsLoader.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/IKeyStoreLoader.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/KeyStoreType.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/PasswordManager.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecretResolver.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecretResolverFactory.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecureVaultException.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecurityConstants.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SymmetricCipher.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/commons/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/commons/MBeanRegistrar.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/commons/MiscellaneousUtil.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/definition/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/definition/CipherInformation.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/definition/IdentityKeyStoreInformation.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/definition/KeyStoreInformation.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/definition/KeyStoreInformationFactory.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/definition/TrustKeyStoreInformation.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/AbstractKeyStoreLoader.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/CACertsLoader.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/IdentityKeyStoreWrapper.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/JKSKeyStoreLoader.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/KeyStoreWrapper.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/PKCS12KeyStoreLoader.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/PKCS8KeyStoreLoader.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/keystore/TrustKeyStoreWrapper.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/AbstractSecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/MultiSecretCallback.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretCallback.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretCallbackHandlerFactory.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretInformation.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretInformationFactory.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretLoadingModule.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretManager.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretRepository.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SecretRepositoryProvider.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/SingleSecretCallback.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/HardCodedSecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/JBossEncryptionSecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/JMXSecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/JlineSecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/SecretManagerSecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/SharedSecretCallbackHandler.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/handler/SharedSecretCallbackHandlerCache.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/mbean/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/mbean/JMXSecretsProvider.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/mbean/JMXSecretsProviderMBean.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/mbean/SecretManagerAdminMBean.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/repository/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/repository/FileBaseSecretRepository.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/secret/repository/FileBaseSecretRepositoryProvider.java
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/tool/
synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/tool/CipherTool.java
synapse/trunk/java/modules/securevault/src/test/
Removed:
synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/security/
Modified:
synapse/trunk/java/modules/commons/pom.xml
synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformation.java
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/JNDIBasedDataSourceRepository.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/serializer/DataSourceInformationSerializer.java
synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformation.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/core/pom.xml
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.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/SecretManagerAdminMBeanImpl.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/ServerStateDetectionStrategy.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/AbstractDBMediatorFactory.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/mediators/db/AbstractDBMediator.java
synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat
synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.sh
synapse/trunk/java/pom.xml
synapse/trunk/java/repository/conf/synapse.properties
synapse/trunk/java/src/site/xdoc/Synapse_Samples_Setup.xml
Modified: synapse/trunk/java/modules/commons/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/pom.xml?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/pom.xml (original)
+++ synapse/trunk/java/modules/commons/pom.xml Mon May 24 15:42:06 2010
@@ -77,8 +77,13 @@
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
+ <artifactId>axis2-transport-base</artifactId>
<version>${axis2.transport.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.synapse</groupId>
+ <artifactId>synapse-securevault</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformation.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformation.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformation.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/DataSourceInformation.java Mon May 24 15:42:06 2010
@@ -20,7 +20,7 @@ package org.apache.synapse.commons.datas
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.apache.commons.pool.impl.GenericObjectPool;
-import org.apache.synapse.commons.security.secret.SecretInformation;
+import org.apache.synapse.securevault.secret.SecretInformation;
import java.util.HashMap;
import java.util.Map;
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=947673&r1=947672&r2=947673&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 Mon May 24 15:42:06 2010
@@ -21,9 +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 org.apache.synapse.securevault.SecretResolver;
+import org.apache.synapse.securevault.SecretResolverFactory;
+import org.apache.synapse.securevault.secret.SecretInformation;
import java.util.HashMap;
import java.util.Iterator;
Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/JNDIBasedDataSourceRepository.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/JNDIBasedDataSourceRepository.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/JNDIBasedDataSourceRepository.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/JNDIBasedDataSourceRepository.java Mon May 24 15:42:06 2010
@@ -24,9 +24,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.SecurityConstants;
import org.apache.synapse.commons.util.MiscellaneousUtil;
import org.apache.synapse.commons.util.RMIRegistryController;
+import org.apache.synapse.securevault.SecurityConstants;
import javax.naming.*;
import javax.sql.DataSource;
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=947673&r1=947672&r2=947673&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 Mon May 24 15:42:06 2010
@@ -25,9 +25,9 @@ import org.apache.commons.pool.impl.Gene
import org.apache.synapse.commons.SynapseCommonsException;
import org.apache.synapse.commons.datasource.DataSourceConstants;
import org.apache.synapse.commons.datasource.DataSourceInformation;
-import org.apache.synapse.commons.security.SecurityConstants;
-import org.apache.synapse.commons.security.secret.SecretInformation;
-import org.apache.synapse.commons.security.secret.SecretInformationFactory;
+import org.apache.synapse.securevault.SecurityConstants;
+import org.apache.synapse.securevault.secret.SecretInformation;
+import org.apache.synapse.securevault.secret.SecretInformationFactory;
import org.apache.synapse.commons.util.MiscellaneousUtil;
import java.util.Properties;
Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/serializer/DataSourceInformationSerializer.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/serializer/DataSourceInformationSerializer.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/serializer/DataSourceInformationSerializer.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/datasource/serializer/DataSourceInformationSerializer.java Mon May 24 15:42:06 2010
@@ -20,8 +20,8 @@ package org.apache.synapse.commons.datas
import org.apache.synapse.commons.datasource.DataSourceConstants;
import org.apache.synapse.commons.datasource.DataSourceInformation;
-import org.apache.synapse.commons.security.SecurityConstants;
-import org.apache.synapse.commons.security.secret.SecretInformation;
+import org.apache.synapse.securevault.SecurityConstants;
+import org.apache.synapse.securevault.secret.SecretInformation;
import java.util.Properties;
Modified: synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformation.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformation.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformation.java (original)
+++ synapse/trunk/java/modules/commons/src/main/java/org/apache/synapse/commons/jmx/JmxInformation.java Mon May 24 15:42:06 2010
@@ -19,7 +19,7 @@
package org.apache.synapse.commons.jmx;
-import org.apache.synapse.commons.security.secret.SecretInformation;
+import org.apache.synapse.securevault.secret.SecretInformation;
public class JmxInformation {
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=947673&r1=947672&r2=947673&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 Mon May 24 15:42:06 2010
@@ -23,8 +23,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.commons.util.MiscellaneousUtil;
import org.apache.synapse.commons.SynapseCommonsException;
-import org.apache.synapse.commons.security.secret.SecretInformation;
-import org.apache.synapse.commons.security.secret.SecretInformationFactory;
+import org.apache.synapse.securevault.secret.SecretInformation;
+import org.apache.synapse.securevault.secret.SecretInformationFactory;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
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=947673&r1=947672&r2=947673&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 Mon May 24 15:42:06 2010
@@ -19,7 +19,7 @@
package org.apache.synapse.commons.jmx;
-import org.apache.synapse.commons.security.secret.SecretInformation;
+import org.apache.synapse.securevault.secret.SecretInformation;
import javax.management.remote.JMXAuthenticator;
import javax.management.remote.JMXPrincipal;
Modified: synapse/trunk/java/modules/core/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/pom.xml?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/pom.xml (original)
+++ synapse/trunk/java/modules/core/pom.xml Mon May 24 15:42:06 2010
@@ -169,6 +169,10 @@
<dependencies>
<dependency>
<groupId>org.apache.synapse</groupId>
+ <artifactId>synapse-securevault</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.synapse</groupId>
<artifactId>synapse-commons</artifactId>
</dependency>
<dependency>
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java Mon May 24 15:42:06 2010
@@ -37,8 +37,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.commons.datasource.DataSourceRepositoryHolder;
import org.apache.synapse.commons.util.RMIRegistryController;
-import org.apache.synapse.commons.security.SecurityConstants;
-import org.apache.synapse.commons.security.secret.SecretCallbackHandler;
+import org.apache.synapse.securevault.SecurityConstants;
+import org.apache.synapse.securevault.secret.SecretCallbackHandler;
import org.apache.synapse.commons.datasource.DataSourceInformationRepository;
import org.apache.synapse.commons.datasource.DataSourceConstants;
import org.apache.synapse.commons.jmx.JmxInformation;
@@ -51,7 +51,7 @@ import org.apache.synapse.core.SynapseEn
import org.apache.synapse.core.axis2.*;
import org.apache.synapse.eventing.SynapseEventSource;
import org.apache.synapse.task.*;
-import org.apache.synapse.commons.security.secret.handler.SharedSecretCallbackHandlerCache;
+import org.apache.synapse.securevault.secret.handler.SharedSecretCallbackHandlerCache;
import java.util.*;
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=947673&r1=947672&r2=947673&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 Mon May 24 15:42:06 2010
@@ -20,9 +20,8 @@ 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.securevault.PasswordManager;
+import org.apache.synapse.securevault.secret.SecretInformation;
import org.apache.synapse.commons.util.RMIRegistryController;
import org.apache.synapse.commons.jmx.JmxInformation;
import org.apache.synapse.commons.jmx.JmxSecretAuthenticator;
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SecretManagerAdminMBeanImpl.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SecretManagerAdminMBeanImpl.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SecretManagerAdminMBeanImpl.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SecretManagerAdminMBeanImpl.java Mon May 24 15:42:06 2010
@@ -19,20 +19,20 @@
package org.apache.synapse;
import org.apache.synapse.config.SynapsePropertiesLoader;
-import org.apache.synapse.commons.security.secret.SecretManager;
-import org.apache.synapse.commons.security.secret.mbean.SecretManagerAdminMBean;
+import org.apache.synapse.securevault.secret.SecretManager;
+import org.apache.synapse.securevault.secret.mbean.SecretManagerAdminMBean;
import javax.management.StandardMBean;
import javax.management.NotCompliantMBeanException;
/**
- *
+ * Admin service for managing SecretManager
*/
public class SecretManagerAdminMBeanImpl extends StandardMBean implements SecretManagerAdminMBean {
- private SecretManager secretManager = SecretManager.getInstance();
+ private final SecretManager secretManager = SecretManager.getInstance();
public SecretManagerAdminMBeanImpl() throws NotCompliantMBeanException {
super(SecretManagerAdminMBean.class);
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=947673&r1=947672&r2=947673&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 Mon May 24 15:42:06 2010
@@ -21,10 +21,10 @@ 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 org.apache.synapse.securevault.PasswordManager;
+import org.apache.synapse.securevault.SecurityConstants;
import javax.management.NotCompliantMBeanException;
import java.util.Date;
@@ -33,7 +33,7 @@ import java.util.Date;
* This is the core class that starts up a Synapse instance.
* <p/>
* From the command line scripts synapse.sh and synapse-daemon.sh (though the wrapper.conf)
- * the SynapseServer is invoked which inturn calls on this to start the instance
+ * the SynapseServer is invoked which in turn calls on this to start the instance
* <p/>
* When the WAR deployment is used, the SynapseStartUpServlet servlet calls on this class to
* initialize Synapse
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerStateDetectionStrategy.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerStateDetectionStrategy.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerStateDetectionStrategy.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/ServerStateDetectionStrategy.java Mon May 24 15:42:06 2010
@@ -19,7 +19,7 @@
package org.apache.synapse;
import org.apache.synapse.config.SynapsePropertiesLoader;
-import org.apache.synapse.commons.security.secret.SecretManager;
+import org.apache.synapse.securevault.secret.SecretManager;
/**
* Detects possible current server state
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigUtils.java Mon May 24 15:42:06 2010
@@ -29,10 +29,10 @@ import org.apache.commons.codec.binary.B
import org.apache.synapse.*;
import org.apache.synapse.aspects.AspectConfiguration;
import org.apache.synapse.aspects.statistics.StatisticsCollector;
-import org.apache.synapse.commons.security.definition.IdentityKeyStoreInformation;
-import org.apache.synapse.commons.security.definition.KeyStoreInformation;
-import org.apache.synapse.commons.security.definition.KeyStoreInformationFactory;
-import org.apache.synapse.commons.security.definition.TrustKeyStoreInformation;
+import org.apache.synapse.securevault.definition.IdentityKeyStoreInformation;
+import org.apache.synapse.securevault.definition.KeyStoreInformation;
+import org.apache.synapse.securevault.definition.KeyStoreInformationFactory;
+import org.apache.synapse.securevault.definition.TrustKeyStoreInformation;
import org.apache.synapse.core.SynapseEnvironment;
import org.apache.synapse.mediators.MediatorProperty;
import org.apache.synapse.mediators.base.SequenceMediator;
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/AbstractDBMediatorFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/AbstractDBMediatorFactory.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/AbstractDBMediatorFactory.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/AbstractDBMediatorFactory.java Mon May 24 15:42:06 2010
@@ -22,7 +22,7 @@ package org.apache.synapse.config.xml;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.synapse.commons.datasource.DataSourceInformation;
-import org.apache.synapse.commons.security.secret.SecretInformation;
+import org.apache.synapse.securevault.secret.SecretInformation;
import org.apache.synapse.mediators.db.AbstractDBMediator;
import org.apache.synapse.mediators.db.Statement;
import org.apache.synapse.util.xpath.SynapseXPath;
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=947673&r1=947672&r2=947673&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 Mon May 24 15:42:06 2010
@@ -25,10 +25,10 @@ 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.SynapseSubscription;
+import org.apache.synapse.securevault.PasswordManager;
import org.wso2.eventing.SubscriptionManager;
import org.wso2.eventing.exceptions.EventException;
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/AbstractDBMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/AbstractDBMediator.java?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/AbstractDBMediator.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/db/AbstractDBMediator.java Mon May 24 15:42:06 2010
@@ -29,7 +29,7 @@ import org.apache.synapse.SynapseLog;
import org.apache.synapse.commons.datasource.*;
import org.apache.synapse.commons.datasource.factory.DataSourceFactory;
import org.apache.synapse.commons.jmx.MBeanRepository;
-import org.apache.synapse.commons.security.secret.SecretManager;
+import org.apache.synapse.securevault.secret.SecretManager;
import org.apache.synapse.core.SynapseEnvironment;
import org.apache.synapse.mediators.AbstractMediator;
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=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat (original)
+++ synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.bat Mon May 24 15:42:06 2010
@@ -83,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%" %_XDEBUG% -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.securevault.tool.CipherTool %*
endlocal
:end
Modified: synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.sh
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.sh?rev=947673&r1=947672&r2=947673&view=diff
==============================================================================
--- synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.sh (original)
+++ synapse/trunk/java/modules/distribution/src/main/bin/ciphertool.sh Mon May 24 15:42:06 2010
@@ -102,4 +102,4 @@ fi
$JAVA_HOME/bin/java \
-classpath "$SYNAPSE_CLASSPATH" \
-Djava.endorsed.dirs="$SYNAPSE_HOME/lib/endorsed":"$JAVA_HOME/jre/lib/endorsed":"$JAVA_HOME/lib/endorsed" \
-org.apache.synapse.commons.security.tool.CipherTool $*
+org.apache.synapse.securevault.tool.CipherTool $*
Added: synapse/trunk/java/modules/securevault/pom.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/pom.xml?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/pom.xml (added)
+++ synapse/trunk/java/modules/securevault/pom.xml Mon May 24 15:42:06 2010
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.synapse</groupId>
+ <artifactId>synapse-securevault</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <name>Apache Synapse - Secure vault</name>
+ <description>Apache Synapse - Secure vault</description>
+ <packaging>bundle</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.synapse.securevault.*,
+ </Export-Package>
+ <Import-Package>
+ !javax.xml.namespace,
+ javax.xml.namespace; version=0.0.0,
+ *;resolution:=optional,
+ </Import-Package>
+ <DynamicImport-Package>*</DynamicImport-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>${jline.version}</version>
+ </dependency>
+ <!-- direct dependencies for 3rd party JARs / Util JARs -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons.logging.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>${commons-cli.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons_io.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>${commons-codec.version}</version>
+ </dependency>
+
+ </dependencies>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <axiom.version>1.2.9-SNAPSHOT</axiom.version>
+ <commons.logging.version>1.1.1</commons.logging.version>
+ <junit.version>3.8.2</junit.version>
+ <log4j.version>1.2.14</log4j.version>
+ <commons-cli.version>1.0</commons-cli.version>
+ <jline.version>0.9.94</jline.version>
+ <commons_io.version>1.4</commons_io.version>
+ <commons-codec.version>1.2</commons-codec.version>
+ </properties>
+</project>
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/AsymmetricCipher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/AsymmetricCipher.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/AsymmetricCipher.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/AsymmetricCipher.java Mon May 24 15:42:06 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.securevault;
+
+import org.apache.synapse.securevault.definition.CipherInformation;
+import org.apache.synapse.securevault.definition.KeyStoreInformation;
+import org.apache.synapse.securevault.keystore.IdentityKeyStoreWrapper;
+import org.apache.synapse.securevault.keystore.KeyStoreWrapper;
+
+import java.security.Key;
+
+/**
+ * The Cipher doing asymmetric cryptographic operations
+ */
+public class AsymmetricCipher extends BaseCipher {
+
+ public AsymmetricCipher(CipherInformation cipherInformation,
+ KeyStoreInformation keystoreInformation) {
+ super(cipherInformation, keystoreInformation);
+ }
+
+ public AsymmetricCipher(CipherInformation cipherInformation, KeyStoreWrapper keyStoreWrapper) {
+ super(cipherInformation, keyStoreWrapper);
+ }
+
+ public AsymmetricCipher(CipherInformation cipherInformation, Key key) {
+ super(cipherInformation, key);
+ }
+
+ public Key getKey(CipherOperationMode operationMode) {
+ if (operationMode == CipherOperationMode.ENCRYPT) {
+ return keyStoreWrapper.getPublicKey();
+ } else {
+ return ((IdentityKeyStoreWrapper) keyStoreWrapper).getPrivateKey();
+ }
+ }
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/BaseCipher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/BaseCipher.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/BaseCipher.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/BaseCipher.java Mon May 24 15:42:06 2010
@@ -0,0 +1,204 @@
+/*
+* 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.securevault;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.securevault.definition.CipherInformation;
+import org.apache.synapse.securevault.definition.IdentityKeyStoreInformation;
+import org.apache.synapse.securevault.definition.KeyStoreInformation;
+import org.apache.synapse.securevault.definition.TrustKeyStoreInformation;
+import org.apache.synapse.securevault.keystore.IdentityKeyStoreWrapper;
+import org.apache.synapse.securevault.keystore.KeyStoreWrapper;
+import org.apache.synapse.securevault.keystore.TrustKeyStoreWrapper;
+import org.apache.synapse.securevault.secret.SecretInformation;
+
+import javax.crypto.Cipher;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.NoSuchPaddingException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+
+/**
+ * Wraps the cipher and expose abstraction need for synapse ciphering
+ */
+public abstract class BaseCipher implements EncryptionProvider, DecryptionProvider {
+
+ private CipherInformation cipherInformation;
+ private KeyStoreInformation keystoreInformation;
+ private static Log log = LogFactory.getLog(BaseCipher.class);
+ /* Underlying cipher instance*/
+ private Cipher cipher;
+ protected KeyStoreWrapper keyStoreWrapper;
+ private Key key;
+
+ protected BaseCipher(CipherInformation cipherInformation,
+ KeyStoreInformation keystoreInformation) {
+ this.cipherInformation = cipherInformation;
+ this.keystoreInformation = keystoreInformation;
+ if (keystoreInformation instanceof TrustKeyStoreInformation) {
+ keyStoreWrapper = new TrustKeyStoreWrapper();
+ ((TrustKeyStoreWrapper) keyStoreWrapper).init(
+ (TrustKeyStoreInformation) keystoreInformation);
+ } else {
+ keyStoreWrapper = new IdentityKeyStoreWrapper();
+ IdentityKeyStoreInformation identityKeyStore =
+ (IdentityKeyStoreInformation) keystoreInformation;
+
+ SecretInformation secretInformation = identityKeyStore.getKeyPasswordProvider();
+ if (secretInformation != null) { //TODO validate
+ ((IdentityKeyStoreWrapper) keyStoreWrapper).init(identityKeyStore,
+ secretInformation.getResolvedSecret());
+ }
+ }
+ init();
+ }
+
+ protected BaseCipher(CipherInformation cipherInformation,
+ KeyStoreWrapper keyStoreWrapper) {
+ this.keyStoreWrapper = keyStoreWrapper;
+ this.cipherInformation = cipherInformation;
+ init();
+ }
+
+ protected BaseCipher(CipherInformation cipherInformation, Key key) {
+ this.key = key;
+ this.cipherInformation = cipherInformation;
+ init();
+ }
+
+ private void init() {
+
+ String algorithm = cipherInformation.getAlgorithm();
+ CipherOperationMode opMode = cipherInformation.getCipherOperationMode();
+ if (key == null) {
+ key = getKey(opMode);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Initializing cipher with algorithm " +
+ "'" + algorithm + "' in mode '" + opMode + "'");
+ }
+ try {
+ String provider = cipherInformation.getProvider();
+ if (provider != null && !"".equals(provider)) {
+ try {
+ cipher = Cipher.getInstance(algorithm, provider.trim());
+ } catch (NoSuchProviderException e) {
+ throw new SecureVaultException("Invalid Provider : " + provider, log);
+ }
+ } else {
+ cipher = Cipher.getInstance(algorithm);
+ }
+ if (opMode == CipherOperationMode.ENCRYPT) {
+ cipher.init(Cipher.ENCRYPT_MODE, key);
+ } else if (opMode == CipherOperationMode.DECRYPT) {
+ cipher.init(Cipher.DECRYPT_MODE, key);
+ } else {
+ throw new SecureVaultException("Invalid mode : " + opMode, log);
+ }
+
+ } catch (NoSuchAlgorithmException e) {
+ throw new SecureVaultException("There is no algorithm support for " +
+ "'" + algorithm + "' in the operation mode '" + opMode + "'" + e, log);
+ } catch (NoSuchPaddingException e) {
+ throw new SecureVaultException("There is no padding scheme for " +
+ "'" + algorithm + "' in the operation mode '" + opMode + "'" + e, log);
+ } catch (InvalidKeyException e) {
+ throw new SecureVaultException("Invalid key ", e, log);
+ }
+ }
+
+ public CipherInformation getCipherInformation() {
+ return cipherInformation;
+ }
+
+ public KeyStoreInformation getKeyStoreInformation() {
+ return keystoreInformation;
+ }
+
+ /**
+ * Returns the correct key for correct operation
+ *
+ * @param operationMode Ciper operation
+ * @return A key
+ */
+ public abstract Key getKey(CipherOperationMode operationMode);
+
+ /**
+ * Do cryptographic operation
+ *
+ * @param inputStream Input Stream
+ * @return result
+ */
+ private byte[] doCipherOperation(byte[] inputStream) {
+
+ InputStream sourceStream = new ByteArrayInputStream(inputStream);
+ if (cipherInformation.getInType() != null) {
+ try {
+ sourceStream = EncodingHelper.decode(
+ sourceStream, cipherInformation.getInType());
+ } catch (IOException e) {
+ throw new SecureVaultException("IOError when decoding the input " +
+ "stream for cipher ", e, log);
+ }
+ }
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ CipherOutputStream out = new CipherOutputStream(baos, cipher);
+
+ byte[] buffer = new byte[64];
+ int length;
+ try {
+ while ((length = sourceStream.read(buffer)) != -1) {
+ out.write(buffer, 0, length);
+ }
+ } catch (IOException e) {
+ throw new SecureVaultException("IOError when reading the input" +
+ " stream for cipher ", e, log);
+ } finally {
+ try {
+ sourceStream.close();
+ out.flush();
+ out.close();
+ } catch (IOException ignored) {
+ // ignore exception
+ }
+ }
+
+ if (cipherInformation.getOutType() != null) {
+ return EncodingHelper.encode(baos, cipherInformation.getOutType());
+ } else {
+ return baos.toByteArray();
+ }
+ }
+
+ public byte[] encrypt(byte[] plainText) {
+ return doCipherOperation(plainText);
+ }
+
+ public byte[] decrypt(byte[] cipherText) {
+ return doCipherOperation(cipherText);
+ }
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherFactory.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherFactory.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherFactory.java Mon May 24 15:42:06 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.securevault;
+
+import org.apache.synapse.securevault.definition.CipherInformation;
+import org.apache.synapse.securevault.definition.KeyStoreInformation;
+import org.apache.synapse.securevault.keystore.KeyStoreWrapper;
+
+import java.security.Key;
+
+/**
+ * Creates Ciphers
+ */
+public class CipherFactory {
+
+ public static BaseCipher createCipher(CipherInformation cipherInformation,
+ KeyStoreInformation keystoreInformation) {
+
+ if ("symmetric".equals(cipherInformation.getType())) {
+ return new SymmetricCipher(cipherInformation, keystoreInformation);
+ } else {
+ return new AsymmetricCipher(cipherInformation, keystoreInformation);
+ }
+ }
+
+ public static BaseCipher createCipher(CipherInformation cipherInformation,
+ KeyStoreWrapper keyStoreWrapper) {
+
+ if ("symmetric".equals(cipherInformation.getType())) {
+ return new SymmetricCipher(cipherInformation, keyStoreWrapper);
+ } else {
+ return new AsymmetricCipher(cipherInformation, keyStoreWrapper);
+ }
+ }
+
+ public static BaseCipher createCipher(CipherInformation cipherInformation,
+ Key key) {
+
+ if ("symmetric".equals(cipherInformation.getType())) {
+ return new SymmetricCipher(cipherInformation, key);
+ } else {
+ return new AsymmetricCipher(cipherInformation, key);
+ }
+ }
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherOperationMode.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherOperationMode.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherOperationMode.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/CipherOperationMode.java Mon May 24 15:42:06 2010
@@ -0,0 +1,27 @@
+/*
+ * 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.securevault;
+
+/**
+ * Cipher Operation Mode.
+ */
+public enum CipherOperationMode {
+ ENCRYPT,
+ DECRYPT
+}
\ No newline at end of file
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/DecryptionProvider.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/DecryptionProvider.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/DecryptionProvider.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/DecryptionProvider.java Mon May 24 15:42:06 2010
@@ -0,0 +1,33 @@
+/*
+ * 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.securevault;
+
+/**
+ * Provides Decrypt operation
+ */
+public interface DecryptionProvider {
+
+ /**
+ * Decrypts input cipher bytes
+ *
+ * @param cipherText as a byte array
+ * @return plain text as byte array
+ */
+ public byte[] decrypt(byte[] cipherText);
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingHelper.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingHelper.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingHelper.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingHelper.java Mon May 24 15:42:06 2010
@@ -0,0 +1,102 @@
+/*
+* 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.securevault;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.securevault.commons.MiscellaneousUtil;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+
+/**
+ * Helper to handle encoding and decoding of data streams.
+ */
+public final class EncodingHelper {
+
+ private static Log log = LogFactory.getLog(EncodingHelper.class);
+
+ private EncodingHelper() {
+ }
+
+ /**
+ * Encodes the provided ByteArrayOutputStream using the specified encoding type.
+ *
+ * @param baos The ByteArrayOutputStream to encode
+ * @param encodingType The encoding to use
+ * @return The encoded ByteArrayOutputStream as a String
+ */
+ public static byte[] encode(ByteArrayOutputStream baos, EncodingType encodingType) {
+ switch (encodingType) {
+ case BASE64:
+ if (log.isDebugEnabled()) {
+ log.debug("base64 encoding on output ");
+ }
+ return Base64.encodeBase64(baos.toByteArray());
+ case BIGINTEGER16:
+ if (log.isDebugEnabled()) {
+ log.debug("BigInteger 16 encoding on output ");
+ }
+ return new BigInteger(baos.toByteArray()).toByteArray();
+ default:
+ throw new IllegalArgumentException("Unsupported encoding type");
+ }
+ }
+
+ /**
+ * Decodes the provided InputStream using the specified encoding type.
+ *
+ * @param inputStream The InputStream to decode
+ * @param encodingType The encoding to use
+ * @return The decoded InputStream
+ * @throws java.io.IOException If an error occurs decoding the input stream
+ * @throws IllegalArgumentException if the specified encodingType is not supported
+ */
+ public static InputStream decode(InputStream inputStream, EncodingType encodingType)
+ throws IOException {
+
+ InputStream decodedInputStream = null;
+ switch (encodingType) {
+ case BASE64:
+ if (log.isDebugEnabled()) {
+ log.debug("base64 decoding on input ");
+ }
+ decodedInputStream = new ByteArrayInputStream(
+ Base64.decodeBase64(MiscellaneousUtil.asBytes(inputStream)));
+ break;
+ case BIGINTEGER16:
+ if (log.isDebugEnabled()) {
+ log.debug("BigInteger 16 encoding on output ");
+ }
+
+ BigInteger n = new BigInteger(IOUtils.toString(inputStream), 16);
+ decodedInputStream = new ByteArrayInputStream(n.toByteArray());
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported encoding type");
+ }
+
+ return decodedInputStream;
+ }
+}
\ No newline at end of file
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingType.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingType.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingType.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncodingType.java Mon May 24 15:42:06 2010
@@ -0,0 +1,27 @@
+/*
+ * 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.securevault;
+
+/**
+ * Encoding Types
+ */
+public enum EncodingType {
+ BASE64,
+ BIGINTEGER16
+}
\ No newline at end of file
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncryptionProvider.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncryptionProvider.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncryptionProvider.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/EncryptionProvider.java Mon May 24 15:42:06 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.securevault;
+
+/**
+ * Provides Encrypt operation
+ */
+public interface EncryptionProvider {
+ /**
+ * Encrypts a plain text
+ *
+ * @param plainText as a byte array
+ * @return cipher text as a byte array
+ */
+ public byte[] encrypt(byte[] plainText);
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/ICACertsLoader.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/ICACertsLoader.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/ICACertsLoader.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/ICACertsLoader.java Mon May 24 15:42:06 2010
@@ -0,0 +1,33 @@
+/*
+ * 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.securevault;
+
+import java.security.KeyStore;
+
+/**
+ * ICACertsLoader provides an uniform interface to create a keyStore containing CA certs
+ * (trust store)
+ */
+public interface ICACertsLoader {
+ /**
+ * @param CACertificateFilesPath Path to the CA certificates directory
+ * @return KeyStore Instance
+ */
+ public abstract KeyStore loadTrustStore(String CACertificateFilesPath);
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/IKeyStoreLoader.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/IKeyStoreLoader.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/IKeyStoreLoader.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/IKeyStoreLoader.java Mon May 24 15:42:06 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.securevault;
+
+import java.security.KeyStore;
+
+/**
+ * Provides a way to load KeyStore
+ */
+public interface IKeyStoreLoader {
+
+ /**
+ * returns an instance of KeyStore object
+ *
+ * @return KeyStore Instance
+ */
+ public abstract KeyStore getKeyStore();
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/KeyStoreType.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/KeyStoreType.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/KeyStoreType.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/KeyStoreType.java Mon May 24 15:42:06 2010
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.synapse.securevault;
+
+/**
+ * KeyStore Types
+ */
+
+public enum KeyStoreType {
+ JKS,
+ PKCS8,
+ PKCS12,
+ CA_CERTIFICATES_PATH
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/PasswordManager.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/PasswordManager.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/PasswordManager.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/PasswordManager.java Mon May 24 15:42:06 2010
@@ -0,0 +1,93 @@
+/*
+ * 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.securevault;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+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 SecureVaultException(msg);
+ }
+
+ public SecretResolver getSecretResolver() {
+ assertInitialized();
+ return secretResolver;
+ }
+}
Added: synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecretResolver.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecretResolver.java?rev=947673&view=auto
==============================================================================
--- synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecretResolver.java (added)
+++ synapse/trunk/java/modules/securevault/src/main/java/org/apache/synapse/securevault/SecretResolver.java Mon May 24 15:42:06 2010
@@ -0,0 +1,164 @@
+/*
+ * 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.securevault;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.securevault.secret.SecretCallback;
+import org.apache.synapse.securevault.secret.SecretCallbackHandler;
+import org.apache.synapse.securevault.secret.SecretLoadingModule;
+import org.apache.synapse.securevault.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 SecureVaultException("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 SecureVaultException("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();
+ }
+}