ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1720192 [22/33] - in /webservices/wss4j/trunk: 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/src/main/java/org...
Date Tue, 15 Dec 2015 16:40:42 GMT
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureTest.java Tue Dec 15 16:40:37 2015
@@ -56,18 +56,18 @@ import org.w3c.dom.Node;
  * A set of test-cases for signing and verifying SOAP requests.
  */
 public class SignatureTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SignatureTest.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 SignatureTest() throws Exception {
         WSSConfig.init();
         crypto = CryptoFactory.getInstance();
@@ -76,7 +76,7 @@ public class SignatureTest extends org.j
     /**
      * The test uses the Issuer Serial key identifier type.
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -92,22 +92,22 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with IssuerSerial key identifier:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
         LOG.info("After Signing IS....");
         WSHandlerResult results = verify(signedDoc);
-        
+
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.SIGN).get(0);
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
-        REFERENCE_TYPE referenceType = 
+        REFERENCE_TYPE referenceType =
             (REFERENCE_TYPE)actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
         assertTrue(referenceType == REFERENCE_TYPE.ISSUER_SERIAL);
     }
-    
+
     @org.junit.Test
     public void testX509SignatureISAttached() throws Exception {
         WSSecSignature builder = new WSSecSignature();
@@ -122,27 +122,27 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with IssuerSerial key identifier:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
         LOG.info("After Signing IS....");
         WSHandlerResult results = verify(signedDoc);
-        
+
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.SIGN).get(0);
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
-        REFERENCE_TYPE referenceType = 
+        REFERENCE_TYPE referenceType =
             (REFERENCE_TYPE)actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
         assertTrue(referenceType == REFERENCE_TYPE.ISSUER_SERIAL);
     }
-    
+
 
     /**
      * Test that signs (twice) and verifies a WS-Security envelope.
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -156,11 +156,11 @@ public class SignatureTest extends org.j
         Document signedDoc1 = builder.build(signedDoc, crypto, secHeader);
         verify(signedDoc1);
     }
-    
+
     /**
      * Test that signs and verifies a WS-Security envelope
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -175,18 +175,18 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
-    
+
     /**
      * Test that signs and verifies a WS-Security envelope
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -202,19 +202,19 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
         try {
             newEngine.processSecurityHeader(doc, null, null, crypto);
             fail("Failure expected on a bad c14n algorithm");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         RequestData data = new RequestData();
         data.setSigVerCrypto(crypto);
         List<BSPRule> ignoredRules = new ArrayList<>();
@@ -223,11 +223,11 @@ public class SignatureTest extends org.j
         data.setIgnoredBSPRules(ignoredRules);
         newEngine.processSecurityHeader(doc, data);
     }
-    
+
     /**
      * Test that signs and verifies a WS-Security envelope
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -243,18 +243,18 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
-    
+
     /**
      * Test that signs and verifies a WS-Security envelope
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -270,26 +270,26 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         WSHandlerResult results = verify(signedDoc);
-        
+
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.SIGN).get(0);
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
-        REFERENCE_TYPE referenceType = 
+        REFERENCE_TYPE referenceType =
             (REFERENCE_TYPE)actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
         assertTrue(referenceType == REFERENCE_TYPE.DIRECT_REF);
     }
-    
+
     /**
      * Test that signs and verifies a WS-Security envelope
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -302,24 +302,24 @@ public class SignatureTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Crypto pkiCrypto = CryptoFactory.getInstance("wss40.properties");
         Document signedDoc = builder.build(doc, pkiCrypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After PKI Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         secEngine.processSecurityHeader(doc, null, callbackHandler, pkiCrypto, null);
     }
-    
+
     /**
      * Test that signs and verifies a WS-Security envelope
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -335,29 +335,29 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
-        WSHandlerResult results = 
+        WSHandlerResult results =
             newEngine.processSecurityHeader(doc, null, null, crypto);
 
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.SIGN).get(0);
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
-        REFERENCE_TYPE referenceType = 
+        REFERENCE_TYPE referenceType =
             (REFERENCE_TYPE)actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
         assertTrue(referenceType == REFERENCE_TYPE.KEY_IDENTIFIER);
     }
-    
+
     /**
      * Test that signs and verifies a WS-Security envelope.
-     * The test uses the ThumbprintSHA1 key identifier type. 
+     * The test uses the ThumbprintSHA1 key identifier type.
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -367,7 +367,7 @@ public class SignatureTest extends org.j
         builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
         LOG.info("Before Signing ThumbprintSHA1....");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
@@ -375,19 +375,19 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with ThumbprintSHA1 key identifier:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
         LOG.info("After Signing ThumbprintSHA1....");
-        
+
         WSHandlerResult results = verify(signedDoc);
-        
+
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.SIGN).get(0);
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
-        REFERENCE_TYPE referenceType = 
+        REFERENCE_TYPE referenceType =
             (REFERENCE_TYPE)actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
         assertTrue(referenceType == REFERENCE_TYPE.THUMBPRINT_SHA1);
     }
@@ -400,7 +400,7 @@ public class SignatureTest extends org.j
         builder.setIncludeSignatureToken(true);
         LOG.info("Before Signing ThumbprintSHA1....");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
@@ -408,28 +408,28 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with ThumbprintSHA1 key identifier:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
         LOG.info("After Signing ThumbprintSHA1....");
-        
+
         WSHandlerResult results = verify(signedDoc);
-        
+
         WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.SIGN).get(0);
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
         assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
-        REFERENCE_TYPE referenceType = 
+        REFERENCE_TYPE referenceType =
             (REFERENCE_TYPE)actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
         assertTrue(referenceType == REFERENCE_TYPE.THUMBPRINT_SHA1);
     }
-    
+
     /**
      * Test that signs (twice) and verifies a WS-Security envelope.
      * The test uses the ThumbprintSHA1 key identifier type.
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -438,7 +438,7 @@ public class SignatureTest extends org.j
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
@@ -446,13 +446,13 @@ public class SignatureTest extends org.j
         Document signedDoc1 = builder.build(signedDoc, crypto, secHeader);
         verify(signedDoc1);
     }
-    
-    
+
+
     /**
      * Test that signs and verifies a Timestamp. The request is then modified so that the
      * Timestamp has a default (WSU) namespace inserted. The signature validation should still
      * pass due to c14n (see WSS-181).
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -463,40 +463,40 @@ public class SignatureTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(300);
         Document createdDoc = timestamp.build(doc, secHeader);
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "Timestamp",
                 WSConstants.WSU_NS,
                 "");
         builder.getParts().add(encP);
-        
+
         Document signedDoc = builder.build(createdDoc, crypto, secHeader);
         Element secHeaderElement = secHeader.getSecurityHeader();
-        Node timestampNode = 
+        Node timestampNode =
             secHeaderElement.getElementsByTagNameNS(WSConstants.WSU_NS, "Timestamp").item(0);
         ((Element)timestampNode).setAttributeNS(
             WSConstants.XMLNS_NS, "xmlns", WSConstants.WSU_NS
         );
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
-    
+
     /**
      * Sign using a different digest algorithm (SHA-256).
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -514,14 +514,14 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with IssuerSerial key identifier:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
         LOG.info("After Signing IS....");
         verify(signedDoc);
     }
-    
+
     /**
      * A test for "SignatureAction does not set DigestAlgorithm on WSSecSignature instance"
      */
@@ -536,25 +536,25 @@ public class SignatureTest extends org.j
         config.put(WSHandlerConstants.SIG_PROP_FILE, "crypto.properties");
         config.put("password", "security");
         config.put(
-            WSHandlerConstants.SIG_ALGO, 
+            WSHandlerConstants.SIG_ALGO,
             "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
         );
         config.put(
-            WSHandlerConstants.SIG_DIGEST_ALGO, 
+            WSHandlerConstants.SIG_DIGEST_ALGO,
             "http://www.w3.org/2001/04/xmlenc#sha256"
         );
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         HandlerAction action = new HandlerAction(WSConstants.SIGN);
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(action),
             true
         );
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message:");
@@ -566,14 +566,14 @@ public class SignatureTest extends org.j
         assertTrue(
                 outputString.contains("http://www.w3.org/2001/04/xmlenc#sha256")
         );
-        
+
         verify(doc);
     }
-    
+
     /**
-     * This is a test for WSS-234 - 
-     * "When a document contains a comment as its first child element, 
-     * wss4j will not find the SOAP body." 
+     * This is a test for WSS-234 -
+     * "When a document contains a comment as its first child element,
+     * wss4j will not find the SOAP body."
      */
     @org.junit.Test
     public void testWSS234() throws Exception {
@@ -584,7 +584,7 @@ public class SignatureTest extends org.j
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
         Document signedDoc = builder.build(doc, crypto, secHeader);
-        
+
         // Add a comment node as the first node element
         Node firstChild = signedDoc.getFirstChild();
         Node newNode = signedDoc.removeChild(firstChild);
@@ -594,14 +594,14 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
-    
+
     /**
      * Test that signs and verifies a Timestamp. The Signature element is appended to the security
      * header, and so appears after the Timestamp element.
@@ -611,42 +611,42 @@ public class SignatureTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(300);
         Document createdDoc = timestamp.build(doc, secHeader);
-        
+
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "Timestamp",
                 WSConstants.WSU_NS,
                 "");
         builder.getParts().add(encP);
-        
+
         builder.prepare(createdDoc, crypto, secHeader);
-        
-        List<javax.xml.crypto.dsig.Reference> referenceList = 
+
+        List<javax.xml.crypto.dsig.Reference> referenceList =
             builder.addReferencesToSign(builder.getParts(), secHeader);
 
         builder.computeSignature(referenceList, false, null);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         verify(doc);
     }
-    
+
     /**
-     * This is a test for WSS-283 - "ClassCastException when signing message with existing 
+     * This is a test for WSS-283 - "ClassCastException when signing message with existing
      * WSSE header containing Text as first child":
-     * 
+     *
      * https://issues.apache.org/jira/browse/WSS-283
      */
     @org.junit.Test
@@ -654,24 +654,24 @@ public class SignatureTest extends org.j
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         Element secHeaderElement = secHeader.insertSecurityHeader();
         Node textNode = doc.createTextNode("This is a text node");
         secHeaderElement.appendChild(textNode);
         Document signedDoc = builder.build(doc, crypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with text node:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
-    
+
     /**
      * Create a signature that uses a custom SecurityTokenReference.
      */
@@ -684,32 +684,32 @@ public class SignatureTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         SecurityTokenReference secRef = new SecurityTokenReference(doc);
         Reference ref = new Reference(doc);
         ref.setURI("custom-uri");
         secRef.setReference(ref);
         builder.setSecurityTokenReference(secRef);
-        
+
         Document signedDoc = builder.build(doc, crypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
     }
-    
+
     /**
      * The test uses the Issuer Serial key identifier type.
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
     public void testX509SignatureDefaultPassword() throws Exception {
         Crypto passwordCrypto = CryptoFactory.getInstance("alice.properties");
-        
+
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo(passwordCrypto.getDefaultX509Identifier(), null);
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
@@ -721,7 +721,7 @@ public class SignatureTest extends org.j
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with IssuerSerial key identifier:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
@@ -729,7 +729,7 @@ public class SignatureTest extends org.j
         WSSecurityEngine newEngine = new WSSecurityEngine();
         newEngine.processSecurityHeader(doc, null, null, passwordCrypto);
     }
-    
+
     /**
      * A test for "There is an issue with the position of the <Timestamp> element in the
      * <Security> header when using WSS4J calling .NET Web Services with WS-Security."
@@ -741,7 +741,7 @@ public class SignatureTest extends org.j
         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");
@@ -749,33 +749,33 @@ public class SignatureTest extends org.j
             WSHandlerConstants.SIGNATURE_PARTS, "{}{" + WSConstants.WSU_NS + "}Timestamp"
         );
         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.SIGN));
         actions.add(new HandlerAction(WSConstants.TS));
         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);
         }
-        
+
         WSHandlerResult results = verify(doc);
-            
+
         List<Integer> receivedActions = new ArrayList<>();
         receivedActions.add(WSConstants.SIGN);
         receivedActions.add(WSConstants.TS);
         assertTrue(handler.checkResults(results.getResults(), receivedActions));
     }
-    
+
     @org.junit.Test
     public void
     testSignatureEncryptTimestampOrder() throws Exception {
@@ -783,7 +783,7 @@ public class SignatureTest extends org.j
         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(WSHandlerConstants.ENC_PROP_FILE, "crypto.properties");
@@ -792,7 +792,7 @@ public class SignatureTest extends org.j
             WSHandlerConstants.SIGNATURE_PARTS, "{}{" + WSConstants.WSU_NS + "}Timestamp"
         );
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         List<HandlerAction> actions = new ArrayList<>();
@@ -800,19 +800,19 @@ public class SignatureTest extends org.j
         actions.add(new HandlerAction(WSConstants.ENCR));
         actions.add(new HandlerAction(WSConstants.TS));
         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);
         }
     }
-    
+
     @org.junit.Test
     public void
     testEncryptSignatureTimestampOrder() throws Exception {
@@ -820,7 +820,7 @@ public class SignatureTest extends org.j
         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(WSHandlerConstants.ENC_PROP_FILE, "crypto.properties");
@@ -829,7 +829,7 @@ public class SignatureTest extends org.j
             WSHandlerConstants.SIGNATURE_PARTS, "{}{" + WSConstants.WSU_NS + "}Timestamp"
         );
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         List<HandlerAction> actions = new ArrayList<>();
@@ -837,64 +837,64 @@ public class SignatureTest extends org.j
         actions.add(new HandlerAction(WSConstants.SIGN));
         actions.add(new HandlerAction(WSConstants.TS));
         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);
         }
     }
-    
+
     @org.junit.Test
     public void testWSHandlerSignatureCanonicalization() throws Exception {
         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(WSHandlerConstants.SIG_C14N_ALGO, WSConstants.C14N_WITH_COMMENTS);
         config.put("password", "security");
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         HandlerAction action = new HandlerAction(WSConstants.SIGN);
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(action),
             true
         );
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message:");
             LOG.debug(outputString);
         }
-        
+
         RequestData data = new RequestData();
         data.setWssConfig(WSSConfig.getNewInstance());
         data.setSigVerCrypto(crypto);
-        
+
         List<BSPRule> disabledRules = new ArrayList<>();
         disabledRules.add(BSPRule.R5404);
         disabledRules.add(BSPRule.R5406);
         data.setIgnoredBSPRules(disabledRules);
-        
+
         WSSecurityEngine newSecEngine = new WSSecurityEngine();
-        WSHandlerResult results = 
+        WSHandlerResult results =
             newSecEngine.processSecurityHeader(doc, data);
-        assertTrue(handler.checkResults(results.getResults(), 
+        assertTrue(handler.checkResults(results.getResults(),
                                         Collections.singletonList(WSConstants.SIGN)));
     }
-    
+
     @org.junit.Test
     public void testCommentInSOAPBody() throws Exception {
         WSSecSignature builder = new WSSecSignature();
@@ -904,26 +904,26 @@ public class SignatureTest extends org.j
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
         Document signedDoc = builder.build(doc, crypto, secHeader);
-        
+
         // Add a comment node
         Element body = WSSecurityUtil.findBodyElement(signedDoc);
         Node commentNode = signedDoc.createComment("This is a comment");
         body.getFirstChild().appendChild(commentNode);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
-    
+
 
     /**
      * Verifies the soap envelope.
-     * This method verifies all the signature generated. 
-     * 
+     * This method verifies all the signature generated.
+     *
      * @param env soap envelope
      * @throws java.lang.Exception Thrown when there is a problem in verification
      */

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java Tue Dec 15 16:40:37 2015
@@ -47,16 +47,16 @@ import org.w3c.dom.Document;
  * used to verify the signature.
  */
 public class SignedBSTTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SignedBSTTest.class);
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public SignedBSTTest() throws Exception {
         WSSConfig.init();
         crypto = CryptoFactory.getInstance("wss40.properties");
@@ -69,19 +69,19 @@ public class SignedBSTTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         // Get a certificate, convert it into a BinarySecurityToken and add it to the security header
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
         cryptoType.setAlias("wss40");
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         assertNotNull(certs);
-        
+
         X509Security bst = new X509Security(doc);
         String certUri = WSSConfig.getNewInstance().getIdAllocator().createSecureId("X509-", certs[0]);
         bst.setX509Certificate(certs[0]);
         bst.setID(certUri);
         WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
-        
+
         // Add the signature
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("wss40", "security");
@@ -103,75 +103,75 @@ public class SignedBSTTest extends org.j
             );
         encP.setElement(bst.getElement());
         sign.getParts().add(encP);
-        
+
         sign.setCustomTokenId(bst.getID());
         sign.setCustomTokenValueType(bst.getValueType());
         sign.prepare(doc, crypto, secHeader);
-        
-        List<javax.xml.crypto.dsig.Reference> referenceList = 
+
+        List<javax.xml.crypto.dsig.Reference> referenceList =
             sign.addReferencesToSign(sign.getParts(), secHeader);
         sign.computeSignature(referenceList, false, null);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         verify(doc);
     }
-    
+
     @org.junit.Test
     public void testSignedBSTAction() throws Exception {
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
         reqData.setUsername("wss40");
-        
+
         java.util.Map<String, Object> config = new java.util.TreeMap<String, Object>();
         config.put(WSHandlerConstants.SIG_PROP_FILE, "wss40.properties");
         config.put("password", "security");
         config.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
         config.put(
-            WSHandlerConstants.SIGNATURE_PARTS, 
+            WSHandlerConstants.SIGNATURE_PARTS,
             "{}{" + WSConstants.WSSE_NS + "}BinarySecurityToken"
         );
         reqData.setMsgContext(config);
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         HandlerAction action = new HandlerAction(WSConstants.SIGN);
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(action),
             true
         );
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message:");
             LOG.debug(outputString);
         }
-        
+
         WSHandlerResult results = verify(doc);
-        assertTrue(handler.checkResults(results.getResults(), 
+        assertTrue(handler.checkResults(results.getResults(),
                                         Collections.singletonList(WSConstants.SIGN)));
     }
 
     /**
      * Verifies the soap envelope
      * <p/>
-     * 
-     * @param doc 
+     *
+     * @param doc
      * @throws Exception Thrown when there is a problem in verification
      */
     private WSHandlerResult verify(Document doc) throws Exception {
-        WSHandlerResult results = 
+        WSHandlerResult results =
             secEngine.processSecurityHeader(doc, null, null, crypto);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Verfied and decrypted message:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java Tue Dec 15 16:40:37 2015
@@ -51,23 +51,23 @@ import org.w3c.dom.Document;
 
 /**
  * Test symmetric key signature created using an encrypted key
- * Demonstrates that Signature Crypto object can have null values when 
+ * Demonstrates that Signature Crypto object can have null values when
  * calling processSecurityHeader method of WSSecurityEngine.
  */
 public class SymmetricSignatureTest extends org.junit.Assert implements CallbackHandler {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SymmetricSignatureTest.class);
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private CallbackHandler callbackHandler = new KeystoreCallbackHandler();
     private SecretKeyCallbackHandler secretKeyCallbackHandler = new SecretKeyCallbackHandler();
     private byte[] keyData;
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public SymmetricSignatureTest() throws Exception {
         WSSConfig.init();
         crypto = CryptoFactory.getInstance("wss40.properties");
@@ -76,7 +76,7 @@ public class SymmetricSignatureTest exte
     /**
      * Setup method
      * <p/>
-     * 
+     *
      * @throws Exception Thrown when there is a problem in setup
      */
     @org.junit.Before
@@ -93,32 +93,32 @@ public class SymmetricSignatureTest exte
     @org.junit.Test
     public void testSymmetricSignatureSHA1() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecSignature sign = new WSSecSignature();
         sign.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
         sign.setSecretKey(keyData);
         sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
 
         Document signedDoc = sign.build(doc, crypto, secHeader);
-        
+
         byte[] encodedBytes = KeyUtils.generateDigest(keyData);
         String identifier = Base64.encode(encodedBytes);
         secretKeyCallbackHandler.addSecretKey(identifier, keyData);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed symmetric message SHA1:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
 
         secEngine.processSecurityHeader(doc, null, secretKeyCallbackHandler, null, crypto);
     }
-    
-    
+
+
     /**
      * Test signing a message body using a symmetric key with Direct Reference to an
      * EncryptedKey
@@ -126,16 +126,16 @@ public class SymmetricSignatureTest exte
     @org.junit.Test
     public void testSymmetricSignatureDR() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
         encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         encrKey.setUserInfo("wss40", "security");
         encrKey.setSymmetricEncAlgorithm(WSConstants.AES_192);
         encrKey.prepare(doc, crypto);
-        
+
         WSSecSignature sign = new WSSecSignature();
         sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
         sign.setCustomTokenId(encrKey.getId());
@@ -145,21 +145,21 @@ public class SymmetricSignatureTest exte
 
         Document signedDoc = sign.build(doc, crypto, secHeader);
         encrKey.prependToHeader(secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed symmetric message DR:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(signedDoc);
     }
 
     /**
      * Test that first signs, then encrypts a WS-Security envelope.
      * <p/>
-     * 
+     *
      * @throws Exception Thrown when there is any problem in signing, encryption,
      *                   decryption, or verification
      */
@@ -167,16 +167,16 @@ public class SymmetricSignatureTest exte
     public void testEncryptedKeySignature() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         LOG.info("Before Sign/Encryption....");
-        
+
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
         encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         encrKey.setUserInfo("wss40", "security");
         encrKey.setSymmetricEncAlgorithm(WSConstants.AES_192);
-        encrKey.prepare(doc, crypto);   
-        
+        encrKey.prepare(doc, crypto);
+
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setEncKeyId(encrKey.getId());
         encrypt.setEphemeralKey(encrKey.getEphemeralKey());
@@ -196,17 +196,17 @@ public class SymmetricSignatureTest exte
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed and encrypted message with IssuerSerial key identifier (both), 3DES:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
             LOG.debug(outputString);
         }
-        
+
         LOG.info("After Sign/Encryption....");
         verify(encryptedSignedDoc);
     }
 
     /**
-     * Test signing a message body using a symmetric key with EncryptedKeySHA1. 
+     * Test signing a message body using a symmetric key with EncryptedKeySHA1.
      * The request is generated using WSHandler, instead of coding it.
      */
     @org.junit.Test
@@ -220,48 +220,48 @@ public class SymmetricSignatureTest exte
         messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, this);
         reqData.setMsgContext(messageContext);
         reqData.setUsername("");
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         HandlerAction action = new HandlerAction(WSConstants.SIGN);
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(action),
             true
         );
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         reqData = new RequestData();
         reqData.setWssConfig(WSSConfig.getNewInstance());
         messageContext = new java.util.TreeMap<String, Object>();
         messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, this);
         reqData.setMsgContext(messageContext);
         reqData.setUsername("");
-        
+
         handler.receive(Collections.singletonList(WSConstants.SIGN), reqData);
-        
+
         secEngine.processSecurityHeader(doc, null, this, null, crypto);
     }
-    
-    
+
+
     /**
      * Verifies the soap envelope
      * <p/>
-     * 
-     * @param doc 
+     *
+     * @param doc
      * @throws Exception Thrown when there is a problem in verification
      */
     private void verify(Document doc) throws Exception {
         secEngine.processSecurityHeader(doc, null, callbackHandler, null, crypto);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Verfied and decrypted message:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -285,6 +285,6 @@ public class SymmetricSignatureTest exte
             }
         }
     }
-    
+
 
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TestMessageTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TestMessageTransformer.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TestMessageTransformer.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TestMessageTransformer.java Tue Dec 15 16:40:37 2015
@@ -45,7 +45,7 @@ public class TestMessageTransformer exte
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public static Element duplicateEncryptedDataInWsseHeader(Element saaj, boolean moveReferenceList) throws TransformerException, IOException {
         if (moveReferenceList) {
             moveReferenceList(saaj);
@@ -120,7 +120,7 @@ public class TestMessageTransformer exte
         print(saaj.getOwnerDocument());
         return newEncData;
     }
-    
+
     public static Element duplicateEncryptedDataInWrapperBody(Element saaj) throws TransformerException, IOException {
         Element body = getFirstChildElement(saaj, new QName("http://schemas.xmlsoap.org/soap/envelope/",
                                                             "Body"), true);
@@ -141,7 +141,7 @@ public class TestMessageTransformer exte
         }
         Element wrapper = encData.getOwnerDocument().createElementNS(null, "a");
         wrapper.appendChild(newEncData);
-        
+
         body.appendChild(wrapper);
         while (cur != null) {
             cur = copyHeadersAndUpdateRefList(cur, newWsseHeader, newId);
@@ -155,7 +155,7 @@ public class TestMessageTransformer exte
         print(saaj.getOwnerDocument());
         return newEncData;
     }
-    
+
     public static Element duplicateEncryptedDataAfterWrapperBody(Element saaj) throws TransformerException, IOException {
         Element body = getFirstChildElement(saaj, new QName("http://schemas.xmlsoap.org/soap/envelope/",
                                                             "Body"), true);
@@ -178,7 +178,7 @@ public class TestMessageTransformer exte
         Node clonedBody = body.cloneNode(false);
         clonedBody.appendChild(newEncData);
         wrapper.appendChild(clonedBody);
-        
+
         body.getParentNode().appendChild(wrapper);
         while (cur != null) {
             cur = copyHeadersAndUpdateRefList(cur, newWsseHeader, newId);
@@ -231,7 +231,7 @@ public class TestMessageTransformer exte
         print(saaj.getOwnerDocument());
         return newEncData;
     }
-    
+
     public static Element addEncryptedDataWithEmbeddedEncryptedKeyInWsseHeader(Element saaj) throws TransformerException, IOException {
         moveReferenceList(saaj);
         Element body = getFirstChildElement(saaj, new QName("http://schemas.xmlsoap.org/soap/envelope/",

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java Tue Dec 15 16:40:37 2015
@@ -49,15 +49,15 @@ import org.w3c.dom.Element;
  * WS-Security Test Case for Timestamps.
  */
 public class TimestampTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(TimestampTest.class);
 
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     /**
      * This is a test for processing a valid Timestamp.
      */
@@ -67,35 +67,35 @@ public class TimestampTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(300);
         Document createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Do some processing
         //
         WSHandlerResult wsResult = verify(createdDoc);
-        WSSecurityEngineResult actionResult = 
+        WSSecurityEngineResult actionResult =
             wsResult.getActionResults().get(WSConstants.TS).get(0);
         assertTrue(actionResult != null);
-        
-        Timestamp receivedTimestamp = 
+
+        Timestamp receivedTimestamp =
             (Timestamp)actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);
         assertTrue(receivedTimestamp != null);
-        
+
         Timestamp clone = new Timestamp(receivedTimestamp.getElement(), new BSPEnforcer(true));
         assertTrue(clone.equals(receivedTimestamp));
         assertTrue(clone.hashCode() == receivedTimestamp.hashCode());
     }
-    
-    
+
+
     /**
      * This is a test for processing a valid Timestamp with no expires element
      */
@@ -105,47 +105,47 @@ public class TimestampTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(0);
         Document createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Do some processing
         //
         WSHandlerResult wsResult = verify(createdDoc);
-        WSSecurityEngineResult actionResult = 
+        WSSecurityEngineResult actionResult =
             wsResult.getActionResults().get(WSConstants.TS).get(0);
         assertTrue(actionResult != null);
-        
-        Timestamp receivedTimestamp = 
+
+        Timestamp receivedTimestamp =
             (Timestamp)actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);
         assertTrue(receivedTimestamp != null);
     }
-    
+
     @org.junit.Test
     public void testInvalidTimestampNoExpires() throws Exception {
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(0);
         Document createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Do some processing
         //
@@ -157,22 +157,22 @@ public class TimestampTest extends org.j
             secEngine.processSecurityHeader(doc, requestData);
             fail("Failure expected on no Expires Element");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.SECURITY_ERROR); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.SECURITY_ERROR);
         }
 
         requestData.setWssConfig(WSSConfig.getNewInstance());
         requestData.setRequireTimestampExpires(false);
         WSHandlerResult wsResult = secEngine.processSecurityHeader(doc, requestData);
-        WSSecurityEngineResult actionResult = 
+        WSSecurityEngineResult actionResult =
             wsResult.getActionResults().get(WSConstants.TS).get(0);
         assertTrue(actionResult != null);
-        
-        Timestamp receivedTimestamp = 
+
+        Timestamp receivedTimestamp =
             (Timestamp)actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);
         assertTrue(receivedTimestamp != null);
     }
-    
-    
+
+
     /**
      * This is a test for processing an expired Timestamp.
      */
@@ -182,46 +182,46 @@ public class TimestampTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(-1);
         Document createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(createdDoc);
             fail("Expected failure on an expired timestamp");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED); 
-        }        
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED);
+        }
     }
-    
-    
+
+
     /**
      * This is a test for processing an "old" Timestamp, i.e. one with a "Created" element that is
      * out of date
      */
     @org.junit.Test
     public void testOldTimestamp() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         Document createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Do some processing
         //
@@ -232,24 +232,24 @@ public class TimestampTest extends org.j
             verify(createdDoc, requestData);
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED); 
-        }  
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED);
+        }
     }
-    
-    
+
+
     /**
      * This is a test for processing an Timestamp where the "Created" element is in the (near)
-     * future. It should be accepted by default when it is created 30 seconds in the future, 
+     * future. It should be accepted by default when it is created 30 seconds in the future,
      * and then rejected once we configure "0 seconds" for future-time-to-live.
      */
     @org.junit.Test
     public void testNearFutureCreated() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -266,9 +266,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementCreated);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -282,22 +282,22 @@ public class TimestampTest extends org.j
             verify(doc, requestData);
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED);
         }
     }
-    
+
     /**
      * This is a test for processing an Timestamp where the "Created" element is in the future.
      * A Timestamp that is 120 seconds in the future should be rejected by default.
      */
     @org.junit.Test
     public void testFutureCreated() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -314,9 +314,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementCreated);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -327,23 +327,23 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED);
         }
     }
-    
-    
+
+
     /**
      * This is a test for processing an Timestamp where the "Created" element is greater than
      * the expiration time.
      */
     @org.junit.Test
     public void testExpiresBeforeCreated() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -358,7 +358,7 @@ public class TimestampTest extends org.j
         createdDate.setTime(currentTime);
         elementCreated.appendChild(doc.createTextNode(zulu.format(createdDate)));
         timestampElement.appendChild(elementCreated);
-        
+
         Date expiresDate = new Date();
         expiresDate.setTime(expiresDate.getTime() - 300000);
 
@@ -370,9 +370,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementExpires);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -383,10 +383,10 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED);
         }
     }
-    
+
     /**
      * This is a test for processing multiple Timestamps in the security header
      */
@@ -396,21 +396,21 @@ public class TimestampTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(300);
         Document createdDoc = timestamp.build(doc, secHeader);
-        
+
         timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(60);
         createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Do some processing
         //
@@ -418,24 +418,24 @@ public class TimestampTest extends org.j
             verify(createdDoc);
             fail("Expected failure on multiple timestamps");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         verify(createdDoc, Collections.singletonList(BSPRule.R3227));
     }
-    
+
     /**
      * This is a test for processing an Timestamp where it contains multiple "Created" elements.
      * This Timestamp should be rejected.
      */
     @org.junit.Test
     public void testMultipleCreated() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -451,9 +451,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementCreated.cloneNode(true));
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -464,24 +464,24 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed on multiple Created elements");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         verify(doc, Collections.singletonList(BSPRule.R3203));
     }
-    
+
     /**
      * This is a test for processing an Timestamp where it contains no "Created" element.
      * This Timestamp should be rejected.
      */
     @org.junit.Test
     public void testNoCreated() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -498,9 +498,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementCreated);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -511,31 +511,31 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed on no Created element");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         List<BSPRule> rules = new ArrayList<>();
         rules.add(BSPRule.R3203);
         rules.add(BSPRule.R3221);
         verify(doc, rules);
     }
-    
+
     /**
      * This is a test for processing an Timestamp where it contains multiple "Expires" elements.
      * This Timestamp should be rejected.
      */
     @org.junit.Test
     public void testMultipleExpires() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
-        
+
         DateFormat zulu = new XmlSchemaDateFormat();
         Element elementCreated =
             doc.createElementNS(
@@ -558,9 +558,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementExpires.cloneNode(true));
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -571,24 +571,24 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed on multiple Expires elements");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         verify(doc, Collections.singletonList(BSPRule.R3224));
     }
-    
+
     /**
      * This is a test for processing an Timestamp where it contains an "Expires" element before
      * the Created element. This Timestamp should be rejected as per the BSP spec.
      */
     @org.junit.Test
     public void testExpiresInFrontOfCreated() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -603,7 +603,7 @@ public class TimestampTest extends org.j
         expiresDate.setTime(currentTime);
         elementCreated.appendChild(doc.createTextNode(zulu.format(expiresDate)));
         timestampElement.appendChild(elementCreated);
-        
+
         Element elementExpires =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.CREATED_LN
@@ -612,9 +612,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementExpires);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -625,25 +625,25 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         verify(doc, Collections.singletonList(BSPRule.R3221));
     }
-    
-    
+
+
     /**
      * This is a test for processing an Timestamp where it contains a Created element with
      * seconds > 60. This should be rejected as per the BSP spec.
      */
     @org.junit.Test
     public void testCreatedSeconds() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -656,9 +656,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementCreated);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -672,23 +672,23 @@ public class TimestampTest extends org.j
             verify(doc, wssConfig, new ArrayList<BSPRule>());
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
     }
-    
-    
+
+
     /**
      * This is a test for processing an Timestamp where it contains a Created element with
      * a ValueType. This should be rejected as per the BSP spec.
      */
     @org.junit.Test
     public void testCreatedValueType() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -706,9 +706,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementCreated);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -719,15 +719,15 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         // Now it should pass...
         WSSConfig wssConfig = WSSConfig.getNewInstance();
         wssConfig.setValidator(WSConstants.TIMESTAMP, new NoOpValidator());
         verify(doc, wssConfig, Collections.singletonList(BSPRule.R3225));
     }
-    
+
 
 
     /**
@@ -736,12 +736,12 @@ public class TimestampTest extends org.j
      */
     @org.junit.Test
     public void testCustomElement() throws Exception {
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Element timestampElement = 
+
+        Element timestampElement =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
@@ -754,7 +754,7 @@ public class TimestampTest extends org.j
         Date createdDate = new Date();
         elementCreated.appendChild(doc.createTextNode(zulu.format(createdDate)));
         timestampElement.appendChild(elementCreated);
-        
+
         Element elementExpires =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.EXPIRES_LN
@@ -762,7 +762,7 @@ public class TimestampTest extends org.j
         createdDate.setTime(createdDate.getTime() + 300000);
         elementExpires.appendChild(doc.createTextNode(zulu.format(createdDate)));
         timestampElement.appendChild(elementExpires);
-        
+
         Element elementCustom =
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + "Custom"
@@ -770,9 +770,9 @@ public class TimestampTest extends org.j
         timestampElement.appendChild(elementCustom);
 
         secHeader.getSecurityHeader().appendChild(timestampElement);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
@@ -783,13 +783,13 @@ public class TimestampTest extends org.j
             verify(doc);
             fail("The timestamp validation should have failed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         // Now it should pass...
         verify(doc, Collections.singletonList(BSPRule.R3222));
     }
-    
+
     /**
      * This is a test to create a "Spoofed" Timestamp (see WSS-441)
      */
@@ -799,10 +799,10 @@ public class TimestampTest extends org.j
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(300);
-        
+
         WSTimeSource spoofedTimeSource = new WSTimeSource() {
 
             public Date now() {
@@ -810,18 +810,18 @@ public class TimestampTest extends org.j
                 currentTime.setTime(currentTime.getTime() - (500L * 1000L));
                 return currentTime;
             }
-            
+
         };
         timestamp.setWsTimeSource(spoofedTimeSource);
-        
+
         Document createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Do some processing
         //
@@ -829,64 +829,64 @@ public class TimestampTest extends org.j
             verify(createdDoc);
             fail("Expected failure on an expired timestamp");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.MESSAGE_EXPIRED);
         }
     }
-    
+
     @org.junit.Test
     public void testTimestampNoMilliseconds() throws Exception {
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setPrecisionInMilliSeconds(false);
         timestamp.setTimeToLive(300);
         Document createdDoc = timestamp.build(doc, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(createdDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Do some processing
         //
         WSHandlerResult wsResult = verify(createdDoc);
-        WSSecurityEngineResult actionResult = 
+        WSSecurityEngineResult actionResult =
             wsResult.getActionResults().get(WSConstants.TS).get(0);
         assertTrue(actionResult != null);
     }
-    
+
     @org.junit.Test
     public void testThaiLocaleVerification() throws Exception {
-        
+
         Locale defaultLocale = Locale.getDefault();
         try {
             Locale.setDefault(new Locale("th", "TH"));
-        
+
             Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
-            
+
             WSSecTimestamp timestamp = new WSSecTimestamp();
             timestamp.setTimeToLive(300);
             Document createdDoc = timestamp.build(doc, secHeader);
-            
+
             //
             // Do some processing
             //
             WSHandlerResult wsResult = verify(createdDoc);
-            WSSecurityEngineResult actionResult = 
+            WSSecurityEngineResult actionResult =
                 wsResult.getActionResults().get(WSConstants.TS).get(0);
             assertTrue(actionResult != null);
         } finally {
             Locale.setDefault(defaultLocale);
         }
     }
-    
+
     /**
      * Verifies the soap envelope
      */
@@ -898,14 +898,14 @@ public class TimestampTest extends org.j
         requestData.setWssConfig(WSSConfig.getNewInstance());
         return secEngine.processSecurityHeader(doc, requestData);
     }
-    
+
     private WSHandlerResult verify(
         Document doc, RequestData requestData
     ) throws Exception {
         WSSecurityEngine secEngine = new WSSecurityEngine();
         return secEngine.processSecurityHeader(doc, requestData);
     }
-    
+
     /**
      * Verifies the soap envelope
      */
@@ -917,7 +917,7 @@ public class TimestampTest extends org.j
         requestData.setIgnoredBSPRules(ignoredRules);
         return secEngine.processSecurityHeader(doc, requestData);
     }
-    
+
     /**
      * Verifies the soap envelope
      */
@@ -930,6 +930,6 @@ public class TimestampTest extends org.j
         requestData.setIgnoredBSPRules(ignoredRules);
         return secEngine.processSecurityHeader(doc, requestData);
     }
-    
-    
+
+
 }



Mime
View raw message