Author: indika Date: Mon May 11 01:43:50 2009 New Revision: 35471 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=35471
Log: Remove unwanted casting Add a new factory method to Secret Information Factory Modified: branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java Modified: branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java?rev=35471&r1=35470&r2=35471&view=diff ============================================================================== --- branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java (original) +++ branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/CipherOperationMode.java Mon May 11 01:43:50 2009 @@ -23,5 +23,5 @@ */ public enum CipherOperationMode { ENCRYPT, - DECRYPT; + DECRYPT } \ No newline at end of file Modified: branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java?rev=35471&r1=35470&r2=35471&view=diff ============================================================================== --- branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java (original) +++ branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/security/enumeration/EncodingType.java Mon May 11 01:43:50 2009 @@ -23,5 +23,5 @@ */ public enum EncodingType { BASE64, - BIGINTEGER16; + BIGINTEGER16 } \ No newline at end of file Modified: branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java?rev=35471&r1=35470&r2=35471&view=diff ============================================================================== --- branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java (original) +++ branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/factory/DataSourceInformationFactory.java Mon May 11 01:43:50 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: branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java?rev=35471&r1=35470&r2=35471&view=diff ============================================================================== --- branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java (original) +++ branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/secret/SecretInformationFactory.java Mon May 11 01:43:50 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,40 @@ } // 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; + } } _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
