ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1675876 - in /webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom: common/SAML2CallbackHandler.java saml/SamlTokenTest.java
Date Fri, 24 Apr 2015 14:56:34 GMT
Author: coheigea
Date: Fri Apr 24 14:56:33 2015
New Revision: 1675876

URL: http://svn.apache.org/r1675876
Log:
Add a special character test for SAML

Modified:
    webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML2CallbackHandler.java
    webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java

Modified: webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML2CallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML2CallbackHandler.java?rev=1675876&r1=1675875&r2=1675876&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML2CallbackHandler.java
(original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML2CallbackHandler.java
Fri Apr 24 14:56:33 2015
@@ -96,4 +96,8 @@ public class SAML2CallbackHandler extend
         }
     }
     
+    public void setSubjectName(String newSubjectName) {
+        this.subjectName = newSubjectName;
+    }
+    
 }

Modified: webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java?rev=1675876&r1=1675875&r2=1675876&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
(original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
Fri Apr 24 14:56:33 2015
@@ -1028,6 +1028,51 @@ public class SamlTokenTest extends org.j
         assertFalse(receivedSamlAssertion.isSigned());
     }
     
+    @org.junit.Test
+    public void testSAML2SpecialCharacter() throws Exception {
+        SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
+        callbackHandler.setStatement(SAML2CallbackHandler.Statement.ATTR);
+        callbackHandler.setIssuer("www.example.com");
+        // Test an "umlaut"
+        String newSubjectName = "uid=j\u00f6e,ou=people,ou=saml-demo,o=example.com";
+        callbackHandler.setSubjectName(newSubjectName);
+        List<Object> customAttributeValue = new ArrayList<>(1);
+        customAttributeValue.add("j\u00f6an");
+        callbackHandler.setCustomAttributeValues(customAttributeValue);
+
+        SAMLCallback samlCallback = new SAMLCallback();
+        SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
+        SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
+
+        WSSecSAMLToken wsSign = new WSSecSAMLToken();
+
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+
+        String outputString = XMLUtils.PrettyDocumentToString(unsignedDoc);
+        assertTrue(outputString.contains("j\u00f6e") && outputString.contains("j\u00f6an"));
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(outputString);
+        }
+
+        RequestData requestData = new RequestData();
+        requestData.setValidateSamlSubjectConfirmation(false);
+        
+        WSSecurityEngine newEngine = new WSSecurityEngine();
+        WSHandlerResult results = newEngine.processSecurityHeader(doc, requestData);
+        
+        WSSecurityEngineResult actionResult =
+            results.getActionResults().get(WSConstants.ST_UNSIGNED).get(0);
+        
+        SamlAssertionWrapper receivedSamlAssertion =
+            (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
+        assertTrue(receivedSamlAssertion != null);
+        assertFalse(receivedSamlAssertion.isSigned());
+    }
+    
     private void encryptElement(
         Document document,
         Element elementToEncrypt,



Mime
View raw message