Author: indika
Date: Mon Mar 9 10:10:01 2009
New Revision: 751643
URL: http://svn.apache.org/viewvc?rev=751643&view=rev
Log:
Add Callbacks based secret loading in for root level secret repository
Add SecretCallbackHandlerFactory
Added:
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretCallbackHandlerFactory.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdmin.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdminMBean.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceFactory.java
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SingleSecretCallback.java
synapse/trunk/java/repository/conf/synapse.properties
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdmin.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdmin.java?rev=751643&r1=751642&r2=751643&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdmin.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdmin.java
Mon Mar 9 10:10:01 2009
@@ -18,6 +18,7 @@
*/
package org.apache.synapse.security.mbean;
+import org.apache.synapse.config.SynapsePropertiesLoader;
import org.apache.synapse.security.secret.SecretManager;
@@ -37,22 +38,10 @@
* @see SecretManagerAdminMBean
*/
public void init() {
- this.secretManager.init();
+
this.secretManager.init(SynapsePropertiesLoader.loadSynapseProperties());
}
public void shutDown() {
this.secretManager.shoutDown();
}
-
- public void setIdentityStorePassword(String identityStorePassword) {
- this.secretManager.setIdentityKeyPassword(identityStorePassword);
- }
-
- public void setIdentityKeyPassword(String identityKeyPassword) {
- secretManager.setIdentityKeyPassword(identityKeyPassword);
- }
-
- public void setTrustStorePassword(String trustStorePassword) {
- this.secretManager.setTrustStorePassword(trustStorePassword);
- }
}
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdminMBean.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdminMBean.java?rev=751643&r1=751642&r2=751643&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdminMBean.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/mbean/SecretManagerAdminMBean.java
Mon Mar 9 10:10:01 2009
@@ -33,19 +33,4 @@
* Shutting Down the SecretManager
*/
public void shutDown();
-
- /**
- * @param identityStorePassword Identity keyStore password
- */
- public void setIdentityStorePassword(String identityStorePassword);
-
- /**
- * @param identityKeyPassword Private key Password
- */
- public void setIdentityKeyPassword(String identityKeyPassword);
-
- /**
- * @param trustStorePassword TrustStore password
- */
- public void setTrustStorePassword(String trustStorePassword);
}
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java?rev=751643&r1=751642&r2=751643&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/secret/SecretManager.java
Mon Mar 9 10:10:01 2009
@@ -6,7 +6,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseException;
-import org.apache.synapse.config.SynapsePropertiesLoader;
import org.apache.synapse.security.definition.IdentityKeyStoreInformation;
import org.apache.synapse.security.definition.TrustKeyStoreInformation;
import
org.apache.synapse.security.definition.factory.KeyStoreInformationFactory;
@@ -15,6 +14,7 @@
import org.apache.synapse.security.mbean.SecretManagerAdmin;
import org.apache.synapse.commons.util.MiscellaneousUtil;
import org.apache.synapse.commons.util.MBeanRegistrar;
+import org.apache.synapse.commons.util.secret.*;
import java.util.Properties;
@@ -28,14 +28,25 @@
private final static SecretManager SECRET_MANAGER = new SecretManager();
/* Default configuration file path for secret manager*/
- private final static String DEFAULT_CONF_LOCATION =
"secret-manager.properties";
+ private final static String PROP_DEFAULT_CONF_LOCATION =
"secret-manager.properties";
/* If the location of the secret manager configuration is provided as a
property- it's name */
- private final static String SECRET_MANAGER_CONF = "secret.manager.conf";
+ private final static String PROP_SECRET_MANAGER_CONF =
"secret.manager.conf";
/* Property key for secretRepositories*/
- private final static String SECRET_REPOSITORIES = "secretRepositories";
+ private final static String PROP_SECRET_REPOSITORIES =
"secretRepositories";
/* Type of the secret repository */
- private final static String PROVIDER = "provider";
-
+ private final static String PROP_PROVIDER = "provider";
+ /* Property key secret manager */
+ private final static String PROP_SECRET_MANAGER = "secretManager";
+ /* Property key password provider */
+ private final static String PROP_PASSWORD_PROVIDER = "passwordProvider";
+ /* Prompt for trust store password*/
+ private final static String TRUSTSTORE_PASSWORD_PROMPT = "Trust Store
Password > ";
+ /* Prompt for identity store password*/
+ private final static String IDENTITYSTORE_PASSWORD_PROMPT = "Identity
Store Password > ";
+ /* Prompt for identity store private key password*/
+ private final static String IDENTITYSTORE_PRIVATE_KEY_PASSWORD_PROMPT
+ = "Identity Store Private Key Password > ";
+ /* Dot string */
private final static String DOT = ".";
/*Root Secret Repository */
@@ -43,12 +54,6 @@
/* True , if secret manage has been started up properly- need to have a at
least one Secret Repository*/
private boolean initialized = false;
- /* Identity key store password*/
- private String identityStorePassword;
- /* Identity key password */
- private String identityKeyPassword;
- /* Trust store password */
- private String trustStorePassword;
public static SecretManager getInstance() {
return SECRET_MANAGER;
@@ -59,9 +64,11 @@
}
/**
- * Initialize the Secret Manager
+ * Initializes the Secret Manager by providing configuration properties
+ *
+ * @param properties Configuration properties
*/
- public void init() {
+ public void init(Properties properties) {
if (initialized) {
if (log.isDebugEnabled()) {
@@ -70,73 +77,28 @@
return;
}
- Properties configurationProperties = loadConfigurationPropertis();
- if (configurationProperties == null) {
+ if (properties == null) {
if (log.isDebugEnabled()) {
- log.debug("Secret Manager configuration properties cannot be
found. " +
- "Cannot initialize SecretManager");
+ log.debug("KeyStore configuration properties cannot be found");
}
return;
}
- if (assertValidPasswords(identityStorePassword, identityKeyPassword,
trustStorePassword)) {
- init(configurationProperties, identityStorePassword,
- identityKeyPassword, trustStorePassword);
- }
- }
+ String configurationFile = MiscellaneousUtil.getProperty(
+ properties, PROP_SECRET_MANAGER_CONF,
PROP_DEFAULT_CONF_LOCATION);
- /**
- * Returns the secret corresponding to the given alias name
- *
- * @param alias The logical or alias name
- * @return If there is a secret , otherwise , alias itself
- */
- public String getSecret(String alias) {
- if (!initialized || parentRepository == null) {
+ Properties configurationProperties =
MiscellaneousUtil.loadProperties(configurationFile);
+ if (configurationProperties == null ||
configurationProperties.isEmpty()) {
if (log.isDebugEnabled()) {
- log.debug("There is no secret repository. Returning alias
itself");
+ log.debug("Configuration properties can not be loaded form : "
+
+ configurationFile + " Will use synapse properties");
}
- return alias;
- }
- return parentRepository.getSecret(alias);
- }
-
- public boolean isInitialized() {
- return initialized;
- }
+ configurationProperties = properties;
- public void shoutDown() {
- this.parentRepository = null;
- this.initialized = false;
- }
-
- public void setIdentityStorePassword(String identityStorePassword) {
- this.identityStorePassword = identityStorePassword;
- }
-
- public void setIdentityKeyPassword(String identityKeyPassword) {
- this.identityKeyPassword = identityKeyPassword;
- }
-
- public void setTrustStorePassword(String trustStorePassword) {
- this.trustStorePassword = trustStorePassword;
- }
-
- /**
- * Initializes the Secret Manager .Paswords for both trusted and private
keyStores have to be
- * provided separately due to security reasons
- *
- * @param configurationProperties Secret Manager configuration properties
- * @param identityStorePass Password to access private keyStore
- * @param identityKeyPass Password to access private or secret keys
- * @param trustStorePass Password to access trusted KeyStore
- */
- private void init(Properties configurationProperties, String
identityStorePass,
- String identityKeyPass, String trustStorePass) {
+ }
- Properties keyStoreProperties =
SynapsePropertiesLoader.loadSynapseProperties();
String repositoriesString = MiscellaneousUtil.getProperty(
- configurationProperties, SECRET_REPOSITORIES, null);
+ configurationProperties, PROP_SECRET_REPOSITORIES, null);
if (repositoriesString == null || "".equals(repositoriesString)) {
if (log.isDebugEnabled()) {
log.debug("No secret repositories have been configured");
@@ -152,14 +114,56 @@
return;
}
+ SecretCallbackHandler secretCallbackHandler =
+
SecretCallbackHandlerFactory.createSecretCallbackHandler(properties,
+ PROP_SECRET_MANAGER + DOT + PROP_PASSWORD_PROVIDER);
+
+ if (secretCallbackHandler == null) {
+ return;
+ }
+
+ String identityStorePass;
+ String identityKeyPass;
+ String trustStorePass;
+
+ SingleSecretCallback trustStorePassSecretCallback
+ = new SingleSecretCallback(TRUSTSTORE_PASSWORD_PROMPT);
+ SingleSecretCallback identityStorePassSecretCallback
+ = new SingleSecretCallback(IDENTITYSTORE_PASSWORD_PROMPT);
+ SingleSecretCallback identityKeyPassSecretCallback
+ = new
SingleSecretCallback(IDENTITYSTORE_PRIVATE_KEY_PASSWORD_PROMPT);
+
+ MultiSecretCallback callback = new MultiSecretCallback();
+ callback.addSecretCallback(trustStorePassSecretCallback);
+ callback.addSecretCallback(identityStorePassSecretCallback);
+ callback.addSecretCallback(identityKeyPassSecretCallback);
+
+ SecretLoadingModule secretLoadingModule = new SecretLoadingModule();
+ secretLoadingModule.init(new
SecretCallbackHandler[]{secretCallbackHandler});
+
+ SecretCallback[] secretCallbacks = new SecretCallback[]{callback};
+ secretLoadingModule.load(secretCallbacks);
+
+ identityKeyPass = identityKeyPassSecretCallback.getSecret();
+ identityStorePass = identityStorePassSecretCallback.getSecret();
+ trustStorePass = trustStorePassSecretCallback.getSecret();
+
+ if (validatePasswords(identityStorePass, identityKeyPass,
trustStorePass)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Either Identity or Trust keystore password is
mandotory" +
+ " in order to initialized secret manager.");
+ }
+ return;
+ }
+
//Create a KeyStore Information for private key entry KeyStore
IdentityKeyStoreInformation keyStoreInformation =
-
KeyStoreInformationFactory.createIdentityKeyStoreInformation(keyStoreProperties);
+
KeyStoreInformationFactory.createIdentityKeyStoreInformation(properties);
keyStoreInformation.setKeyStorePassword(identityStorePass);
// Create a KeyStore Information for trusted certificate KeyStore
TrustKeyStoreInformation trustInformation =
-
KeyStoreInformationFactory.createTrustKeyStoreInformation(keyStoreProperties);
+
KeyStoreInformationFactory.createTrustKeyStoreInformation(properties);
trustInformation.setKeyStorePassword(trustStorePass);
IdentityKeyStoreWrapper identityKeyStoreWrapper = new
IdentityKeyStoreWrapper();
@@ -172,12 +176,12 @@
for (String secretRepo : repositories) {
StringBuffer sb = new StringBuffer();
- sb.append(SECRET_REPOSITORIES);
+ sb.append(PROP_SECRET_REPOSITORIES);
sb.append(DOT);
sb.append(secretRepo);
String id = sb.toString();
sb.append(DOT);
- sb.append(PROVIDER);
+ sb.append(PROP_PROVIDER);
String provider = MiscellaneousUtil.getProperty(
configurationProperties, sb.toString(), null);
@@ -204,12 +208,12 @@
secretRepository.setParent(currentParent);
currentParent = secretRepository;
if (log.isDebugEnabled()) {
- log.debug("Successfully Initiate a Secret Repository
provided by : " +
- provider);
+ log.debug("Successfully Initiate a Secret Repository
provided by : "
+ + provider);
}
} else {
- handleException("Invalid class as SecretRepositoryProvider
: Class Name : " +
- provider);
+ handleException("Invalid class as SecretRepositoryProvider
: Class Name : "
+ + provider);
}
} catch (ClassNotFoundException e) {
@@ -224,42 +228,29 @@
initialized = true;
}
- private boolean assertValidPasswords(String identityStorePass,
- String identityKeyPass, String
trustStorePass) {
- boolean isValid = false;
- if (trustStorePass != null && !"".equals(trustStorePass)) {
+ /**
+ * Returns the secret corresponding to the given alias name
+ *
+ * @param alias The logical or alias name
+ * @return If there is a secret , otherwise , alias itself
+ */
+ public String getSecret(String alias) {
+ if (!initialized || parentRepository == null) {
if (log.isDebugEnabled()) {
- log.debug("Trust Store Password cannot be found.");
- }
- isValid = true;
- } else {
- if (identityStorePass != null && !"".equals(identityStorePass) &&
- identityKeyPass != null && !"".equals(identityKeyPass)) {
- isValid = true;
+ log.debug("There is no secret repository. Returning alias
itself");
}
+ return alias;
}
- return isValid;
+ return parentRepository.getSecret(alias);
}
- private Properties loadConfigurationPropertis() {
- Properties keyStoreProperties =
SynapsePropertiesLoader.loadSynapseProperties();
- if (keyStoreProperties != null) {
- String configurationFile = MiscellaneousUtil.getProperty(
- keyStoreProperties, SECRET_MANAGER_CONF,
DEFAULT_CONF_LOCATION);
-
- Properties configurationProperties =
MiscellaneousUtil.loadProperties(
- configurationFile);
- if (configurationProperties == null ||
configurationProperties.isEmpty()) {
- if (log.isDebugEnabled()) {
- log.debug("Configuration properties can not be loaded form
: " +
- configurationFile + " Will use synapse
properties");
- }
- configurationProperties = keyStoreProperties;
+ public boolean isInitialized() {
+ return initialized;
+ }
- }
- return configurationProperties;
- }
- return null;
+ public void shoutDown() {
+ this.parentRepository = null;
+ this.initialized = false;
}
private static void handleException(String msg) {
@@ -269,7 +260,28 @@
private void registerMBean() {
MBeanRegistrar mBeanRegistrar = MBeanRegistrar.getInstance();
- mBeanRegistrar.registerMBean(new SecretManagerAdmin(this),
"SecurityAdminServices",
- "SecretManagerAdmin");
+ mBeanRegistrar.registerMBean(new SecretManagerAdmin(this),
+ "SecurityAdminServices", "SecretManagerAdmin");
+ }
+
+ private boolean validatePasswords(String identityStorePass,
+ String identityKeyPass, String
trustStorePass) {
+ boolean isValid = false;
+ if (trustStorePass != null && !"".equals(trustStorePass)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Trust Store Password cannot be found.");
+ }
+ isValid = true;
+ } else {
+ if (identityStorePass != null && !"".equals(identityStorePass) &&
+ identityKeyPass != null && !"".equals(identityKeyPass)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Identity Store Password " +
+ "and Identity Store private key Password cannot be
found.");
+ }
+ isValid = true;
+ }
+ }
+ return isValid;
}
-}
+}
\ No newline at end of file
Modified:
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceFactory.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceFactory.java?rev=751643&r1=751642&r2=751643&view=diff
==============================================================================
---
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceFactory.java
(original)
+++
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceFactory.java
Mon Mar 9 10:10:01 2009
@@ -75,10 +75,9 @@
if (secretCallbackHandler != null) {
SecretLoadingModule secretLoadingModule = new
SecretLoadingModule();
secretLoadingModule.init(new
SecretCallbackHandler[]{secretCallbackHandler});
- SecretCallback[] secretCallbacks = new SecretCallback[0];
- SingleSecretCallback secretCallback = new SingleSecretCallback();
- secretCallback.setPrompt(PROMPT + information.getAlias());
- secretCallbacks[0] = secretCallback;
+ SingleSecretCallback secretCallback =
+ new SingleSecretCallback(PROMPT + information.getAlias());
+ SecretCallback[] secretCallbacks = new
SecretCallback[]{secretCallback};
secretLoadingModule.load(secretCallbacks);
password = secretCallback.getSecret();
}
Modified:
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java?rev=751643&r1=751642&r2=751643&view=diff
==============================================================================
---
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java
(original)
+++
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java
Mon Mar 9 10:10:01 2009
@@ -24,7 +24,7 @@
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.synapse.commons.util.MiscellaneousUtil;
import org.apache.synapse.commons.util.SynapseUtilException;
-import org.apache.synapse.commons.util.secret.SecretCallbackHandler;
+import org.apache.synapse.commons.util.secret.SecretCallbackHandlerFactory;
import
org.apache.synapse.commons.util.datasource.DataSourceConfigurationConstants;
import org.apache.synapse.commons.util.datasource.DataSourceInformation;
@@ -275,32 +275,11 @@
MiscellaneousUtil.getProperty(
properties, prefix +
DataSourceConfigurationConstants.PROP_PROVIDER_PORT,
null));
- String provider = MiscellaneousUtil.getProperty(
- properties, prefix +
DataSourceConfigurationConstants.PROP_PASSWORD_PROVIDER,
- null);
-
- if (provider != null && !"".equals(provider)) {
-
- try {
- Class aClass =
Thread.currentThread().getContextClassLoader().loadClass(provider);
- Object instance = aClass.newInstance();
-
- if (instance != null && instance instanceof
SecretCallbackHandler) {
- information.setPasswordProvider((SecretCallbackHandler)
instance);
- } else {
- handleException("Invalid class as SecretCallbackHandler :
Class Name : " +
- provider);
- }
-
- } catch (ClassNotFoundException e) {
- handleException("A SecretCallbackHandler cannot be found for
class name : " +
- provider, e);
- } catch (IllegalAccessException e) {
- handleException("Error creating a instance from class : " +
provider, e);
- } catch (InstantiationException e) {
- handleException("Error creating a instance from class : " +
provider, e);
- }
- }
+
+ information.setPasswordProvider(
+
SecretCallbackHandlerFactory.createSecretCallbackHandler(properties,
+ prefix +
DataSourceConfigurationConstants.PROP_PASSWORD_PROVIDER));
+
return information;
}
@@ -313,15 +292,4 @@
log.error(msg);
throw new SynapseUtilException(msg);
}
-
- /**
- * Helper methods for handle errors.
- *
- * @param msg The error message
- * @param e Thorwen Exception
- */
- private static void handleException(String msg, Exception e) {
- log.error(msg, e);
- throw new SynapseUtilException(msg, e);
- }
}
Added:
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretCallbackHandlerFactory.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretCallbackHandlerFactory.java?rev=751643&view=auto
==============================================================================
---
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretCallbackHandlerFactory.java
(added)
+++
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretCallbackHandlerFactory.java
Mon Mar 9 10:10:01 2009
@@ -0,0 +1,89 @@
+/*
+ * 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.util.secret;
+
+import org.apache.synapse.commons.util.MiscellaneousUtil;
+import org.apache.synapse.commons.util.SynapseUtilException;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import java.util.Properties;
+
+/**
+ *
+ */
+public class SecretCallbackHandlerFactory {
+
+ private static final Log log =
LogFactory.getLog(SecretCallbackHandlerFactory.class);
+
+ public static SecretCallbackHandler createSecretCallbackHandler(Properties
properties, String key) {
+ String provider = MiscellaneousUtil.getProperty(
+ properties, key,
+ null);
+ return createSecretCallbackHandler(provider);
+
+ }
+
+ public static SecretCallbackHandler createSecretCallbackHandler(String
provider) {
+ if (provider != null && !"".equals(provider)) {
+
+ try {
+ Class aClass =
Thread.currentThread().getContextClassLoader().loadClass(provider);
+ Object instance = aClass.newInstance();
+
+ if (instance != null && instance instanceof
SecretCallbackHandler) {
+ return (SecretCallbackHandler) instance;
+ } else {
+ handleException("Invalid class as SecretCallbackHandler :
Class Name : " +
+ provider);
+ }
+
+ } catch (ClassNotFoundException e) {
+ handleException("A SecretCallbackHandler cannot be found for
class name : " +
+ provider, e);
+ } catch (IllegalAccessException e) {
+ handleException("Error creating a instance from class : " +
provider, e);
+ } catch (InstantiationException e) {
+ handleException("Error creating a instance from class : " +
provider, e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Helper methods for handle errors.
+ *
+ * @param msg The error message
+ * @param e Thorwen Exception
+ */
+ private static void handleException(String msg, Exception e) {
+ log.error(msg, e);
+ throw new SynapseUtilException(msg, e);
+ }
+
+ /**
+ * Helper methods for handle errors.
+ *
+ * @param msg The error message
+ */
+ private static void handleException(String msg) {
+ log.error(msg);
+ throw new SynapseUtilException(msg);
+ }
+}
Modified:
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SingleSecretCallback.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SingleSecretCallback.java?rev=751643&r1=751642&r2=751643&view=diff
==============================================================================
---
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SingleSecretCallback.java
(original)
+++
synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SingleSecretCallback.java
Mon Mar 9 10:10:01 2009
@@ -30,6 +30,18 @@
/* The Id to identify the context that secret is going to be used */
private String id;
+ public SingleSecretCallback(String prompt) {
+ this.prompt = prompt;
+ }
+
+ public SingleSecretCallback(String prompt, String id) {
+ this(prompt);
+ this.id = id;
+ }
+
+ public SingleSecretCallback() {
+ }
+
public void setSecret(String secret) {
this.secret = secret;
}
Modified: synapse/trunk/java/repository/conf/synapse.properties
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/synapse.properties?rev=751643&r1=751642&r2=751643&view=diff
==============================================================================
--- synapse/trunk/java/repository/conf/synapse.properties (original)
+++ synapse/trunk/java/repository/conf/synapse.properties Mon Mar 9 10:10:01
2009
@@ -77,6 +77,8 @@
#synapse.datasources.reportds.maxIdle=20
#synapse.datasources.reportds.maxWait=10000
#
+#secretManager.passwordProvider=org.apache.synapse.commons.util.secret.SecretCallbackHandler
implementation
+#
#secretRepositories=file
##
#secretRepositories.file.provider=org.apache.synapse.security.secret.repository.filebased.FileBaseSecretRepositoryProvider