ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1623848 - /webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
Date Tue, 09 Sep 2014 15:33:33 GMT
Author: coheigea
Date: Tue Sep  9 15:33:33 2014
New Revision: 1623848

URL: http://svn.apache.org/r1623848
Log:
Adding a SAML unit test

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java?rev=1623848&r1=1623847&r2=1623848&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
Tue Sep  9 15:33:33 2014
@@ -19,6 +19,8 @@
 
 package org.apache.wss4j.dom.saml;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.security.Key;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
@@ -27,6 +29,7 @@ import java.util.List;
 
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
+import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.crypto.CryptoFactory;
@@ -930,6 +933,30 @@ public class SamlTokenTest extends org.j
         assertTrue(actionResult != null);
     }
     
+    @org.junit.Test
+    public void testAssertionWrapper() throws Exception {
+        SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
+        callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
+        callbackHandler.setIssuer("www.example.com");
+        
+        SAMLCallback samlCallback = new SAMLCallback();
+        SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
+        SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
+        String assertionString = samlAssertion.assertionToString();
+        
+        // Convert String to DOM + into an assertionWrapper
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        
+        InputStream in = new ByteArrayInputStream(assertionString.getBytes());
+        Document newDoc = dbf.newDocumentBuilder().parse(in);
+        
+        SamlAssertionWrapper newAssertion = 
+            new SamlAssertionWrapper(newDoc.getDocumentElement());
+        String secondAssertionString = newAssertion.assertionToString();
+        assertEquals(assertionString, secondAssertionString);
+    }
+    
     private void encryptElement(
         Document document,
         Element elementToEncrypt,



Mime
View raw message