Author: indika
Date: Sat May 16 02:41:27 2009
New Revision: 35964
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=35964

Log:
fix an issue with key usage

Modified:
   
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/repository/filebased/FileBaseSecretRepository.java
   
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java
   
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/IdentityKeyStoreWrapper.java
   
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/KeyStoreWrapper.java

Modified: 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/repository/filebased/FileBaseSecretRepository.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/repository/filebased/FileBaseSecretRepository.java?rev=35964&r1=35963&r2=35964&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/repository/filebased/FileBaseSecretRepository.java
     (original)
+++ 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/secret/repository/filebased/FileBaseSecretRepository.java
     Sat May 16 02:41:27 2009
@@ -31,6 +31,7 @@
 
 import java.io.ByteArrayInputStream;
 import java.security.PublicKey;
+import java.security.Key;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -148,7 +149,7 @@
             String aliasOfCert = MiscellaneousUtil.getProperty(
                     cipherProperties, sbThree.toString(), null);
 
-            PublicKey key;
+            Key key;
             if (TRUSTED.equals(keyStore)) {
                 if (aliasOfCert == null) {
                     key = trust.getPublicKey();
@@ -157,9 +158,9 @@
                 }
             } else {
                 if (aliasOfCert == null) {
-                    key = identity.getPublicKey();
+                    key = identity.getPrivateKey();
                 } else {
-                    key = identity.getPublicKey(aliasOfCert);
+                    key = identity.getPrivateKey(aliasOfCert); //TODO use 
password per 'alias'
                 }
             }
             //Creates a cipherInformation

Modified: 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java?rev=35964&r1=35963&r2=35964&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java
  (original)
+++ 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/tool/CipherTool.java
  Sat May 16 02:41:27 2009
@@ -159,9 +159,9 @@
                         assertEmpty(keyPass, KEY_PASS);
                         storeWrapper.init(getIdentityKeyStoreInformation(cmd), 
keyPass);
                         if (cipherInformation.getCipherOperationMode() == 
CipherOperationMode.ENCRYPT) {
-                            key = storeWrapper.getPrivateKey();
-                        } else {
                             key = storeWrapper.getPublicKey();
+                        } else {
+                            key = storeWrapper.getPrivateKey();
                         }
                     }
                 }

Modified: 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/IdentityKeyStoreWrapper.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/IdentityKeyStoreWrapper.java?rev=35964&r1=35963&r2=35964&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/IdentityKeyStoreWrapper.java
 (original)
+++ 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/IdentityKeyStoreWrapper.java
 Sat May 16 02:41:27 2009
@@ -69,6 +69,19 @@
     }
 
     /**
+     * Returns the private key based on initialization data
+     *
+     * @return PrivateKey if there is a one , otherwise null
+     */
+    public PrivateKey getPrivateKey(String alias) {
+        Key key = super.getPrivateKey(alias);
+        if (key instanceof PrivateKey) {
+            return (PrivateKey) key;
+        }
+        return null;
+    }
+
+    /**
      * Returns the secret key
      *
      * @param alias       The alias of the certificate in the specified 
keyStore

Modified: 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/KeyStoreWrapper.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/KeyStoreWrapper.java?rev=35964&r1=35963&r2=35964&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/KeyStoreWrapper.java
 (original)
+++ 
branches/synapse/1.3-wso2v1/modules/commons/src/main/java/org/apache/synapse/commons/security/wrappers/KeyStoreWrapper.java
 Sat May 16 02:41:27 2009
@@ -127,6 +127,16 @@
     }
 
     /**
+     * Returns the key based on default key password
+     *
+     * @param alias The alias
+     * @return Key , if there is a one , otherwise null
+     */
+    protected Key getPrivateKey(String alias) {
+        return getKey(alias, keyPassword);
+    }
+
+    /**
      * Returns the public key for the given alias
      *
      * @param alias The alias of the certificate in the specified keyStore

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to