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 2009/05/11 10:39:34 UTC

svn commit: r773498 - in /synapse/trunk/java/modules: core/src/main/java/org/apache/synapse/security/enumeration/ utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/ utils/src/main/java/org/apache/synapse/commons/util/secret/

Author: indika
Date: Mon May 11 08:39:34 2009
New Revision: 773498

URL: http://svn.apache.org/viewvc?rev=773498&view=rev
Log:
Remove unwanted casting 
Add a new factory method to Secret Information Factory 

Modified:
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.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/SecretInformationFactory.java

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java?rev=773498&r1=773497&r2=773498&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java Mon May 11 08:39:34 2009
@@ -23,5 +23,5 @@
  */
 public enum CipherOperationMode {
     ENCRYPT,
-    DECRYPT;
+    DECRYPT
 }
\ No newline at end of file

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java?rev=773498&r1=773497&r2=773498&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java Mon May 11 08:39:34 2009
@@ -23,5 +23,5 @@
  */
 public enum EncodingType {
     BASE64,
-    BIGINTEGER16;
+    BIGINTEGER16
 }
\ No newline at end of file

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=773498&r1=773497&r2=773498&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 May 11 08:39:34 2009
@@ -90,34 +90,34 @@
         datasourceInformation.setDriver(driver);
         datasourceInformation.setUrl(url);
 
-        String dataSourceName = (String) MiscellaneousUtil.getProperty(
+        String dataSourceName = MiscellaneousUtil.getProperty(
                 properties, prefix + DataSourceConstants.PROP_DSNAME, dsName,
                 String.class);
         datasourceInformation.setDatasourceName(dataSourceName);
 
-        String dsType = (String) MiscellaneousUtil.getProperty(
+        String dsType = MiscellaneousUtil.getProperty(
                 properties, prefix + DataSourceConstants.PROP_TYPE,
                 DataSourceConstants.PROP_BASIC_DATA_SOURCE, String.class);
 
         datasourceInformation.setType(dsType);
 
-        String repositoryType = (String) MiscellaneousUtil.getProperty(
+        String repositoryType = MiscellaneousUtil.getProperty(
                 properties, prefix + DataSourceConstants.PROP_REGISTRY,
                 DataSourceConstants.PROP_REGISTRY_MEMORY, String.class);
 
         datasourceInformation.setRepositoryType(repositoryType);
 
-        Integer maxActive = (Integer) MiscellaneousUtil.getProperty(
+        Integer maxActive = MiscellaneousUtil.getProperty(
                 properties, prefix + DataSourceConstants.PROP_MAXACTIVE,
                 GenericObjectPool.DEFAULT_MAX_ACTIVE, Integer.class);
         datasourceInformation.setMaxActive(maxActive);
 
-        Integer maxIdle = (Integer) MiscellaneousUtil.getProperty(
+        Integer maxIdle = MiscellaneousUtil.getProperty(
                 properties, prefix + DataSourceConstants.PROP_MAXIDLE,
                 GenericObjectPool.DEFAULT_MAX_IDLE, Integer.class);
         datasourceInformation.setMaxIdle(maxIdle);
 
-        Long maxWait = (Long) MiscellaneousUtil.getProperty(
+        Long maxWait = MiscellaneousUtil.getProperty(
                 properties, prefix + DataSourceConstants.PROP_MAXWAIT,
                 GenericObjectPool.DEFAULT_MAX_WAIT, Long.class);
 
@@ -143,51 +143,51 @@
                 "cpds");
         datasourceInformation.addParameter(suffix, name);
 
-        boolean defaultAutoCommit = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean defaultAutoCommit = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_DEFAULTAUTOCOMMIT, true,
                 Boolean.class);
 
-        boolean defaultReadOnly = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean defaultReadOnly = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_DEFAULTREADONLY, false,
                 Boolean.class);
 
-        boolean testOnBorrow = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean testOnBorrow = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_TESTONBORROW, true,
                 Boolean.class);
 
-        boolean testOnReturn = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean testOnReturn = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_TESTONRETURN, false,
                 Boolean.class);
 
-        long timeBetweenEvictionRunsMillis = (Long) MiscellaneousUtil.getProperty(properties,
+        long timeBetweenEvictionRunsMillis = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_TIMEBETWEENEVICTIONRUNSMILLIS,
                 GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, Long.class);
 
-        int numTestsPerEvictionRun = (Integer) MiscellaneousUtil.getProperty(properties,
+        int numTestsPerEvictionRun = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_NUMTESTSPEREVICTIONRUN,
                 GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, Integer.class);
 
-        long minEvictableIdleTimeMillis = (Long) MiscellaneousUtil.getProperty(properties,
+        long minEvictableIdleTimeMillis = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_MINEVICTABLEIDLETIMEMILLIS,
                 GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, Long.class);
 
-        boolean testWhileIdle = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean testWhileIdle = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_TESTWHILEIDLE, false,
                 Boolean.class);
 
         String validationQuery = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_VALIDATIONQUERY, null);
 
-        int minIdle = (Integer) MiscellaneousUtil.getProperty(properties,
+        int minIdle = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_MINIDLE,
                 GenericObjectPool.DEFAULT_MIN_IDLE,
                 Integer.class);
 
-        int initialSize = (Integer) MiscellaneousUtil.getProperty(
+        int initialSize = MiscellaneousUtil.getProperty(
                 properties, prefix + DataSourceConstants.PROP_INITIALSIZE, 0,
                 Integer.class);
 
-        int defaultTransactionIsolation = (Integer) MiscellaneousUtil.getProperty(properties,
+        int defaultTransactionIsolation = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_DEFAULTTRANSACTIONISOLATION, -1,
                 Integer.class);
 
@@ -195,29 +195,29 @@
                 properties, prefix + DataSourceConstants.PROP_DEFAULTCATALOG, null);
 
         boolean accessToUnderlyingConnectionAllowed =
-                (Boolean) MiscellaneousUtil.getProperty(properties,
+                MiscellaneousUtil.getProperty(properties,
                         prefix +
                                 DataSourceConstants.
                                         PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED,
                         false, Boolean.class);
 
-        boolean removeAbandoned = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean removeAbandoned = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_REMOVEABANDONED, false,
                 Boolean.class);
 
-        int removeAbandonedTimeout = (Integer) MiscellaneousUtil.getProperty(properties,
+        int removeAbandonedTimeout = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_REMOVEABANDONEDTIMEOUT, 300,
                 Integer.class);
 
-        boolean logAbandoned = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean logAbandoned = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_LOGABANDONED, false,
                 Boolean.class);
 
-        boolean poolPreparedStatements = (Boolean) MiscellaneousUtil.getProperty(properties,
+        boolean poolPreparedStatements = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_POOLPREPAREDSTATEMENTS, false,
                 Boolean.class);
 
-        int maxOpenPreparedStatements = (Integer) MiscellaneousUtil.getProperty(properties,
+        int maxOpenPreparedStatements = MiscellaneousUtil.getProperty(properties,
                 prefix + DataSourceConstants.PROP_MAXOPENPREPAREDSTATEMENTS,
                 GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, Integer.class);
 
@@ -266,8 +266,8 @@
                         properties, prefix + DataSourceConstants.PROP_PROVIDER_PORT,
                         null));
 
-        String passwordPrompt = (String) MiscellaneousUtil.getProperty(
-                properties, prefix + SecretConfigurationConstants.PROP_PASSWORD_PROMPT, 
+        String passwordPrompt = MiscellaneousUtil.getProperty(
+                properties, prefix + SecretConfigurationConstants.PROP_PASSWORD_PROMPT,
                 "Password for datasource " + dsName, String.class);
 
         SecretInformation secretInformation = SecretInformationFactory.createSecretInformation(

Modified: synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java?rev=773498&r1=773497&r2=773498&view=diff
==============================================================================
--- synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java (original)
+++ synapse/trunk/java/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java Mon May 11 08:39:34 2009
@@ -42,7 +42,6 @@
      * @param configurationPrefix The configuration prefix to use
      * @param passwordPrompt      A specific password prompt to use
      *                            (only for interactive authentication providers)
-     * 
      * @return SecretInformation instance
      */
     public static SecretInformation createSecretInformation(
@@ -50,14 +49,14 @@
 
         SecretInformation secretInformation = new SecretInformation();
 
-        String user = (String) MiscellaneousUtil.getProperty(
+        String user = MiscellaneousUtil.getProperty(
                 properties, configurationPrefix + SecretConfigurationConstants.PROP_USER_NAME, null,
                 String.class);
         if (user != null && !"".equals(user)) {
             secretInformation.setUser(user);
         }
 
-        String password = (String) MiscellaneousUtil.getProperty(
+        String password = MiscellaneousUtil.getProperty(
                 properties, configurationPrefix + SecretConfigurationConstants.PROP_PASSWORD, null,
                 String.class);
 
@@ -66,20 +65,41 @@
         }
 
         // set specific password provider if configured
-        SecretCallbackHandler passwordProvider = 
-            SecretCallbackHandlerFactory.createSecretCallbackHandler(properties,
-                    configurationPrefix + SecretConfigurationConstants.PROP_PASSWORD_PROVIDER);
+        SecretCallbackHandler passwordProvider =
+                SecretCallbackHandlerFactory.createSecretCallbackHandler(properties,
+                        configurationPrefix + SecretConfigurationConstants.PROP_PASSWORD_PROVIDER);
 
         // if no specific password provider configured, use default password provider
         if (passwordProvider == null) {
             passwordProvider = SecretCallbackHandlerFactory.createSecretCallbackHandler(
-                    properties, 
-                    SecretConfigurationConstants.GLOBAL_PREFIX 
-                    + SecretConfigurationConstants.PROP_PASSWORD_PROVIDER);
+                    properties,
+                    SecretConfigurationConstants.GLOBAL_PREFIX
+                            + SecretConfigurationConstants.PROP_PASSWORD_PROVIDER);
         }
         secretInformation.setPasswordProvider(passwordProvider);
         secretInformation.setPasswordPrompt(passwordPrompt);
 
         return secretInformation;
     }
+
+    /**
+     * Factory method to create a SecretInformation instance based on the given information
+     *
+     * @param secretProvider A SecretCallbackHandler implementation to use to get secrets
+     * @param aliasPassword  The  alias password
+     * @param passwordPrompt A specific password prompt to use
+     *                       (only for interactive authentication providers)
+     * @return SecretInformation instance
+     */
+    public static SecretInformation createSecretInformation(String secretProvider,
+                                                            String aliasPassword,
+                                                            String passwordPrompt) {
+
+        SecretInformation secretInformation = new SecretInformation();
+        secretInformation.setAliasPassword(aliasPassword);
+        secretInformation.setPasswordProvider(
+                SecretCallbackHandlerFactory.createSecretCallbackHandler(secretProvider));
+        secretInformation.setPasswordPrompt(passwordPrompt);
+        return secretInformation;
+    }
 }