You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by ru...@apache.org on 2006/06/30 12:07:57 UTC

svn commit: r418225 - in /webservices/wss4j/trunk/src/org/apache/ws/security: errors.properties message/WSSecEncryptedKey.java

Author: ruchithf
Date: Fri Jun 30 03:07:55 2006
New Revision: 418225

URL: http://svn.apache.org/viewvc?rev=418225&view=rev
Log:
Added setter methods to WSSecEncryptedKey to set the size of the ephemeral key and the encryption algorithm


Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/errors.properties
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/errors.properties
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/errors.properties?rev=418225&r1=418224&r2=418225&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/errors.properties (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/errors.properties Fri Jun 30 03:07:55 2006
@@ -76,3 +76,5 @@
 requiredElementNoID=Element {0} is not signed; it does not have a wsu:Id attribute
 noSignResult=No SIGN result in WSS4J result vector
 requiredElementNotSigned=Element {0} is not included in the signature
+
+invalidKeySize=Invalid keysize
\ No newline at end of file

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java?rev=418225&r1=418224&r2=418225&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java Fri Jun 30 03:07:55 2006
@@ -95,6 +95,12 @@
     protected BinarySecurity bstToken = null;
     
     protected X509Certificate useThisCert = null;
+    
+    /**
+     * Key size in bits
+     * Defaults to 128
+     */
+    protected int keySize = 128;
 
     /**
      * Set the user name to get the encryption certificate.
@@ -286,7 +292,7 @@
     protected byte[] generateEphemeralKey() throws WSSecurityException {
         try {
             SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
-            byte[] temp = new byte[16];
+            byte[] temp = new byte[this.keySize / 8];
             random.nextBytes(temp);
             return temp;
         } catch (Exception e) {
@@ -399,5 +405,17 @@
         } else  {
             return null;
         }
+    }
+
+    public void setKeySize(int keySize) throws WSSecurityException {
+        if(keySize < 64) {
+            //Minimum size has to be 64 bits - E.g. A DES key
+            throw new WSSecurityException("invalidKeySize");
+        }
+        this.keySize = keySize;
+    }
+
+    public void setKeyEncAlgo(String keyEncAlgo) {
+        this.keyEncAlgo = keyEncAlgo;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org