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/12/19 12:11:55 UTC

svn commit: r1720895 [27/34] - in /webservices/wss4j/branches/2_1_x-fixes: bindings/src/main/java/org/apache/wss4j/binding/wss10/ bindings/src/main/java/org/apache/wss4j/binding/wss11/ bindings/src/main/java/org/apache/wss4j/binding/wssc13/ bindings/sr...

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java Sat Dec 19 11:11:50 2015
@@ -58,7 +58,7 @@ import javax.security.auth.callback.Call
  * Some tests for how SAML tokens are referenced.
  */
 public class SamlReferenceTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SamlReferenceTest.class);
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private CallbackHandler callbackHandler = new KeystoreCallbackHandler();
@@ -66,16 +66,16 @@ public class SamlReferenceTest extends o
     private Crypto trustCrypto = null;
     private Crypto issuerCrypto = null;
     private Crypto userCrypto = CryptoFactory.getInstance("wss40.properties");
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public SamlReferenceTest() throws Exception {
         WSSConfig config = WSSConfig.getNewInstance();
         secEngine.setWssConfig(config);
-        
+
         // Load the issuer keystore
         issuerCrypto = new Merlin();
         KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
@@ -83,7 +83,7 @@ public class SamlReferenceTest extends o
         InputStream input = Merlin.loadInputStream(loader, "keys/wss40_server.jks");
         keyStore.load(input, "security".toCharArray());
         ((Merlin)issuerCrypto).setKeyStore(keyStore);
-        
+
         // Load the server truststore
         trustCrypto = new Merlin();
         KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
@@ -91,7 +91,7 @@ public class SamlReferenceTest extends o
         trustStore.load(input, "security".toCharArray());
         ((Merlin)trustCrypto).setTrustStore(trustStore);
     }
-    
+
     /**
      * Test that creates, sends and processes an signed SAML 1.1 sender-vouches assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a KeyIdentifier,
@@ -104,24 +104,24 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
                 "security", secHeader
             );
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(signedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML message Key Identifier (sender vouches):");
@@ -129,14 +129,14 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, crypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_UNSIGNED).get(0);
         SamlAssertionWrapper receivedSamlAssertion =
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
-        
+
         // Test we processed a signature (SAML assertion + SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -144,16 +144,16 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 2);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
-        
+
         wsDataRef = refs.get(1);
         xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/saml1:Assertion", xpath);
     }
-    
+
     /**
      * Test that creates, sends and processes an signed SAML 1.1 sender-vouches assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a direct reference,
@@ -167,25 +167,25 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         wsSign.setUseDirectReferenceToAssertion(true);
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
                 "security", secHeader
             );
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML message Direct Reference (sender vouches):");
@@ -193,14 +193,14 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, crypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_UNSIGNED).get(0);
         SamlAssertionWrapper receivedSamlAssertion =
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
-        
+
         // Test we processed a signature (SAML assertion + SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -208,16 +208,16 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 2);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
-        
+
         wsDataRef = refs.get(1);
         xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/saml1:Assertion", xpath);
     }
-    
+
     /**
      * Test that creates, sends and processes an signed SAML 1.1 holder-of-key assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a KeyIdentifier,
@@ -231,11 +231,11 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
@@ -247,10 +247,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML message Key Identifier (holder-of-key):");
@@ -258,7 +258,7 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, trustCrypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -266,7 +266,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed a signature (SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -274,17 +274,17 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
     }
-    
+
     /**
      * Test that creates, sends and processes an signed SAML 1.1 holder-of-key assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a direct reference,
      * and not a KeyIdentifier. This method is not spec compliant and is included to make sure
-     * we can process third-party Assertions referenced in this way. This tests that we can 
+     * we can process third-party Assertions referenced in this way. This tests that we can
      * process a Direct Reference to a SAML Assertion in the KeyInfo of a Signature.
      */
     @org.junit.Test
@@ -294,11 +294,11 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
@@ -312,10 +312,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML message Direct Reference (holder-of-key):");
@@ -323,7 +323,7 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, trustCrypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -331,7 +331,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed a signature (SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -339,7 +339,7 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
@@ -348,10 +348,10 @@ public class SamlReferenceTest extends o
     /**
      * WS-Security Test Case for WSS-178 - "signature verification failure of signed saml token
      * due to "The Reference for URI (bst-saml-uri) has no XMLSignatureInput".
-     * 
-     * The problem is that the signature is referring to a SecurityTokenReference via the 
-     * STRTransform, which in turn is referring to the SAML Assertion. The request is putting 
-     * the SAML Assertion below the SecurityTokenReference, and this is causing 
+     *
+     * The problem is that the signature is referring to a SecurityTokenReference via the
+     * STRTransform, which in turn is referring to the SAML Assertion. The request is putting
+     * the SAML Assertion below the SecurityTokenReference, and this is causing
      * SecurityTokenReference.getTokenElement to fail.
      */
     @org.junit.Test
@@ -359,39 +359,39 @@ public class SamlReferenceTest extends o
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.ATTR);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
-        
+
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
         Crypto crypto = CryptoFactory.getInstance("crypto.properties");
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        Document samlDoc = 
+        Document samlDoc =
             wsSign.build(doc, null, samlAssertion, crypto,
                 "16c73ab6-b892-458f-abf5-2f875f74882e", "security", secHeader
             );
-        
+
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Document encryptedDoc = builder.build(samlDoc, crypto, secHeader);
-        
+
         //
         // Remove the assertion its place in the security header and then append it
         //
         Element secHeaderElement = secHeader.getSecurityHeader();
-        Node assertionNode = 
+        Node assertionNode =
             secHeaderElement.getElementsByTagNameNS(WSConstants.SAML_NS, "Assertion").item(0);
         secHeaderElement.removeChild(assertionNode);
         secHeaderElement.appendChild(assertionNode);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message:");
@@ -399,11 +399,11 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML_TOKEN_TYPE));
-        
+
         verify(encryptedDoc, crypto, crypto);
     }
-    
-    
+
+
     /**
      * The body of the SOAP request is encrypted using a secret key, which is in turn encrypted
      * using the certificate embedded in the SAML assertion and referenced using a Key Identifier.
@@ -418,11 +418,11 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
@@ -430,7 +430,7 @@ public class SamlReferenceTest extends o
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
         secHeader.getSecurityHeader().appendChild(assertionNode);
-        
+
         // Encrypt the SOAP body
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
@@ -439,8 +439,8 @@ public class SamlReferenceTest extends o
         builder.setCustomEKTokenValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
         builder.setCustomEKTokenId(samlAssertion.getId());
         builder.prepare(doc, userCrypto);
-        
-        WSEncryptionPart encP = 
+
+        WSEncryptionPart encP =
             new WSEncryptionPart(
                 "add", "http://ws.apache.org/counter/counter_port_type", "Element"
             );
@@ -449,7 +449,7 @@ public class SamlReferenceTest extends o
         builder.addInternalRefElement(refElement);
         builder.appendToHeader(secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted SAML 1.1 message Key Identifier (holder-of-key):");
@@ -457,7 +457,7 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(doc, trustCrypto, userCrypto);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -465,7 +465,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed an encrypted element
         actionResult = results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
@@ -473,17 +473,17 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body/add", xpath);
-        
+
     }
-    
+
     /**
      * The body of the SOAP request is encrypted using a secret key, which is in turn encrypted
      * using the certificate embedded in the SAML assertion and referenced using Direct
-     * Reference. This method is not spec compliant and is included to make sure we can process 
+     * Reference. This method is not spec compliant and is included to make sure we can process
      * third-party Assertions referenced in this way. This tests that we can process a Direct
      * Reference to a SAML Assertion in the KeyInfo of an EncryptedKey.
      */
@@ -495,18 +495,18 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
         secHeader.getSecurityHeader().appendChild(assertionNode);
-        
+
         // Encrypt the SOAP body
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
@@ -515,8 +515,8 @@ public class SamlReferenceTest extends o
         builder.setCustomEKTokenValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
         builder.setCustomEKTokenId(samlAssertion.getId());
         builder.prepare(doc, userCrypto);
-        
-        WSEncryptionPart encP = 
+
+        WSEncryptionPart encP =
             new WSEncryptionPart(
                 "add", "http://ws.apache.org/counter/counter_port_type", "Element"
             );
@@ -525,7 +525,7 @@ public class SamlReferenceTest extends o
         builder.addInternalRefElement(refElement);
         builder.appendToHeader(secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted SAML 1.1 message Direct Reference (holder-of-key):");
@@ -533,7 +533,7 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(doc, trustCrypto, userCrypto);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -541,7 +541,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed an encrypted element
         actionResult = results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
@@ -549,12 +549,12 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body/add", xpath);
     }
-    
+
     /**
      * Test that creates, sends and processes an signed SAML 2 sender-vouches assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a KeyIdentifier,
@@ -567,24 +567,24 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
                 "security", secHeader
             );
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(signedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML2 message Key Identifier (sender vouches):");
@@ -592,14 +592,14 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, crypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_UNSIGNED).get(0);
         SamlAssertionWrapper receivedSamlAssertion =
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
-        
+
         // Test we processed a signature (SAML assertion + SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -607,16 +607,16 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 2);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
-        
+
         wsDataRef = refs.get(1);
         xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/saml2:Assertion", xpath);
     }
-    
+
     /**
      * Test that creates, sends and processes an signed SAML 2 sender-vouches assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a direct reference,
@@ -629,25 +629,25 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         wsSign.setUseDirectReferenceToAssertion(true);
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
                 "security", secHeader
             );
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML2 message Direct Reference (sender vouches):");
@@ -655,14 +655,14 @@ public class SamlReferenceTest extends o
         }
         assertFalse(outputString.contains(WSConstants.WSS_SAML2_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, crypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_UNSIGNED).get(0);
         SamlAssertionWrapper receivedSamlAssertion =
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
-        
+
         // Test we processed a signature (SAML assertion + SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -670,16 +670,16 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 2);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
-        
+
         wsDataRef = refs.get(1);
         xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/saml2:Assertion", xpath);
     }
-    
+
     /**
      * Test that creates, sends and processes an signed SAML 2 holder-of-key assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a KeyIdentifier,
@@ -693,11 +693,11 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
@@ -709,10 +709,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML2 message Key Identifier (holder-of-key):");
@@ -720,7 +720,7 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, trustCrypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -728,7 +728,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed a signature (SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -736,13 +736,13 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
     }
-    
-    
+
+
     /**
      * Test that creates, sends and processes an signed SAML 2 holder-of-key assertion,
      * where the SecurityTokenReference that points to the SAML Assertion uses a direct reference,
@@ -756,11 +756,11 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
@@ -774,10 +774,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        Document signedDoc = 
+        Document signedDoc =
             wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed SAML2 message Direct Reference (holder-of-key):");
@@ -785,7 +785,7 @@ public class SamlReferenceTest extends o
         }
         assertFalse(outputString.contains(WSConstants.WSS_SAML2_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(signedDoc, trustCrypto, null);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -793,7 +793,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed a signature (SOAP body)
         actionResult =  results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -801,12 +801,12 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
     }
-    
+
     /**
      * The body of the SOAP request is encrypted using a secret key, which is in turn encrypted
      * using the certificate embedded in the SAML assertion and referenced using a Key Identifier.
@@ -821,11 +821,11 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
@@ -833,7 +833,7 @@ public class SamlReferenceTest extends o
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
         secHeader.getSecurityHeader().appendChild(assertionNode);
-        
+
         // Encrypt the SOAP body
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
@@ -842,8 +842,8 @@ public class SamlReferenceTest extends o
         builder.setCustomEKTokenValueType(WSConstants.WSS_SAML2_KI_VALUE_TYPE);
         builder.setCustomEKTokenId(samlAssertion.getId());
         builder.prepare(doc, userCrypto);
-        
-        WSEncryptionPart encP = 
+
+        WSEncryptionPart encP =
             new WSEncryptionPart(
                 "add", "http://ws.apache.org/counter/counter_port_type", "Element"
             );
@@ -852,7 +852,7 @@ public class SamlReferenceTest extends o
         builder.addInternalRefElement(refElement);
         builder.appendToHeader(secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted SAML 2 message Key Identifier (holder-of-key):");
@@ -860,7 +860,7 @@ public class SamlReferenceTest extends o
         }
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(doc, trustCrypto, userCrypto);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -868,7 +868,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed an encrypted element
         actionResult =  results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
@@ -876,13 +876,13 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body/add", xpath);
-        
+
     }
-    
+
     /**
      * The body of the SOAP request is encrypted using a secret key, which is in turn encrypted
      * using the certificate embedded in the SAML assertion and referenced using Direct
@@ -897,11 +897,11 @@ public class SamlReferenceTest extends o
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
@@ -909,7 +909,7 @@ public class SamlReferenceTest extends o
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
         secHeader.getSecurityHeader().appendChild(assertionNode);
-        
+
         // Encrypt the SOAP body
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
@@ -918,8 +918,8 @@ public class SamlReferenceTest extends o
         builder.setCustomEKTokenValueType(WSConstants.WSS_SAML2_KI_VALUE_TYPE);
         builder.setCustomEKTokenId(samlAssertion.getId());
         builder.prepare(doc, userCrypto);
-        
-        WSEncryptionPart encP = 
+
+        WSEncryptionPart encP =
             new WSEncryptionPart(
                 "add", "http://ws.apache.org/counter/counter_port_type", "Element"
             );
@@ -928,7 +928,7 @@ public class SamlReferenceTest extends o
         builder.addInternalRefElement(refElement);
         builder.appendToHeader(secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted SAML 2 message Direct Reference (holder-of-key):");
@@ -936,7 +936,7 @@ public class SamlReferenceTest extends o
         }
         assertFalse(outputString.contains(WSConstants.WSS_SAML2_KI_VALUE_TYPE));
         assertTrue(outputString.contains(WSConstants.WSS_SAML2_TOKEN_TYPE));
-        
+
         WSHandlerResult results = verify(doc, trustCrypto, userCrypto);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -944,7 +944,7 @@ public class SamlReferenceTest extends o
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
-        
+
         // Test we processed an encrypted element
         actionResult =  results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
@@ -952,17 +952,17 @@ public class SamlReferenceTest extends o
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 1);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body/add", xpath);
-        
+
     }
-    
-    
+
+
     /**
      * Verifies the soap envelope
-     * 
+     *
      * @param doc
      * @throws Exception Thrown when there is a problem in verification
      */
@@ -974,13 +974,13 @@ public class SamlReferenceTest extends o
         requestData.setDecCrypto(decCrypto);
         requestData.setSigVerCrypto(verifyCrypto);
         requestData.setValidateSamlSubjectConfirmation(false);
-        
+
         WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
         return results;
     }
-    
+
 }

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenActionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenActionTest.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenActionTest.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenActionTest.java Sat Dec 19 11:11:50 2015
@@ -48,11 +48,11 @@ import org.apache.wss4j.dom.handler.WSHa
  * Test-case for sending SAML Assertions using the "action" approach.
  */
 public class SamlTokenActionTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SamlTokenActionTest.class);
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
@@ -65,32 +65,32 @@ public class SamlTokenActionTest extends
         config.setValidator(WSConstants.SAML2_TOKEN, new CustomSamlAssertionValidator());
         secEngine.setWssConfig(config);
     }
-    
+
     @org.junit.Test
     public void testAssertionAction() throws Exception {
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
         reqData.setUsername("wss40");
-        
+
         CallbackHandler callbackHandler = new KeystoreCallbackHandler();
-        
+
         SAML1CallbackHandler samlCallbackHandler = new SAML1CallbackHandler();
         samlCallbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         samlCallbackHandler.setIssuer("www.example.com");
-        
+
         java.util.Map<String, Object> config = new java.util.TreeMap<String, Object>();
         config.put(WSHandlerConstants.SIG_PROP_FILE, "wss40.properties");
         config.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
         config.put(WSHandlerConstants.SAML_CALLBACK_REF, samlCallbackHandler);
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         HandlerAction action = new HandlerAction(WSConstants.ST_UNSIGNED);
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(action),
             true
         );
@@ -98,36 +98,36 @@ public class SamlTokenActionTest extends
             String outputString = XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         verify(doc, callbackHandler);
     }
-    
+
     @org.junit.Test
     public void testSignedAssertionAction() throws Exception {
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
-        
+
         CallbackHandler callbackHandler = new KeystoreCallbackHandler();
-        
+
         SAML1CallbackHandler samlCallbackHandler = new SAML1CallbackHandler();
         samlCallbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         samlCallbackHandler.setIssuer("www.example.com");
         samlCallbackHandler.setIssuerCrypto(crypto);
         samlCallbackHandler.setIssuerName("wss40");
         samlCallbackHandler.setIssuerPassword("security");
-        
+
         java.util.Map<String, Object> config = new java.util.TreeMap<String, Object>();
         config.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
         config.put(WSHandlerConstants.SAML_CALLBACK_REF, samlCallbackHandler);
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         HandlerAction action = new HandlerAction(WSConstants.ST_SIGNED);
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(action),
             true
         );
@@ -135,38 +135,38 @@ public class SamlTokenActionTest extends
             String outputString = XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         verify(doc, callbackHandler);
     }
-    
+
     @org.junit.Test
     public void testAssertionWithSignatureAction() throws Exception {
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
         reqData.setUsername("wss40");
-        
+
         CallbackHandler callbackHandler = new KeystoreCallbackHandler();
-        
+
         SAML1CallbackHandler samlCallbackHandler = new SAML1CallbackHandler();
         samlCallbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         samlCallbackHandler.setIssuer("www.example.com");
-        
+
         java.util.Map<String, Object> config = new java.util.TreeMap<String, Object>();
         config.put(WSHandlerConstants.SIG_PROP_FILE, "wss40.properties");
         config.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
         config.put(WSHandlerConstants.SAML_CALLBACK_REF, samlCallbackHandler);
         config.put(WSHandlerConstants.SIGNATURE_PARTS, "{}{" + WSConstants.SAML_NS + "}Assertion;");
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         List<HandlerAction> actions = new ArrayList<>();
         actions.add(new HandlerAction(WSConstants.ST_UNSIGNED));
         actions.add(new HandlerAction(WSConstants.SIGN));
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             actions,
             true
         );
@@ -174,10 +174,10 @@ public class SamlTokenActionTest extends
             String outputString = XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         verify(doc, callbackHandler);
     }
-    
+
     private WSHandlerResult verify(
         Document doc, CallbackHandler callbackHandler
     ) throws Exception {
@@ -186,12 +186,12 @@ public class SamlTokenActionTest extends
         requestData.setDecCrypto(crypto);
         requestData.setSigVerCrypto(crypto);
         requestData.setValidateSamlSubjectConfirmation(false);
-        
+
         WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
         return results;
     }
-    
+
 }

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java Sat Dec 19 11:11:50 2015
@@ -60,16 +60,16 @@ import org.w3c.dom.Element;
 /**
  */
 public class SamlTokenCustomSignatureTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SamlTokenCustomSignatureTest.class);
-    
+
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public SamlTokenCustomSignatureTest() throws Exception {
         WSSConfig.init();
         crypto = CryptoFactory.getInstance("crypto.properties");
@@ -84,38 +84,38 @@ public class SamlTokenCustomSignatureTes
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_BEARER);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         Element assertionElement = samlAssertion.toDOM(doc);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
         secHeader.getSecurityHeader().appendChild(assertionElement);
-        
+
         // Sign
         signAssertion(doc, assertionElement);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1.1 Authn Assertion (Bearer):");
             String outputString = XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(doc);
             fail("Failure expected on a signature that doesn't conform with the signature profile");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE);
         }
-        
+
         // This should pass as we are disabling signature profile validation in the Validator
         verifyWithoutProfile(doc);
     }
-    
+
     /**
      * Test that creates, sends and processes a signed SAML 2.0 authentication assertion.
      */
@@ -125,56 +125,56 @@ public class SamlTokenCustomSignatureTes
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         Element assertionElement = samlAssertion.toDOM(doc);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
         secHeader.getSecurityHeader().appendChild(assertionElement);
-        
+
         // Sign
         signAssertion(doc, assertionElement);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 2.0 Authn Assertion (Bearer):");
             String outputString = XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(doc);
             fail("Failure expected on a signature that doesn't conform with the signature profile");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE);
         }
-        
+
         // This should pass as we are disabling signature profile validation in the Validator
         verifyWithoutProfile(doc);
     }
-    
+
     @org.junit.Test
     public void testAddSAML1AndSign() throws Exception {
         SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         Element assertionElement = samlAssertion.toDOM(doc);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
         secHeader.getSecurityHeader().appendChild(assertionElement);
-        
+
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
@@ -186,67 +186,67 @@ public class SamlTokenCustomSignatureTes
                 "Element");
         encP.setRequired(false);
         sign.getParts().add(encP);
-        
+
         Document signedDoc = sign.build(doc, crypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
             String outputString = XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
-    
+
     @org.junit.Test
     public void testAddSAML1AndSignAction() throws Exception {
         SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
         reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
-        
+
         java.util.Map<String, Object> config = new java.util.TreeMap<String, Object>();
         config.put(WSHandlerConstants.SIG_PROP_FILE, "crypto.properties");
         config.put("password", "security");
         config.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
         config.put(
-            WSHandlerConstants.SIGNATURE_PARTS, 
+            WSHandlerConstants.SIGNATURE_PARTS,
             "{Element}{urn:oasis:names:tc:SAML:1.0:assertion}Assertion"
         );
         config.put(WSHandlerConstants.SAML_CALLBACK_REF, callbackHandler);
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
-        
+
         List<HandlerAction> actions = new ArrayList<>();
         HandlerAction action = new HandlerAction(WSConstants.ST_UNSIGNED);
         actions.add(action);
         action = new HandlerAction(WSConstants.SIGN);
         actions.add(action);
-        
+
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             actions,
             true
         );
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message:");
             LOG.debug(outputString);
         }
-        
+
         verify(doc);
     }
-    
+
     private void signAssertion(Document doc, Element assertionElement) throws Exception {
-        XMLSignature sig = 
+        XMLSignature sig =
             new XMLSignature(doc, null, XMLSignature.ALGO_ID_SIGNATURE_RSA);
         assertionElement.appendChild(sig.getElement());
 
@@ -254,7 +254,7 @@ public class SamlTokenCustomSignatureTes
         String filter = "here()/ancestor::ds.Signature/parent::node()/descendant-or-self::*";
         XPath2FilterContainer xpathC = XPath2FilterContainer.newInstanceIntersect(doc, filter);
         xpathC.setXPathNamespaceContext("dsig-xpath", Transforms.TRANSFORM_XPATH2FILTER);
-        
+
         Element node = xpathC.getElement();
         transforms.addTransform(Transforms.TRANSFORM_XPATH2FILTER, node);
         sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1);
@@ -262,17 +262,17 @@ public class SamlTokenCustomSignatureTes
         PrivateKey privateKey = crypto.getPrivateKey("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
 
         sig.sign(privateKey);
-        
+
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
         cryptoType.setAlias("16c73ab6-b892-458f-abf5-2f875f74882e");
         X509Certificate cert = crypto.getX509Certificates(cryptoType)[0];
         sig.addKeyInfo(cert);
         sig.checkSignatureValue(cert);
     }
-    
+
     /**
      * Verifies the soap envelope
-     * 
+     *
      * @param doc
      * @throws Exception Thrown when there is a problem in verification
      */
@@ -282,7 +282,7 @@ public class SamlTokenCustomSignatureTes
         requestData.setDecCrypto(crypto);
         requestData.setSigVerCrypto(crypto);
         requestData.setValidateSamlSubjectConfirmation(false);
-        
+
         WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
         String outputString = XMLUtils.PrettyDocumentToString(doc);
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
@@ -292,13 +292,13 @@ public class SamlTokenCustomSignatureTes
     private WSHandlerResult verifyWithoutProfile(Document doc) throws Exception {
         SamlAssertionValidator validator = new SamlAssertionValidator();
         validator.setValidateSignatureAgainstProfile(false);
-        
+
         WSSecurityEngine secEngine = new WSSecurityEngine();
         WSSConfig config = secEngine.getWssConfig();
         config.setValidator(WSConstants.SAML_TOKEN, validator);
         config.setValidator(WSConstants.SAML2_TOKEN, validator);
-        
-        WSHandlerResult results = 
+
+        WSHandlerResult results =
             secEngine.processSecurityHeader(
                 doc, null, null, crypto
             );

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java Sat Dec 19 11:11:50 2015
@@ -52,27 +52,27 @@ import org.apache.wss4j.dom.util.WSSecur
 import org.w3c.dom.Document;
 
 /**
- * Test-case for sending and processing a signed (sender vouches) SAML Assertion using a 
+ * Test-case for sending and processing a signed (sender vouches) SAML Assertion using a
  * derived key.
  */
 public class SamlTokenDerivedTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SamlTokenDerivedTest.class);
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private CallbackHandler callbackHandler = new KeystoreCallbackHandler();
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public SamlTokenDerivedTest() throws Exception {
         WSSConfig config = WSSConfig.getNewInstance();
         secEngine.setWssConfig(config);
         crypto = CryptoFactory.getInstance("crypto.properties");
     }
-    
+
     /**
      * Test that creates, sends and processes a signed SAML 1.1 authentication assertion
      * using a derived key.
@@ -87,20 +87,20 @@ public class SamlTokenDerivedTest extend
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_SENDER_VOUCHES);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        SecurityTokenReference secRefSaml = 
+
+        SecurityTokenReference secRefSaml =
             createSamlSTR(doc, samlAssertion, WSSConfig.getNewInstance());
         secHeader.getSecurityHeader().appendChild(samlAssertion.toDOM(doc));
         secHeader.getSecurityHeader().appendChild(secRefSaml.getElement());
-        
+
         //
         // Create a Derived Key object for signature
         //
@@ -109,11 +109,11 @@ public class SamlTokenDerivedTest extend
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1.1 Authn Assertion Derived (sender vouches):");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         // Test we processed a SAML assertion
         WSHandlerResult results = verify(signedDoc);
         WSSecurityEngineResult actionResult =
@@ -121,7 +121,7 @@ public class SamlTokenDerivedTest extend
         SamlAssertionWrapper receivedSamlAssertion =
             (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
         assertTrue(receivedSamlAssertion != null);
-        
+
         // Test we processed a signature (SAML assertion + SOAP body)
         actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
         assertTrue(actionResult != null);
@@ -129,21 +129,21 @@ public class SamlTokenDerivedTest extend
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs.size() == 2);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Body", xpath);
-        
+
         wsDataRef = refs.get(1);
         xpath = wsDataRef.getXpath();
         assertEquals("/SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/saml1:Assertion", xpath);
     }
-    
+
     /**
      * Create a SecurityTokenReference to a SAML Assertion
      */
     private SecurityTokenReference createSamlSTR(
-        Document doc, 
+        Document doc,
         SamlAssertionWrapper samlAssertion,
         WSSConfig wssConfig
     ) {
@@ -151,16 +151,16 @@ public class SamlTokenDerivedTest extend
         String secRefID = wssConfig.getIdAllocator().createSecureId("STRSAMLId-", secRefSaml);
         secRefSaml.setID(secRefID);
 
-        org.apache.wss4j.common.token.Reference ref = 
+        org.apache.wss4j.common.token.Reference ref =
             new org.apache.wss4j.common.token.Reference(doc);
         ref.setURI("#" + samlAssertion.getId());
         ref.setValueType(WSConstants.WSS_SAML_KI_VALUE_TYPE);
         secRefSaml.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
         secRefSaml.setReference(ref);
-        
+
         return secRefSaml;
     }
-    
+
     /**
      * Create a WSSecDKSign object, that signs the SOAP Body as well as the SAML Assertion
      * via a STR Transform.
@@ -174,17 +174,17 @@ public class SamlTokenDerivedTest extend
         cryptoType.setAlias("16c73ab6-b892-458f-abf5-2f875f74882e");
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         secToken.setKeyIdentifierThumb(certs[0]);
-        
+
         WSSecDKSign sigBuilder = new WSSecDKSign();
-        java.security.Key key = 
+        java.security.Key key =
             crypto.getPrivateKey("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());
         sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
         String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
-        WSEncryptionPart encP = 
+        WSEncryptionPart encP =
             new WSEncryptionPart(
                 WSConstants.ELEM_BODY,
-                soapNamespace, 
+                soapNamespace,
                 "Content"
             );
         sigBuilder.getParts().add(encP);
@@ -192,15 +192,15 @@ public class SamlTokenDerivedTest extend
         encP.setId(secRefSaml.getID());
         encP.setElement(secRefSaml.getElement());
         sigBuilder.getParts().add(encP);
-        
+
         return sigBuilder;
     }
-   
+
     /**
      * Verifies the soap envelope
      * <p/>
-     * 
-     * @param envelope 
+     *
+     * @param envelope
      * @throws Exception Thrown when there is a problem in verification
      */
     private WSHandlerResult verify(Document doc) throws Exception {
@@ -209,10 +209,10 @@ public class SamlTokenDerivedTest extend
         requestData.setDecCrypto(crypto);
         requestData.setSigVerCrypto(crypto);
         requestData.setValidateSamlSubjectConfirmation(false);
-        
+
         WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
         return results;

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenHOKTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenHOKTest.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenHOKTest.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenHOKTest.java Sat Dec 19 11:11:50 2015
@@ -44,24 +44,24 @@ import org.w3c.dom.Document;
 
 /**
  * Test-case for sending and processing a signed (holder-of-key) SAML Assertion. These tests
- * just cover the case of creating and signing the Assertion, and not using the credential 
+ * just cover the case of creating and signing the Assertion, and not using the credential
  * information in the SAML Subject to sign the SOAP body.
  */
 public class SamlTokenHOKTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SamlTokenHOKTest.class);
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public SamlTokenHOKTest() throws Exception {
         WSSConfig config = WSSConfig.getNewInstance();
         secEngine.setWssConfig(config);
-        
+
         crypto = CryptoFactory.getInstance("crypto.properties");
     }
 
@@ -74,11 +74,11 @@ public class SamlTokenHOKTest extends or
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false);
 
         WSSecSAMLToken wsSign = new WSSecSAMLToken();
@@ -86,16 +86,16 @@ public class SamlTokenHOKTest extends or
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1.1 Authn Assertion (holder-of-key):");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         WSHandlerResult results = verify(signedDoc);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -105,7 +105,7 @@ public class SamlTokenHOKTest extends or
         assertTrue(receivedSamlAssertion.isSigned());
         assertNotNull(receivedSamlAssertion.assertionToString());
     }
-    
+
     /**
      * Test that creates, sends and processes a signed SAML 1.1 attribute assertion.
      */
@@ -115,11 +115,11 @@ public class SamlTokenHOKTest extends or
         callbackHandler.setStatement(SAML1CallbackHandler.Statement.ATTR);
         callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false);
 
         WSSecSAMLToken wsSign = new WSSecSAMLToken();
@@ -127,28 +127,28 @@ public class SamlTokenHOKTest extends or
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1.1 Attr Assertion (holder-of-key):");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         RequestData requestData = new RequestData();
         requestData.setValidateSamlSubjectConfirmation(false);
         requestData.setCallbackHandler(new KeystoreCallbackHandler());
         Crypto decCrypto = CryptoFactory.getInstance("wss40.properties");
         requestData.setDecCrypto(decCrypto);
         requestData.setSigVerCrypto(crypto);
-        
+
         WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
-        
+
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
         SamlAssertionWrapper receivedSamlAssertion =
@@ -156,7 +156,7 @@ public class SamlTokenHOKTest extends or
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
     }
-    
+
     /**
      * Test that creates, sends and processes an unsigned SAML 2 authentication assertion.
      */
@@ -166,11 +166,11 @@ public class SamlTokenHOKTest extends or
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false);
 
         WSSecSAMLToken wsSign = new WSSecSAMLToken();
@@ -178,16 +178,16 @@ public class SamlTokenHOKTest extends or
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 2 Authn Assertion (holder-of-key):");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(unsignedDoc);
             LOG.debug(outputString);
         }
-        
+
         WSHandlerResult results = verify(unsignedDoc);
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
@@ -196,7 +196,7 @@ public class SamlTokenHOKTest extends or
         assertTrue(receivedSamlAssertion != null);
         assertTrue(receivedSamlAssertion.isSigned());
     }
-    
+
     /**
      * Test that creates, sends and processes an unsigned SAML 2 attribute assertion.
      */
@@ -206,11 +206,11 @@ public class SamlTokenHOKTest extends or
         callbackHandler.setStatement(SAML2CallbackHandler.Statement.ATTR);
         callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
         callbackHandler.setIssuer("www.example.com");
-        
+
         SAMLCallback samlCallback = new SAMLCallback();
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-        
+
         samlAssertion.signAssertion("16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false);
 
 
@@ -219,16 +219,16 @@ public class SamlTokenHOKTest extends or
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 2 Attr Assertion (holder-of-key):");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(unsignedDoc);
             LOG.debug(outputString);
         }
-        
+
         RequestData requestData = new RequestData();
         requestData.setValidateSamlSubjectConfirmation(false);
         requestData.setCallbackHandler(new KeystoreCallbackHandler());
@@ -236,11 +236,11 @@ public class SamlTokenHOKTest extends or
         requestData.setDecCrypto(decCrypto);
         requestData.setSigVerCrypto(crypto);
         WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
-        
+
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ST_SIGNED).get(0);
         SamlAssertionWrapper receivedSamlAssertion =
@@ -251,8 +251,8 @@ public class SamlTokenHOKTest extends or
     /**
      * Verifies the soap envelope
      * <p/>
-     * 
-     * @param envelope 
+     *
+     * @param envelope
      * @throws Exception Thrown when there is a problem in verification
      */
     private WSHandlerResult verify(Document doc) throws Exception {
@@ -260,10 +260,10 @@ public class SamlTokenHOKTest extends or
         requestData.setDecCrypto(crypto);
         requestData.setSigVerCrypto(crypto);
         requestData.setValidateSamlSubjectConfirmation(false);
-        
+
         WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
         return results;