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 co...@apache.org on 2010/08/17 20:49:43 UTC

svn commit: r986449 - in /webservices/wss4j/branches/1_5_x-fixes: src/org/apache/ws/security/WSDataRef.java src/org/apache/ws/security/processor/SignatureProcessor.java test/wssec/TestWSSecuritySignatureParts.java

Author: coheigea
Date: Tue Aug 17 18:49:43 2010
New Revision: 986449

URL: http://svn.apache.org/viewvc?rev=986449&view=rev
Log:
[WSS-236] - Provide signature digest algorithm in signature processor results.
 - Thanks to David for the patch.

Modified:
    webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/WSDataRef.java
    webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/SignatureProcessor.java
    webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecuritySignatureParts.java

Modified: webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/WSDataRef.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/WSDataRef.java?rev=986449&r1=986448&r2=986449&view=diff
==============================================================================
--- webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/WSDataRef.java (original)
+++ webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/WSDataRef.java Tue Aug 17 18:49:43 2010
@@ -63,6 +63,12 @@ public class WSDataRef {
      */
     private String algorithm;
     
+    /**
+     * If this reference represents signed content, this field
+     * represents the digest algorithm applied to the content.
+     */
+    private String digestAlgorithm;
+    
     private boolean content;
     
     
@@ -203,4 +209,19 @@ public class WSDataRef {
         algorithm = algo;
     }
 
+    /**
+     * @return if this reference represents signed content, 
+     * the digest algorithm applied to the content.
+     */
+    public String getDigestAlgorithm() {
+        return this.digestAlgorithm;
+    }
+
+    /**
+     * @param digestAlgorithm if this reference represents 
+     * signed content, the digest algorithm applied to the content.
+     */
+    public void setDigestAlgorithm(String digestAlgorithm) {
+        this.digestAlgorithm = digestAlgorithm;
+    }
 }

Modified: webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/SignatureProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/SignatureProcessor.java?rev=986449&r1=986448&r2=986449&view=diff
==============================================================================
--- webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/SignatureProcessor.java (original)
+++ webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/SignatureProcessor.java Tue Aug 17 18:49:43 2010
@@ -544,6 +544,7 @@ public class SignatureProcessor implemen
                         ref.setProtectedElement(se);
                         ref.setXpath(ReferenceListProcessor.getXPath(se));
                         ref.setAlgorithm(si.getSignatureMethodURI());
+                        ref.setDigestAlgorithm(siRef.getMessageDigestAlgorithm().getAlgorithmURI());
                         protectedElements.add(ref);
                         returnElements.add(WSSecurityUtil.getIDFromReference(uri));
                     } else {

Modified: webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecuritySignatureParts.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecuritySignatureParts.java?rev=986449&r1=986448&r2=986449&view=diff
==============================================================================
--- webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecuritySignatureParts.java (original)
+++ webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecuritySignatureParts.java Tue Aug 17 18:49:43 2010
@@ -45,7 +45,7 @@ import org.apache.ws.security.saml.SAMLI
 import org.apache.ws.security.saml.SAMLIssuerFactory;
 import org.apache.ws.security.saml.WSSecSignatureSAML;
 import org.apache.ws.security.util.WSSecurityUtil;
-import org.apache.xml.security.c14n.Canonicalizer;
+import org.apache.xml.security.algorithms.MessageDigestAlgorithm;
 import org.apache.xml.security.signature.XMLSignature;
 import org.opensaml.SAMLAssertion;
 import org.w3c.dom.Document;
@@ -161,16 +161,20 @@ public class TestWSSecuritySignaturePart
         WSSecurityEngineResult actionResult = 
             WSSecurityUtil.fetchActionResult(results, WSConstants.SIGN);
         assertTrue(actionResult != null);
+        assertFalse(actionResult.isEmpty());
         final java.util.List refs =
             (java.util.List) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-        assertTrue(actionResult != null && !actionResult.isEmpty());
+        
         WSDataRef wsDataRef = (WSDataRef)refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/soapenv:Envelope/soapenv:Header/foo:foobar", xpath);
         assertEquals(XMLSignature.ALGO_ID_SIGNATURE_RSA, wsDataRef.getAlgorithm());
         
+        assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1, wsDataRef.getDigestAlgorithm());
+        
         String sigMethod = (String)actionResult.get(WSSecurityEngineResult.TAG_SIGNATURE_METHOD);
         assertEquals(XMLSignature.ALGO_ID_SIGNATURE_RSA, sigMethod);
+        
         String c14nMethod = 
             (String)actionResult.get(WSSecurityEngineResult.TAG_CANONICALIZATION_METHOD);
         assertEquals(WSConstants.C14N_EXCL_OMIT_COMMENTS, c14nMethod);
@@ -230,9 +234,10 @@ public class TestWSSecuritySignaturePart
         WSSecurityEngineResult signActionResult = 
             WSSecurityUtil.fetchActionResult(results, WSConstants.SIGN);
         assertTrue(signActionResult != null);
+        assertFalse(signActionResult.isEmpty());
         final java.util.List refs =
             (java.util.List) signActionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-        assertTrue(signActionResult != null && !signActionResult.isEmpty());
+        
         WSDataRef wsDataRef = (WSDataRef)refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/soapenv:Envelope/soapenv:Header/wsse:Security/Assertion", xpath);



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