Author: coheigea
Date: Tue Aug 17 18:51:57 2010
New Revision: 986450

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

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/WSDataRef.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
    webservices/wss4j/trunk/test/wssec/TestWSSecuritySignatureParts.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSDataRef.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/WSDataRef.java?rev=986450&r1=986449&r2=986450&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSDataRef.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSDataRef.java Tue Aug 
17 18:51:57 2010
@@ -52,6 +52,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;
     
     /**
@@ -154,5 +160,21 @@ public class WSDataRef {
     public void setAlgorithm(String algo) {
         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/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java?rev=986450&r1=986449&r2=986450&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
 Tue Aug 17 18:51:57 2010
@@ -847,6 +847,7 @@ public class SignatureProcessor implemen
                 ref.setWsuId(uri);
                 ref.setProtectedElement(se);
                 ref.setAlgorithm(signatureMethod);
+                ref.setDigestAlgorithm(siRef.getDigestMethod().getAlgorithm());
                 ref.setXpath(ReferenceListProcessor.getXPath(se));
                 protectedRefs.add(ref);
             }

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecuritySignatureParts.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecuritySignatureParts.java?rev=986450&r1=986449&r2=986450&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecuritySignatureParts.java 
(original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecuritySignatureParts.java Tue 
Aug 17 18:51:57 2010
@@ -40,6 +40,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.algorithms.MessageDigestAlgorithm;
 import org.apache.xml.security.signature.XMLSignature;
 import org.opensaml.SAMLAssertion;
 import org.w3c.dom.Document;
@@ -143,16 +144,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);
@@ -210,9 +215,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-unsubscr...@ws.apache.org
For additional commands, e-mail: wss4j-dev-h...@ws.apache.org

Reply via email to