ws-wss4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r783392 - in /webservices/wss4j/trunk: src/org/apache/ws/security/message/WSSecSignature.java test/wssec/TestWSSecurityNew3.java
Date Wed, 10 Jun 2009 15:25:12 GMT
Author: coheigea
Date: Wed Jun 10 15:25:11 2009
New Revision: 783392

URL: http://svn.apache.org/viewvc?rev=783392&view=rev
Log:
Added some tests for inclusive c14n

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java?rev=783392&r1=783391&r2=783392&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java Wed Jun
10 15:25:11 2009
@@ -592,12 +592,8 @@
             NamedNodeMap attributes = parent.getAttributes();
             for (int i = 0; i < attributes.getLength(); i++) {
                 Node attribute = attributes.item(i);
-                if (attribute.getNamespaceURI() != null
-                    && attribute.getNamespaceURI().equals(
-                        org.apache.ws.security.WSConstants.XMLNS_NS
-                    )
-                ) {
-                    if (attribute.getNodeName().equals("xmlns")) {
+                if (WSConstants.XMLNS_NS.equals(attribute.getNamespaceURI())) {
+                    if ("xmlns".equals(attribute.getNodeName())) {
                         result.add("#default");
                     } else {
                         result.add(attribute.getLocalName());
@@ -610,12 +606,8 @@
             NamedNodeMap attributes = target.getAttributes();
             for (int i = 0; i < attributes.getLength(); i++) {
                 Node attribute = attributes.item(i);
-                if (attribute.getNamespaceURI() != null
-                    && attribute.getNamespaceURI().equals(
-                        org.apache.ws.security.WSConstants.XMLNS_NS
-                    )
-                ) {
-                    if (attribute.getNodeName().equals("xmlns")) {
+                if (WSConstants.XMLNS_NS.equals(attribute.getNamespaceURI())) {
+                    if ("xmlns".equals(attribute.getNodeName())) {
                         result.remove("#default");
                     } else {
                         result.remove(attribute.getLocalName());

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java?rev=783392&r1=783391&r2=783392&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java Wed Jun 10 15:25:11 2009
@@ -28,6 +28,7 @@
 import org.apache.ws.security.WSEncryptionPart;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngine;
+import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
 import org.apache.ws.security.message.WSSecSignature;
@@ -118,6 +119,60 @@
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    public void testSignatureInclusiveC14N() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setSigCanonicalization(WSConstants.C14N_OMIT_COMMENTS);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
+     */
+    public void testSignatureInclusivePrefixes() throws Exception {
+        WSSConfig wssConfig = WSSConfig.getNewInstance();
+        wssConfig.setWsiBSPCompliant(true);
+        WSSecSignature builder = new WSSecSignature();
+        builder.setWsConfig(wssConfig);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Signing....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
+     */
     public void testBSTSignature() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");



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


Mime
View raw message