ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1627495 - /webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java
Date Thu, 25 Sep 2014 09:41:18 GMT
Author: coheigea
Date: Thu Sep 25 09:41:18 2014
New Revision: 1627495

URL: http://svn.apache.org/r1627495
Log:
Adding some more crypto provider tests

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java?rev=1627495&r1=1627494&r2=1627495&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java
Thu Sep 25 09:41:18 2014
@@ -34,7 +34,10 @@ import org.apache.xml.security.utils.Bas
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.CallbackHandler;
+import javax.xml.parsers.DocumentBuilderFactory;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 
@@ -91,6 +94,60 @@ public class CryptoProviderTest extends 
     }
     
     /**
+     * Like before but substitute in an "EMAILADDRESS" instead of the OID
+     * @throws Exception
+     */
+    @org.junit.Test
+    public void testSignatureEmailAddress() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecSignature sign = new WSSecSignature();
+        sign.setUserInfo("wss86", "security");
+        sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = sign.build(doc, crypto, secHeader);
+        
+        String outputString = XMLUtils.PrettyDocumentToString(signedDoc);
+        outputString = 
+            outputString.replace("1.2.840.113549.1.9.1=#16125765726e6572406578616d706c652e636f6d",
+                             "EMAILADDRESS=Werner@example.com");
+        
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        InputStream is = new ByteArrayInputStream(outputString.getBytes());
+        Document parsedDoc = dbf.newDocumentBuilder().parse(is);
+        verify(parsedDoc);
+    }
+    
+    /**
+     * Like before but substitute in an "E" instead of the OID
+     * @throws Exception
+     */
+    @org.junit.Test
+    public void testSignatureOtherEmailAddress() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecSignature sign = new WSSecSignature();
+        sign.setUserInfo("wss86", "security");
+        sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = sign.build(doc, crypto, secHeader);
+        
+        String outputString = XMLUtils.PrettyDocumentToString(signedDoc);
+        outputString = 
+            outputString.replace("1.2.840.113549.1.9.1=#16125765726e6572406578616d706c652e636f6d",
+                             "E=Werner@example.com");
+        
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        InputStream is = new ByteArrayInputStream(outputString.getBytes());
+        Document parsedDoc = dbf.newDocumentBuilder().parse(is);
+        verify(parsedDoc);
+    }
+    
+    /**
      * Test loading a certificate using BouncyCastle, and using it to encrypt a message,
but
      * decrypt the message using the Java Keystore provider
      */



Mime
View raw message