ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1720192 [19/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/EncryptionAlgorithmSuiteTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionAlgorithmSuiteTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionAlgorithmSuiteTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionAlgorithmSuiteTest.java Tue Dec 15 16:40:37 2015
@@ -43,20 +43,20 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
- * A set of test-cases for encrypting and decrypting SOAP requests when specifying an 
+ * A set of test-cases for encrypting and decrypting SOAP requests when specifying an
  * AlgorithmSuite policy.
  */
 public class EncryptionAlgorithmSuiteTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(EncryptionAlgorithmSuiteTest.class);
-    
+
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public EncryptionAlgorithmSuiteTest() throws Exception {
         WSSConfig.init();
         crypto = CryptoFactory.getInstance("wss40.properties");
@@ -68,218 +68,218 @@ public class EncryptionAlgorithmSuiteTes
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         Element securityHeader = WSSecurityUtil.getSecurityHeader(encryptedDoc, null);
         AlgorithmSuite algorithmSuite = createAlgorithmSuite();
-        
+
         verify(securityHeader, algorithmSuite, crypto);
-        
+
         algorithmSuite.setMinimumAsymmetricKeyLength(1024);
-        
+
         try {
             verify(securityHeader, algorithmSuite, crypto);
             fail("Expected failure as 512-bit keys are not allowed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
     }
-    
+
     @org.junit.Test
     public void testEncryptionKeyTransportRSA15() throws Exception {
-        
+
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
-        
+
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         builder.setKeyEncAlgo(WSConstants.KEYTRANSPORT_RSA15);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         Element securityHeader = WSSecurityUtil.getSecurityHeader(encryptedDoc, null);
         AlgorithmSuite algorithmSuite = createAlgorithmSuite();
-        
+
         try {
             verify(securityHeader, algorithmSuite, wssCrypto);
             fail("Expected failure as RSA 15 is not allowed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         algorithmSuite.addKeyWrapAlgorithm(WSConstants.KEYTRANSPORT_RSA15);
         verify(securityHeader, algorithmSuite, wssCrypto);
     }
-    
+
     @org.junit.Test
     public void testEncryptionKeyTransportRSA15NoAlgorithmSuite() throws Exception {
-        
+
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
-        
+
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         builder.setKeyEncAlgo(WSConstants.KEYTRANSPORT_RSA15);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         Element securityHeader = WSSecurityUtil.getSecurityHeader(encryptedDoc, null);
-        
+
         try {
             verify(securityHeader, null, wssCrypto);
             fail("Expected failure as RSA 15 is not allowed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         // Now enable RSA v1.5 processing
         WSSecurityEngine secEngine = new WSSecurityEngine();
         RequestData data = new RequestData();
         data.setDecCrypto(wssCrypto);
         data.setAllowRSA15KeyTransportAlgorithm(true);
-        
+
         data.setCallbackHandler(new KeystoreCallbackHandler());
-        
+
         secEngine.processSecurityHeader(securityHeader, data);
     }
-    
+
     @org.junit.Test
     public void testEncryptionMethodAES128() throws Exception {
-        
+
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
-        
+
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.AES_128);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         Element securityHeader = WSSecurityUtil.getSecurityHeader(encryptedDoc, null);
         AlgorithmSuite algorithmSuite = createAlgorithmSuite();
-        
+
         try {
             verify(securityHeader, algorithmSuite, wssCrypto);
             fail("Expected failure as AES 128 is not allowed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         algorithmSuite.addEncryptionMethod(WSConstants.AES_128);
         verify(securityHeader, algorithmSuite, wssCrypto);
     }
-    
+
     @org.junit.Test
     public void testSymmetricEncryption() throws Exception {
-        
+
         KeyGenerator keyGen = KeyGenerator.getInstance("AES");
         keyGen.init(128);
         SecretKey key = keyGen.generateKey();
         byte[] keyData = key.getEncoded();
-        
+
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
         builder.setSymmetricKey(key);
         builder.setEncryptSymmKey(false);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
 
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         byte[] encodedBytes = KeyUtils.generateDigest(keyData);
         String identifier = Base64.encode(encodedBytes);
         SecretKeyCallbackHandler secretKeyCallbackHandler = new SecretKeyCallbackHandler();
         secretKeyCallbackHandler.addSecretKey(identifier, keyData);
-        
+
         Element securityHeader = WSSecurityUtil.getSecurityHeader(encryptedDoc, null);
         AlgorithmSuite algorithmSuite = createAlgorithmSuite();
-        
+
         WSSecurityEngine secEngine = new WSSecurityEngine();
         RequestData data = new RequestData();
         data.setDecCrypto(crypto);
         data.setCallbackHandler(secretKeyCallbackHandler);
-        
+
         data.setAlgorithmSuite(algorithmSuite);
-        
+
         algorithmSuite.addEncryptionMethod(WSConstants.AES_128);
         secEngine.processSecurityHeader(securityHeader, data);
-        
+
         algorithmSuite.setMinimumSymmetricKeyLength(256);
         try {
             secEngine.processSecurityHeader(securityHeader, data);
             fail("Expected failure as a 128 bit key is not allowed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         algorithmSuite.setMinimumSymmetricKeyLength(64);
         algorithmSuite.setMaximumSymmetricKeyLength(120);
         try {
             secEngine.processSecurityHeader(securityHeader, data);
             fail("Expected failure as a 128 bit key is not allowed");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
     }
-    
-    
+
+
     private AlgorithmSuite createAlgorithmSuite() {
         AlgorithmSuite algorithmSuite = new AlgorithmSuite();
         algorithmSuite.setMinimumAsymmetricKeyLength(512);
         algorithmSuite.addKeyWrapAlgorithm(WSConstants.KEYTRANSPORT_RSAOEP);
         algorithmSuite.addEncryptionMethod(WSConstants.TRIPLE_DES);
-        
+
         return algorithmSuite;
     }
 
@@ -289,11 +289,11 @@ public class EncryptionAlgorithmSuiteTes
         WSSecurityEngine secEngine = new WSSecurityEngine();
         RequestData data = new RequestData();
         data.setDecCrypto(decCrypto);
-        
+
         data.setAlgorithmSuite(algorithmSuite);
-        
+
         data.setCallbackHandler(new KeystoreCallbackHandler());
-        
+
         return secEngine.processSecurityHeader(securityHeader, data);
     }
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java Tue Dec 15 16:40:37 2015
@@ -41,41 +41,41 @@ import org.apache.wss4j.dom.handler.WSHa
 
 
 /**
- * This is a test for Certificate Revocation List checking before encryption. 
- * 
+ * This is a test for Certificate Revocation List checking before encryption.
+ *
  * This test reuses the revoked certificate from SignatureCRLTest
  */
 public class EncryptionCRLTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(EncryptionCRLTest.class);
-        
+
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private CallbackHandler keystoreCallbackHandler = new KeystoreCallbackHandler();
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public EncryptionCRLTest() throws Exception {
         crypto = CryptoFactory.getInstance("wss40All.properties");
     }
-    
+
     /**
      * Setup method
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is a problem in setup
      */
     @org.junit.Before
     public void setUp() throws Exception {
         secEngine.setWssConfig(WSSConfig.getNewInstance());
     }
-    
+
     /**
      * Test that encrypts without certificate revocation check
      * so it should pass
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
      */
     @org.junit.Test
@@ -93,29 +93,29 @@ public class EncryptionCRLTest extends o
         messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, keystoreCallbackHandler);
         reqData.setMsgContext(messageContext);
         reqData.setUsername("wss40rev");
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(new HandlerAction(WSConstants.ENCR)),
             true
         );
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         verify(doc, crypto, keystoreCallbackHandler);
     }
-    
+
     /**
      * Test that encrypts with certificate revocation check
      * so it should fail
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
      * TODO Re-enable once CRL issue fixed
      */
@@ -135,14 +135,14 @@ public class EncryptionCRLTest extends o
         messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, keystoreCallbackHandler);
         reqData.setMsgContext(messageContext);
         reqData.setUsername("wss40rev");
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         handler.setOption(WSHandlerConstants.ENABLE_REVOCATION, "true");
         try {
             handler.send(
-                doc, 
-                reqData, 
+                doc,
+                reqData,
                 Collections.singletonList(new HandlerAction(WSConstants.ENCR)),
                 true
             );
@@ -150,12 +150,12 @@ public class EncryptionCRLTest extends o
         } catch (Exception ex) { //NOPMD
             // expected
         }
-       
+
     }
-    
+
     /**
      * Verifies the soap envelope <p/>
-     * 
+     *
      * @param envelope
      * @throws Exception
      *             Thrown when there is a problem in verification
@@ -165,7 +165,7 @@ public class EncryptionCRLTest extends o
     ) throws Exception {
         secEngine.processSecurityHeader(doc, null, handler, decCrypto);
         if (LOG.isDebugEnabled()) {
-            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/EncryptionGCMTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionGCMTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionGCMTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionGCMTest.java Tue Dec 15 16:40:37 2015
@@ -46,7 +46,7 @@ import java.util.List;
  * https://issues.apache.org/jira/browse/WSS-325
  */
 public class EncryptionGCMTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(EncryptionGCMTest.class);
     private static final javax.xml.namespace.QName SOAP_BODY =
         new javax.xml.namespace.QName(
@@ -57,26 +57,26 @@ public class EncryptionGCMTest extends o
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private CallbackHandler keystoreCallbackHandler = new KeystoreCallbackHandler();
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public EncryptionGCMTest() throws Exception {
         crypto = CryptoFactory.getInstance("wss40.properties");
     }
-    
+
     /**
      * Setup method
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is a problem in setup
      */
     @org.junit.Before
     public void setUp() throws Exception {
         secEngine.setWssConfig(WSSConfig.getNewInstance());
     }
-    
+
     @org.junit.Test
     public void testAES128GCM() throws Exception {
         WSSecEncrypt builder = new WSSecEncrypt();
@@ -88,7 +88,7 @@ public class EncryptionGCMTest extends o
         secHeader.insertSecurityHeader();
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message:");
@@ -97,7 +97,7 @@ public class EncryptionGCMTest extends o
         assertFalse(outputString.contains("counter_port_type"));
         verify(encryptedDoc, keystoreCallbackHandler, SOAP_BODY);
     }
-    
+
     @org.junit.Test
     public void testAES256GCM() throws Exception {
         WSSecEncrypt builder = new WSSecEncrypt();
@@ -109,7 +109,7 @@ public class EncryptionGCMTest extends o
         secHeader.insertSecurityHeader();
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message:");
@@ -150,7 +150,7 @@ public class EncryptionGCMTest extends o
     /**
      * Verifies the soap envelope
      * <p/>
-     * 
+     *
      * @throws Exception Thrown when there is a problem in verification
      */
     @SuppressWarnings("unchecked")
@@ -167,7 +167,7 @@ public class EncryptionGCMTest extends o
         requestData.setCallbackHandler(handler);
         requestData.setDecCrypto(crypto);
         final WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
@@ -175,11 +175,11 @@ public class EncryptionGCMTest extends o
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
         //
         // walk through the results, and make sure there is an encryption
-        // action, together with a reference to the decrypted element 
+        // action, together with a reference to the decrypted element
         // (as a QName)
         //
         boolean encrypted = false;
-        for (java.util.Iterator<WSSecurityEngineResult> ipos = results.getResults().iterator(); 
+        for (java.util.Iterator<WSSecurityEngineResult> ipos = results.getResults().iterator();
             ipos.hasNext();) {
             final WSSecurityEngineResult result = ipos.next();
             final Integer action = (Integer) result.get(WSSecurityEngineResult.TAG_ACTION);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java Tue Dec 15 16:40:37 2015
@@ -48,13 +48,13 @@ import java.util.List;
  * has a custom header added.
  */
 public class EncryptionPartsTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(EncryptionPartsTest.class);
     private static final String SOAPMSG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
             "<soapenv:Envelope xmlns:foo=\"urn:foo.bar\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
             "   <soapenv:Header>" +
-            "       <foo:bar1>baz1</foo:bar1>" + 
-            "       <foo:foobar>baz</foo:foobar>" + 
+            "       <foo:bar1>baz1</foo:bar1>" +
+            "       <foo:foobar>baz</foo:foobar>" +
             "       <foo:bar2>baz2</foo:bar2>" +
             "       <foo:with-attributes some-attribute=\"3\">baz</foo:with-attributes>" +
             "   </soapenv:Header>" +
@@ -65,7 +65,7 @@ public class EncryptionPartsTest extends
     private static final String SOAPMSG_MULTIPLE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
         "<soapenv:Envelope xmlns:foo=\"urn:foo.bar\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
         "   <soapenv:Header>" +
-        "       <foo:foobar>baz</foo:foobar>" + 
+        "       <foo:foobar>baz</foo:foobar>" +
         "   </soapenv:Header>" +
         "   <soapenv:Body>" +
         "      <ns1:testMethod xmlns:ns1=\"http://axis/service/security/test6/LogTestService8\">asf1</ns1:testMethod>" +
@@ -76,12 +76,12 @@ public class EncryptionPartsTest extends
     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 EncryptionPartsTest() throws Exception {
         crypto = CryptoFactory.getInstance();
         WSSConfig.init();
@@ -100,46 +100,46 @@ public class EncryptionPartsTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "foobar",
                 "urn:foo.bar",
                 "");
         encrypt.getParts().add(encP);
-        
+
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         WSHandlerResult results = verify(encryptedDoc);
-        
-        WSSecurityEngineResult actionResult = 
+
+        WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
         assertFalse(actionResult.isEmpty());
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-        
-        assertEquals(WSConstants.KEYTRANSPORT_RSAOEP, 
+
+        assertEquals(WSConstants.KEYTRANSPORT_RSAOEP,
                 actionResult.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_TRANSPORT_METHOD));
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/soapenv:Envelope/soapenv:Header/foo:foobar", xpath);
         assertEquals(WSConstants.AES_128, wsDataRef.getAlgorithm());
         QName expectedQName = new QName("urn:foo.bar", "foobar");
         assertEquals(expectedQName, wsDataRef.getName());
-        
+
         Element encryptedElement = wsDataRef.getEncryptedElement();
         assertNotNull(encryptedElement);
         assertEquals(WSConstants.ENC_NS, encryptedElement.getNamespaceURI());
     }
-    
+
     @org.junit.Test
     public void testOptionalSOAPHeaderPresent() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
@@ -149,7 +149,7 @@ public class EncryptionPartsTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "foobar",
@@ -158,25 +158,25 @@ public class EncryptionPartsTest extends
         encP.setRequired(false);
         encrypt.getParts().add(encP);
         String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
-        encP = 
+        encP =
             new WSEncryptionPart(
-                WSConstants.ELEM_BODY, 
-                soapNamespace, 
+                WSConstants.ELEM_BODY,
+                soapNamespace,
                 "Content"
             );
         encrypt.getParts().add(encP);
-        
+
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(encryptedDoc);
     }
-    
+
     @org.junit.Test
     public void testOptionalSOAPHeaderNotPresent() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
@@ -186,7 +186,7 @@ public class EncryptionPartsTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "foobar",
@@ -195,25 +195,25 @@ public class EncryptionPartsTest extends
         encP.setRequired(false);
         encrypt.getParts().add(encP);
         String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
-        encP = 
+        encP =
             new WSEncryptionPart(
-                WSConstants.ELEM_BODY, 
-                soapNamespace, 
+                WSConstants.ELEM_BODY,
+                soapNamespace,
                 "Content"
             );
         encrypt.getParts().add(encP);
-        
+
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         verify(encryptedDoc);
     }
-    
+
     @org.junit.Test
     public void testRequiredSOAPHeaderNotPresent() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
@@ -223,7 +223,7 @@ public class EncryptionPartsTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "foobar",
@@ -231,23 +231,23 @@ public class EncryptionPartsTest extends
                 "");
         encrypt.getParts().add(encP);
         String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
-        encP = 
+        encP =
             new WSEncryptionPart(
-                WSConstants.ELEM_BODY, 
-                soapNamespace, 
+                WSConstants.ELEM_BODY,
+                soapNamespace,
                 "Content"
             );
         encrypt.getParts().add(encP);
-        
+
         try {
             encrypt.build(doc, crypto, secHeader);
             fail("Failure expected on not encrypting a required element");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE);
         }
     }
-    
-    
+
+
     /**
      * Test encrypting a custom SOAP header using wsse11:EncryptedHeader
      */
@@ -261,41 +261,41 @@ public class EncryptionPartsTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "foobar",
                 "urn:foo.bar",
                 "Header");
         encrypt.getParts().add(encP);
-        
+
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
         assertTrue(outputString.contains("wsse11:EncryptedHeader"));
         assertFalse(outputString.contains("foo:foobar"));
-        
+
         WSHandlerResult results = verify(encryptedDoc);
-        
+
         WSSecurityEngineResult actionResult =
                 results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
         assertFalse(actionResult.isEmpty());
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-        
-        assertEquals(WSConstants.KEYTRANSPORT_RSAOEP, 
+
+        assertEquals(WSConstants.KEYTRANSPORT_RSAOEP,
                 actionResult.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_TRANSPORT_METHOD));
-        
+
         WSDataRef wsDataRef = refs.get(0);
         String xpath = wsDataRef.getXpath();
         assertEquals("/soapenv:Envelope/soapenv:Header/foo:foobar", xpath);
     }
-    
+
     /**
      * Test encrypting a custom SOAP header using wsse11:EncryptedHeader
      */
@@ -357,23 +357,23 @@ public class EncryptionPartsTest extends
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "foobar2",
                 "urn:foo.bar",
                 "");
         encrypt.getParts().add(encP);
-        
+
         try {
             encrypt.build(doc, crypto, secHeader);
             fail("Failure expected on a bad localname");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE);
         }
     }
-    
-    
+
+
     /**
      * Test encrypting a custom SOAP header with a bad namespace
      */
@@ -387,30 +387,30 @@ public class EncryptionPartsTest extends
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "foobar",
                 "urn:foo.bar2",
                 "");
         encrypt.getParts().add(encP);
-        
+
         try {
             encrypt.build(doc, crypto, secHeader);
             fail("Failure expected on a bad namespace");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILURE);
         }
     }
-    
-    
+
+
     /**
      * Test encrypting a custom SOAP header and the SOAP body
      */
     @org.junit.Test
     public void testSOAPHeaderAndBody() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        SOAPConstants soapConstants = 
+        SOAPConstants soapConstants =
             WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -418,7 +418,7 @@ public class EncryptionPartsTest extends
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 soapConstants.getBodyQName().getLocalPart(),    // define the body
@@ -431,31 +431,31 @@ public class EncryptionPartsTest extends
                 "urn:foo.bar",
                 "");
         encrypt.getParts().add(encP2);
-        
+
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         WSHandlerResult results = verify(encryptedDoc);
-        
+
         QName fooName = new QName("urn:foo.bar", "foobar");
         QName bodyName = new QName(soapConstants.getEnvelopeURI(), "Body");
         QName headerName = new QName(soapConstants.getEnvelopeURI(), "Header");
-        
-        WSSecurityEngineResult actionResult = 
+
+        WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
         assertFalse(actionResult.isEmpty());
-        
+
         @SuppressWarnings("unchecked")
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
         assertTrue(refs != null && !refs.isEmpty());
-        
+
         boolean foundFoo = false;
         boolean foundBody = false;
         boolean foundHeader = false;
@@ -471,15 +471,15 @@ public class EncryptionPartsTest extends
         assertTrue(foundFoo && foundBody);
         assertFalse(foundHeader);
     }
-    
-    
+
+
     /**
      * Test getting a DOM Element from WSEncryptionPart directly
      */
     @org.junit.Test
     public void testEncryptionPartDOMElement() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        SOAPConstants soapConstants = 
+        SOAPConstants soapConstants =
             WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -487,7 +487,7 @@ public class EncryptionPartsTest extends
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         // Give wrong names to make sure it's picking up the element
         WSEncryptionPart encP =
             new WSEncryptionPart(
@@ -498,30 +498,30 @@ public class EncryptionPartsTest extends
         assertTrue(bodyElement != null && "Body".equals(bodyElement.getLocalName()));
         encP.setElement(bodyElement);
         encrypt.getParts().add(encP);
-        
+
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
         assertTrue (!outputString.contains("testMethod"));
         WSHandlerResult results = verify(encryptedDoc);
-        
-        WSSecurityEngineResult actionResult = 
+
+        WSSecurityEngineResult actionResult =
             results.getActionResults().get(WSConstants.ENCR).get(0);
         assertTrue(actionResult != null);
         assertFalse(actionResult.isEmpty());
         @SuppressWarnings("unchecked")
         final List<WSDataRef> refs =
             (List<WSDataRef>) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-        
+
         WSDataRef wsDataRef = refs.get(0);
         QName bodyName = new QName(soapConstants.getEnvelopeURI(), "Body");
         assertEquals(bodyName, wsDataRef.getName());
     }
-    
+
     /**
      * Test encrypting two SOAP Body elements with the same QName.
      */
@@ -534,45 +534,45 @@ public class EncryptionPartsTest extends
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "testMethod",
                 "http://axis/service/security/test6/LogTestService8",
                 "");
         encrypt.getParts().add(encP);
-        
+
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
         assertFalse(outputString.contains("testMethod"));
-        
+
         verify(encryptedDoc);
-        
-        outputString = 
+
+        outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         assertTrue(outputString.contains("asf1"));
         assertTrue(outputString.contains("asf2"));
     }
-    
+
 
     /**
      * 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, callbackHandler, null, crypto);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Verified 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/EncryptionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java Tue Dec 15 16:40:37 2015
@@ -59,7 +59,7 @@ import org.w3c.dom.Element;
  * A set of test-cases for encrypting and decrypting SOAP requests.
  */
 public class EncryptionTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(EncryptionTest.class);
     private static final javax.xml.namespace.QName SOAP_BODY =
         new javax.xml.namespace.QName(
@@ -73,19 +73,19 @@ public class EncryptionTest extends org.
     private byte[] keyData;
     private SecretKey key;
     private Crypto crypto = null;
-    
+
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
     }
-    
+
     public EncryptionTest() throws Exception {
         crypto = CryptoFactory.getInstance("wss40.properties");
     }
-    
+
     /**
      * Setup method
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is a problem in setup
      */
     @org.junit.Before
@@ -102,7 +102,7 @@ public class EncryptionTest extends org.
      * This test uses the RSA_15 algorithm to transport (wrap) the symmetric
      * key.
      * <p/>
-     * 
+     *
      * @throws Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -118,7 +118,7 @@ public class EncryptionTest extends org.
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
         LOG.info("After Encryption Triple DES....");
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message, RSA-15 keytransport, 3DES:");
@@ -129,28 +129,28 @@ public class EncryptionTest extends org.
         builder.getParts().clear();
 
         /*
-         * second run, same Junit set up, but change encryption method, 
+         * second run, same Junit set up, but change encryption method,
          * key identification, encryption mode (Element now), and data to encrypt.
-         * This tests if several runs of different algorithms on same builder/cipher 
+         * This tests if several runs of different algorithms on same builder/cipher
          * setup are ok.
          */
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         builder.setSymmetricEncAlgorithm(WSConstants.AES_128);
         builder.setSymmetricKey(null);
-        
-        WSEncryptionPart encP = 
+
+        WSEncryptionPart encP =
             new WSEncryptionPart(
                 "add", "http://ws.apache.org/counter/counter_port_type", "Element"
             );
         builder.getParts().add(encP);
-        
+
         doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();        
+        secHeader.insertSecurityHeader();
         LOG.info("Before Encryption AES 128/RSA-15....");
         encryptedDoc = builder.build(doc, crypto, secHeader);
         LOG.info("After Encryption AES 128/RSA-15....");
-        outputString = 
+        outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message, RSA-15 keytransport, AES 128:");
@@ -165,12 +165,12 @@ public class EncryptionTest extends org.
                 "add"
             )
         );
-        
+
         WSSecurityEngineResult actionResult =
                 results.getActionResults().get(WSConstants.ENCR).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);
     }
@@ -180,7 +180,7 @@ public class EncryptionTest extends org.
      * This test uses the RSA OAEP algorithm to transport (wrap) the symmetric
      * key.
      * <p/>
-     * 
+     *
      * @throws Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -191,36 +191,36 @@ public class EncryptionTest extends org.
         builder.setKeyEncAlgo(WSConstants.KEYTRANSPORT_RSAOEP);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();        
+        secHeader.insertSecurityHeader();
         LOG.info("Before Encryption Triple DES/RSA-OAEP....");
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
         LOG.info("After Encryption Triple DES/RSA-OAEP....");
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
             LOG.debug(outputString);
         }
         assertFalse(outputString.contains("counter_port_type"));
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
-        WSHandlerResult results = 
+        WSHandlerResult results =
             newEngine.processSecurityHeader(encryptedDoc, null, keystoreCallbackHandler, crypto);
-        
+
         WSSecurityEngineResult actionResult =
                 results.getActionResults().get(WSConstants.ENCR).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 encrypt and then again encrypts (Super encryption) WS-Security
      * envelope and then verifies it <p/>
-     * 
+     *
      * @throws Exception
      *             Thrown when there is any problem in encryption or
      *             verification
@@ -236,19 +236,19 @@ public class EncryptionTest extends org.
         secHeader.insertSecurityHeader();
 
         Document encryptedDoc = encrypt.build(doc, encCrypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("After the first encryption:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedDoc);
             LOG.debug(outputString);
         }
-        
+
         Document encryptedEncryptedDoc = encrypt.build(encryptedDoc, encCrypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("After the second encryption:");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(encryptedEncryptedDoc);
             LOG.debug(outputString);
         }
@@ -256,12 +256,12 @@ public class EncryptionTest extends org.
         LOG.info("After Encryption....");
         verify(encryptedEncryptedDoc, encCrypto, keystoreCallbackHandler);
     }
-    
+
     /**
      * Test that encrypts and decrypts 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 encryption or decryption
      */
     @org.junit.Test
@@ -270,38 +270,38 @@ public class EncryptionTest extends org.
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
-        
+
         LOG.info("Before Encrypting ThumbprintSHA1....");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();        
+        secHeader.insertSecurityHeader();
         Document encryptedDoc = builder.build(doc, encCrypto, secHeader);
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message with THUMBPRINT_IDENTIFIER:");
             LOG.debug(outputString);
         }
         assertTrue(outputString.contains("#ThumbprintSHA1"));
-    
+
         LOG.info("After Encrypting ThumbprintSHA1....");
         WSHandlerResult results = verify(encryptedDoc, encCrypto, keystoreCallbackHandler);
-        
+
         WSSecurityEngineResult actionResult =
                 results.getActionResults().get(WSConstants.ENCR).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 encrypts and decrypts a WS-Security envelope.
-     * The test uses the EncryptedKeySHA1 key identifier type. 
+     * The test uses the EncryptedKeySHA1 key identifier type.
      * <p/>
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
      */
     @org.junit.Test
@@ -310,29 +310,29 @@ public class EncryptionTest extends org.
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
-     
+
         LOG.info("Before Encrypting EncryptedKeySHA1....");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();        
+        secHeader.insertSecurityHeader();
         Document encryptedDoc = builder.build(doc, encCrypto, secHeader);
-     
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message with ENCRYPTED_KEY_SHA1_IDENTIFIER:");
             LOG.debug(outputString);
         }
         assertTrue(outputString.contains("#EncryptedKeySHA1"));
-     
+
         LOG.info("After Encrypting EncryptedKeySHA1....");
         verify(encryptedDoc, encCrypto, keystoreCallbackHandler);
     }
-    
+
     /**
-     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key, rather than a 
+     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key, rather than a
      * generated session key which is then encrypted using a public key.
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
      */
     @org.junit.Test
@@ -341,33 +341,33 @@ public class EncryptionTest extends org.
         builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
         builder.setSymmetricKey(key);
         builder.setEncryptSymmKey(false);
-        
+
         LOG.info("Before Encrypting EncryptedKeySHA1....");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
-        
+
         byte[] encodedBytes = KeyUtils.generateDigest(keyData);
         String identifier = Base64.encode(encodedBytes);
         secretKeyCallbackHandler.addSecretKey(identifier, keyData);
-     
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message with ENCRYPTED_KEY_SHA1_IDENTIFIER:");
             LOG.debug(outputString);
         }
         assertTrue(outputString.contains("#EncryptedKeySHA1"));
-     
+
         LOG.info("After Encrypting EncryptedKeySHA1....");
         verify(encryptedDoc, null, secretKeyCallbackHandler);
     }
-    
+
     /**
-     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key (bytes), 
+     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key (bytes),
      * rather than a generated session key which is then encrypted using a public key.
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
      */
     @org.junit.Test
@@ -376,35 +376,35 @@ public class EncryptionTest extends org.
         builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
         builder.setEphemeralKey(keyData);
         builder.setEncryptSymmKey(false);
-        
+
         LOG.info("Before Encrypting EncryptedKeySHA1....");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();        
+        secHeader.insertSecurityHeader();
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
-        
+
         byte[] encodedBytes = KeyUtils.generateDigest(keyData);
         String identifier = Base64.encode(encodedBytes);
         secretKeyCallbackHandler.addSecretKey(identifier, keyData);
-     
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message with ENCRYPTED_KEY_SHA1_IDENTIFIER:");
             LOG.debug(outputString);
         }
         assertTrue(outputString.contains("#EncryptedKeySHA1"));
-     
+
         LOG.info("After Encrypting EncryptedKeySHA1....");
         verify(encryptedDoc, crypto, secretKeyCallbackHandler);
     }
-    
-    
+
+
     /**
-     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key, rather than a 
+     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key, rather than a
      * generated session key which is then encrypted using a public key. The request is generated
      * using WSHandler, instead of coding it.
-     * 
+     *
      * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
      */
     @org.junit.Test
@@ -419,35 +419,35 @@ public class EncryptionTest extends org.
         messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, secretKeyCallbackHandler);
         reqData.setMsgContext(messageContext);
         reqData.setUsername("");
-        
+
         final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         CustomHandler handler = new CustomHandler();
         HandlerAction action = new HandlerAction(WSConstants.ENCR);
         handler.send(
-            doc, 
-            reqData, 
+            doc,
+            reqData,
             Collections.singletonList(action),
             true
         );
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         verify(doc, null, secretKeyCallbackHandler);
     }
-    
+
     /**
      * Test that encrypt and decrypt a WS-Security envelope.
-     * 
+     *
      * This test uses the RSA_15 algorithm to transport (wrap) the symmetric key.
      * The test case creates a ReferenceList element that references EncryptedData
      * elements. The ReferencesList element is put into the Security header, not
      * as child of the EncryptedKey. The EncryptedData elements contain a KeyInfo
      * that references the EncryptedKey via a STR/Reference structure.
-     * 
+     *
      * Refer to OASIS WS Security spec 1.1, chap 7.7
      */
     @org.junit.Test
@@ -496,7 +496,7 @@ public class EncryptionTest extends org.
         Document encryptedDoc = doc;
         LOG.info("After Encryption Triple DES....");
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message, RSA-15 keytransport, 3DES:");
@@ -504,21 +504,21 @@ public class EncryptionTest extends org.
         }
         assertFalse(outputString.contains("counter_port_type"));
         WSHandlerResult results = verify(encryptedDoc, crypto, keystoreCallbackHandler);
-        
-        outputString = 
+
+        outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         assertTrue(outputString.contains("counter_port_type"));
-        
+
         WSSecurityEngineResult actionResult =
                 results.getActionResults().get(WSConstants.ENCR).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);
     }
-    
-    
+
+
     @org.junit.Test
     public void testBadAttribute() throws Exception {
         WSSecEncrypt builder = new WSSecEncrypt();
@@ -566,7 +566,7 @@ public class EncryptionTest extends org.
 
         Document encryptedDoc = doc;
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
@@ -579,14 +579,14 @@ public class EncryptionTest extends org.
         } catch (WSSecurityException ex) {
             assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
-        
+
         RequestData data = new RequestData();
         data.setCallbackHandler(keystoreCallbackHandler);
         data.setDecCrypto(crypto);
         data.setIgnoredBSPRules(Collections.singletonList(BSPRule.R3209));
         newEngine.processSecurityHeader(encryptedDoc, data);
     }
-    
+
     /**
      * In this test an EncryptedKey structure is embedded in the EncryptedData structure.
      * The EncryptedKey structure refers to a certificate via the SKI_KEY_IDENTIFIER.
@@ -594,7 +594,7 @@ public class EncryptionTest extends org.
     @org.junit.Test
     public void testEmbeddedEncryptedKey() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        
+
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
@@ -612,12 +612,12 @@ public class EncryptionTest extends org.
 
         builder.encrypt();
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         verify(doc, crypto, keystoreCallbackHandler);
     }
 
@@ -626,7 +626,7 @@ public class EncryptionTest extends org.
      * This test uses the RSA OAEP algorithm to transport (wrap) the symmetric
      * key and SHA-256.
      * <p/>
-     * 
+     *
      * @throws Exception Thrown when there is any problem in signing or verification
      */
     @org.junit.Test
@@ -637,28 +637,28 @@ public class EncryptionTest extends org.
         builder.setDigestAlgorithm(WSConstants.SHA256);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();        
+        secHeader.insertSecurityHeader();
         LOG.info("Before Encryption Triple DES/RSA-OAEP....");
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
         LOG.info("After Encryption Triple DES/RSA-OAEP....");
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
             LOG.debug(outputString);
         }
         assertFalse(outputString.contains("counter_port_type"));
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
-        WSHandlerResult results = 
+        WSHandlerResult results =
             newEngine.processSecurityHeader(encryptedDoc, null, keystoreCallbackHandler, crypto);
-        
+
         WSSecurityEngineResult actionResult =
                 results.getActionResults().get(WSConstants.ENCR).get(0);
         assertNotNull(actionResult);
     }
-    
+
     // CN has a "*" in it
     @org.junit.Test
     public void testEncryptionWithRegexpCert() throws Exception {
@@ -668,28 +668,28 @@ public class EncryptionTest extends org.
         builder.setKeyEncAlgo(WSConstants.KEYTRANSPORT_RSAOEP);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();        
+        secHeader.insertSecurityHeader();
         LOG.info("Before Encryption Triple DES/RSA-OAEP....");
-        
+
         Crypto regexpCrypto = CryptoFactory.getInstance("regexp.properties");
         Document encryptedDoc = builder.build(doc, regexpCrypto, secHeader);
         LOG.info("After Encryption Triple DES/RSA-OAEP....");
 
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
             LOG.debug(outputString);
         }
         assertFalse(outputString.contains("counter_port_type"));
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
         newEngine.processSecurityHeader(encryptedDoc, null, keystoreCallbackHandler, regexpCrypto);
     }
-    
+
     /**
      * Verifies the soap envelope <p/>
-     * 
+     *
      * @param envelope
      * @throws Exception
      *             Thrown when there is a problem in verification
@@ -697,21 +697,21 @@ public class EncryptionTest extends org.
     private WSHandlerResult verify(
         Document doc, Crypto decCrypto, CallbackHandler handler
     ) throws Exception {
-        WSHandlerResult results = 
+        WSHandlerResult results =
             secEngine.processSecurityHeader(doc, null, handler, decCrypto);
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
         return results;
     }
-    
+
     /**
      * Verifies the soap envelope
      * <p/>
-     * 
-     * @param envelope 
+     *
+     * @param envelope
      * @throws Exception Thrown when there is a problem in verification
      */
     @SuppressWarnings("unchecked")
@@ -720,9 +720,9 @@ public class EncryptionTest extends org.
         CallbackHandler handler,
         javax.xml.namespace.QName expectedEncryptedElement
     ) throws Exception {
-        final WSHandlerResult results = 
+        final WSHandlerResult results =
             secEngine.processSecurityHeader(doc, null, handler, null, crypto);
-        String outputString = 
+        String outputString =
             XMLUtils.PrettyDocumentToString(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
@@ -730,11 +730,11 @@ public class EncryptionTest extends org.
         assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
         //
         // walk through the results, and make sure there is an encryption
-        // action, together with a reference to the decrypted element 
+        // action, together with a reference to the decrypted element
         // (as a QName)
         //
         boolean encrypted = false;
-        for (java.util.Iterator<WSSecurityEngineResult> ipos = results.getResults().iterator(); 
+        for (java.util.Iterator<WSSecurityEngineResult> ipos = results.getResults().iterator();
             ipos.hasNext();) {
             final WSSecurityEngineResult result = ipos.next();
             final Integer action = (Integer) result.get(WSSecurityEngineResult.TAG_ACTION);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java Tue Dec 15 16:40:37 2015
@@ -56,30 +56,30 @@ import org.w3c.dom.Node;
  * This class tests the modification of requests.
  */
 public class ModifiedRequestTest extends org.junit.Assert {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(ModifiedRequestTest.class);
-    private static final String SOAPMSG = 
-        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
+    private static final String SOAPMSG =
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
         + "<SOAP-ENV:Envelope "
         +   "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
         +   "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
-        +   "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" 
-        +   "<SOAP-ENV:Body>" 
-        +       "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">" 
-        +           "<value xmlns=\"http://blah.com\">15</value>" 
-        +       "</add>" 
-        +   "</SOAP-ENV:Body>" 
+        +   "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+        +   "<SOAP-ENV:Body>"
+        +       "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
+        +           "<value xmlns=\"http://blah.com\">15</value>"
+        +       "</add>"
+        +   "</SOAP-ENV:Body>"
         + "</SOAP-ENV:Envelope>";
-    
+
     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 ModifiedRequestTest() throws Exception {
         WSSConfig.init();
         crypto = CryptoFactory.getInstance();
@@ -99,35 +99,35 @@ public class ModifiedRequestTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "value",
                 "http://blah.com",
                 "");
         builder.getParts().add(encP);
-        
+
         Document signedDoc = builder.build(doc, crypto, secHeader);
-        
+
         //
         // Replace the signed element with a modified element, and move the original
         // signed element into the SOAP header
         //
         Element secHeaderElement = secHeader.getSecurityHeader();
         Element envelopeElement = signedDoc.getDocumentElement();
-        Node valueNode = 
+        Node valueNode =
             envelopeElement.getElementsByTagNameNS("http://blah.com", "value").item(0);
         Node clonedValueNode = valueNode.cloneNode(true);
         secHeaderElement.appendChild(clonedValueNode);
         valueNode.getFirstChild().setNodeValue("250");
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(signedDoc);
             fail("Failure expected on multiple elements with the same wsu:Id");
@@ -137,8 +137,8 @@ public class ModifiedRequestTest extends
                     "org.apache.xml.security.utils.resolver.ResourceResolverException: "));
         }
     }
-    
-    
+
+
     /**
      * Test that signs a SOAP body element "value". The SOAP request is then modified
      * so that the signed "value" element is put in the header, and the value of the
@@ -153,23 +153,23 @@ public class ModifiedRequestTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "value",
                 "http://blah.com",
                 "");
         builder.getParts().add(encP);
-        
+
         Document signedDoc = builder.build(doc, crypto, secHeader);
-        
+
         //
         // Replace the signed element with a modified element, and move the original
         // signed element into the SOAP header
         //
         Element secHeaderElement = secHeader.getSecurityHeader();
         Element envelopeElement = signedDoc.getDocumentElement();
-        Node valueNode = 
+        Node valueNode =
             envelopeElement.getElementsByTagNameNS("http://blah.com", "value").item(0);
         Node clonedValueNode = valueNode.cloneNode(true);
         secHeaderElement.appendChild(clonedValueNode);
@@ -177,33 +177,33 @@ public class ModifiedRequestTest extends
         ((Element)valueNode).setAttributeNS(
              WSConstants.WSU_NS, "wsu:Id", "id-250"
         );
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         //
         // Check the signature...this should pass
         //
         WSHandlerResult results = verify(signedDoc);
-        
+
         //
         // Finally we need to check that the Element that was signed is what we expect to be signed
         //
         envelopeElement = signedDoc.getDocumentElement();
-        Node bodyNode = 
+        Node bodyNode =
             envelopeElement.getElementsByTagNameNS(
                 WSConstants.URI_SOAP11_ENV, "Body"
             ).item(0);
-        valueNode = 
+        valueNode =
             ((Element)bodyNode).getElementsByTagNameNS(
                 "http://blah.com", "value"
             ).item(0);
-        
-        List<WSSecurityEngineResult> signedResults = 
+
+        List<WSSecurityEngineResult> signedResults =
             results.getActionResults().get(WSConstants.SIGN);
         try {
             WSSecurityUtil.verifySignedElement((Element)valueNode, signedResults);
@@ -212,7 +212,7 @@ public class ModifiedRequestTest extends
             assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILED_CHECK);
         }
     }
-    
+
     /**
      * Test a duplicated signed SAML Assertion.
      */
@@ -222,19 +222,19 @@ public class ModifiedRequestTest extends
         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);
-        
+
         WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
-        Document signedDoc = 
+
+        Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
                 "security", secHeader
@@ -245,11 +245,11 @@ public class ModifiedRequestTest extends
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1.1 Authn Assertion (sender vouches):");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(signedDoc);
             fail("Failure expected on duplicate tokens");
@@ -259,7 +259,7 @@ public class ModifiedRequestTest extends
             ));
         }
     }
-    
+
     /**
      * Test a duplicated signed UsernameToken
      */
@@ -268,39 +268,39 @@ public class ModifiedRequestTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         WSSecUsernameToken usernameToken = new WSSecUsernameToken();
         usernameToken.setUserInfo("wss86", "security");
         Document createdDoc = usernameToken.build(doc, secHeader);
-        
+
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "UsernameToken",
                 WSConstants.WSSE_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);
-        
+
         secHeader.getSecurityHeader().appendChild(
             usernameToken.getUsernameTokenElement().cloneNode(true)
         );
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed Timestamp");
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(doc);
             fail("Failure expected on duplicate tokens");
@@ -310,7 +310,7 @@ public class ModifiedRequestTest extends
             ));
         }
     }
-    
+
     /**
      * Test for when an EncryptedData structure is modified
      */
@@ -327,25 +327,25 @@ public class ModifiedRequestTest extends
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
         Element body = WSSecurityUtil.findBodyElement(doc);
-        Element encryptionMethod = 
+        Element encryptionMethod =
             XMLUtils.findElement(body, "EncryptionMethod", WSConstants.ENC_NS);
         encryptionMethod.setAttributeNS(null, "Algorithm", "http://new-algorithm");
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
         try {
             newEngine.processSecurityHeader(doc, null, new KeystoreCallbackHandler(), wssCrypto);
             fail("Failure expected on a modified EncryptedData structure");
         } catch (WSSecurityException ex) {
-            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY); 
+            assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
         }
     }
-    
+
     /**
      * Test for when some EncryptedData CipherValue data is modified.
      */
@@ -362,10 +362,10 @@ public class ModifiedRequestTest extends
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
         Element body = WSSecurityUtil.findBodyElement(doc);
-        Element cipherValue = 
+        Element cipherValue =
             XMLUtils.findElement(body, "CipherValue", WSConstants.ENC_NS);
         String cipherText = cipherValue.getTextContent();
-        
+
         StringBuilder stringBuilder = new StringBuilder(cipherText);
         int index = stringBuilder.length() / 2;
         char ch = stringBuilder.charAt(index);
@@ -376,13 +376,13 @@ public class ModifiedRequestTest extends
         }
         stringBuilder.setCharAt(index, ch);
         cipherValue.setTextContent(stringBuilder.toString());
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
         try {
             newEngine.processSecurityHeader(doc, null, new KeystoreCallbackHandler(), wssCrypto);
@@ -391,9 +391,9 @@ public class ModifiedRequestTest extends
             assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILED_CHECK);
         }
     }
-    
+
     /**
-     * Test for when some EncryptedData CipherValue data is modified 
+     * Test for when some EncryptedData CipherValue data is modified
      * (in the security header)
      */
     @org.junit.Test
@@ -402,33 +402,33 @@ public class ModifiedRequestTest extends
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-        
+
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
-        
+
         WSSecTimestamp timestamp = new WSSecTimestamp();
         timestamp.setTimeToLive(300);
         timestamp.build(doc, secHeader);
-        
+
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 "Timestamp",
                 WSConstants.WSU_NS,
                 "");
         builder.getParts().add(encP);
-        
+
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
-        Element securityHeader = 
+        Element securityHeader =
             WSSecurityUtil.getSecurityHeader(encryptedDoc, "");
-        Element encryptedTimestamp = 
+        Element encryptedTimestamp =
             XMLUtils.findElement(securityHeader, "EncryptedData", WSConstants.ENC_NS);
-        Element cipherValue = 
+        Element cipherValue =
             XMLUtils.findElement(encryptedTimestamp, "CipherValue", WSConstants.ENC_NS);
         String cipherText = cipherValue.getTextContent();
-        
+
         StringBuilder stringBuilder = new StringBuilder(cipherText);
         int index = stringBuilder.length() / 2;
         char ch = stringBuilder.charAt(index);
@@ -439,13 +439,13 @@ public class ModifiedRequestTest extends
         }
         stringBuilder.setCharAt(index, ch);
         cipherValue.setTextContent(stringBuilder.toString());
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
         try {
             newEngine.processSecurityHeader(doc, null, new KeystoreCallbackHandler(), wssCrypto);
@@ -454,7 +454,7 @@ public class ModifiedRequestTest extends
             assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILED_CHECK);
         }
     }
-    
+
     /**
      * Test for when some EncryptedKey CipherValue data is modified.
      */
@@ -470,12 +470,12 @@ public class ModifiedRequestTest extends
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
         Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
 
-        Element encryptedKey = 
+        Element encryptedKey =
             XMLUtils.findElement(doc.getDocumentElement(), "EncryptedKey", WSConstants.ENC_NS);
-        Element cipherValue = 
+        Element cipherValue =
             XMLUtils.findElement(encryptedKey, "CipherValue", WSConstants.ENC_NS);
         String cipherText = cipherValue.getTextContent();
-        
+
         StringBuilder stringBuilder = new StringBuilder(cipherText);
         int index = stringBuilder.length() / 2;
         char ch = stringBuilder.charAt(index);
@@ -486,13 +486,13 @@ public class ModifiedRequestTest extends
         }
         stringBuilder.setCharAt(index, ch);
         cipherValue.setTextContent(stringBuilder.toString());
-        
-        String outputString = 
+
+        String outputString =
             XMLUtils.PrettyDocumentToString(encryptedDoc);
         if (LOG.isDebugEnabled()) {
             LOG.debug(outputString);
         }
-        
+
         WSSecurityEngine newEngine = new WSSecurityEngine();
         try {
             newEngine.processSecurityHeader(doc, null, new KeystoreCallbackHandler(), wssCrypto);
@@ -503,7 +503,7 @@ public class ModifiedRequestTest extends
     }
 
 
-    
+
     /**
      * Test for when an element that a Signature Reference points to is modified
      */
@@ -514,40 +514,40 @@ public class ModifiedRequestTest extends
         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);
-        
+
         // Modify the Created text of the Timestamp element
         Element timestampElement = timestamp.getElement();
-        Element createdValue = 
+        Element createdValue =
             XMLUtils.findElement(timestampElement, "Created", WSConstants.WSU_NS);
         DateFormat zulu = new XmlSchemaDateFormat();
-        
-        XMLGregorianCalendar createdCalendar = 
+
+        XMLGregorianCalendar createdCalendar =
             WSSConfig.datatypeFactory.newXMLGregorianCalendar(createdValue.getTextContent());
         // Add 5 seconds
         Duration duration = WSSConfig.datatypeFactory.newDuration(5000L);
         createdCalendar.add(duration);
         Date createdDate = createdCalendar.toGregorianCalendar().getTime();
         createdValue.setTextContent(zulu.format(createdDate));
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(signedDoc);
             fail("Failure expected on a modified Signature Reference");
@@ -555,7 +555,7 @@ public class ModifiedRequestTest extends
             assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILED_CHECK);
         }
     }
-    
+
     /**
      * Test for when a Signature is received with a certificate that is not trusted
      */
@@ -566,16 +566,16 @@ public class ModifiedRequestTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Crypto wss40Crypto = CryptoFactory.getInstance("wss40.properties");
         Document signedDoc = builder.build(doc, wss40Crypto, secHeader);
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(signedDoc);
             fail("Failure expected on an untrusted Certificate");
@@ -583,7 +583,7 @@ public class ModifiedRequestTest extends
             assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.FAILED_CHECK);
         }
     }
-    
+
     /**
      * Test for when the Signature element is modified
      */
@@ -594,9 +594,9 @@ public class ModifiedRequestTest extends
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        
+
         Document signedDoc = builder.build(doc, crypto, secHeader);
-        
+
         // Modify the Signature element
         Element signatureElement = builder.getSignatureElement();
         Node firstChild = signatureElement.getFirstChild();
@@ -604,13 +604,13 @@ public class ModifiedRequestTest extends
             firstChild = signatureElement.getNextSibling();
         }
         ((Element)firstChild).setAttributeNS(null, "Id", "xyz");
-        
+
         if (LOG.isDebugEnabled()) {
-            String outputString = 
+            String outputString =
                 XMLUtils.PrettyDocumentToString(signedDoc);
             LOG.debug(outputString);
         }
-        
+
         try {
             verify(signedDoc);
             fail("Failure expected on a modified Signature element");
@@ -622,7 +622,7 @@ public class ModifiedRequestTest extends
     /**
      * Verifies the soap envelope
      * <p/>
-     * 
+     *
      * @param doc soap envelope
      * @throws java.lang.Exception Thrown when there is a problem in verification
      */



Mime
View raw message