You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2015/07/06 17:57:35 UTC

svn commit: r1689437 - /webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java

Author: coheigea
Date: Mon Jul  6 15:57:34 2015
New Revision: 1689437

URL: http://svn.apache.org/r1689437
Log:
[WSS-544] - Adding BinarySecurityToken test

Modified:
    webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java

Modified: webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java?rev=1689437&r1=1689436&r2=1689437&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java Mon Jul  6 15:57:34 2015
@@ -211,6 +211,39 @@ public class XOPAttachmentTest extends o
         assertTrue(processedDoc.contains(SOAP_BODY));
     }
 
+    // Here we are storing the BinarySecurityToken bytes in an attachment
+    @org.junit.Test
+    public void testSignedSOAPBody() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
+        builder.setAttachmentCallbackHandler(outboundAttachmentCallback);
+        builder.setStoreBytesInAttachment(true);
+        
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+        
+        List<Attachment> signedAttachments = outboundAttachmentCallback.getResponseAttachments();
+        assertNotNull(signedAttachments);
+        assertTrue(signedAttachments.size() == 1);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        AttachmentCallbackHandler inboundAttachmentCallback = 
+            new AttachmentCallbackHandler(signedAttachments);
+        verify(signedDoc, inboundAttachmentCallback);
+    }
+    
     /**
      * Verifies the soap envelope.
      * This method verifies all the signature generated.