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 2007/11/24 03:47:21 UTC

svn commit: r597786 - in /webservices/wss4j/trunk/src/org/apache/ws/security: WSSecurityEngineResult.java processor/EncryptedKeyProcessor.java util/WSSecurityUtil.java

Author: ruchithf
Date: Fri Nov 23 18:47:20 2007
New Revision: 597786

URL: http://svn.apache.org/viewvc?rev=597786&view=rev
Log:
There are instances where a key is encrypted with another symm key and we need to be able to figureout when it is encrypted with an asymm key.
This fix adds a property in the processing results to flag those cases where the key is encrypted with an asymm key.


Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java
    webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
    webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java?rev=597786&r1=597785&r2=597786&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java Fri Nov 23 18:47:20 2007
@@ -147,6 +147,15 @@
         "data-ref-uris";
 
     /**
+     * Tag denoting references the flag for asymmetric key encryption used in 
+     * encrypted key
+     *
+     * The value under this tag is of type Boolean
+     */
+    public static final java.lang.String TAG_ASYMM_KEY_ENCRYPTION =
+        "asymm-key-encr";
+    
+    /**
      * Tag denoting the X.509 certificate chain found, if applicable.
      *
      * The value under this tag is of type java.security.cert.X509Certificate[].
@@ -209,13 +218,15 @@
         byte[] decryptedKey, 
         byte[] encryptedKeyBytes,
         String encyptedKeyId, 
-        List dataRefUris
+        List dataRefUris,
+        boolean asymmEncryption
     ) {
         put(TAG_ACTION, new Integer(act));
         put(TAG_DECRYPTED_KEY, decryptedKey);
         put(TAG_ENCRYPTED_EPHEMERAL_KEY, encryptedKeyBytes);
         put(TAG_ENCRYPTED_KEY_ID, encyptedKeyId);
         put(TAG_DATA_REF_URIS, dataRefUris);
+        put(TAG_ASYMM_KEY_ENCRYPTION, new Boolean(asymmEncryption));
     }
     
     public WSSecurityEngineResult(int act, ArrayList dataRefUris) {

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java?rev=597786&r1=597785&r2=597786&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java Fri Nov 23 18:47:20 2007
@@ -62,6 +62,12 @@
     private byte[] decryptedBytes = null;
     
     private String encryptedKeyId = null;
+    
+    /**
+     * A flag to indicate this key was encrypted with an
+     * asymmetric key
+     */
+    private boolean asymmEncryption;
 
     public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, CallbackHandler cb, WSDocInfo wsDocInfo, Vector returnResults, WSSConfig wsc) throws WSSecurityException {
         if (log.isDebugEnabled()) {
@@ -82,7 +88,8 @@
                                                         this.decryptedBytes,
                                                         this.encryptedEphemeralKey,
                                                         this.encryptedKeyId, 
-                                                        dataRefUris));
+                                                        dataRefUris, 
+                                                        this.asymmEncryption));
     }
 
     public ArrayList handleEncryptedKey(Element xencEncryptedKey,
@@ -293,6 +300,7 @@
         try {
             cipher.init(Cipher.DECRYPT_MODE,
                     privateKey);
+            this.asymmEncryption = true;
         } catch (Exception e1) {
             throw new WSSecurityException(WSSecurityException.FAILED_ENC_DEC, null, null, e1);
         }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java?rev=597786&r1=597785&r2=597786&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java Fri Nov 23 18:47:20 2007
@@ -162,7 +162,7 @@
      */
     public static Element findBodyElement(Document doc, SOAPConstants sc) {
         Element soapBodyElement = (Element) WSSecurityUtil.getDirectChild(doc
-                .getFirstChild(), sc.getBodyQName().getLocalPart(), sc
+                .getDocumentElement(), sc.getBodyQName().getLocalPart(), sc
                 .getEnvelopeURI());
         return soapBodyElement;
     }



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