You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2007/07/27 15:43:32 UTC

svn commit: r560227 - /xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java

Author: mullan
Date: Fri Jul 27 06:43:31 2007
New Revision: 560227

URL: http://svn.apache.org/viewvc?view=rev&rev=560227
Log:
Add test case for testing null type parameter to XMLCipher.encryptData that
takes serialized data (see bug 38668).

Modified:
    xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java

Modified: xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java?view=diff&rev=560227&r1=560226&r2=560227
==============================================================================
--- xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java (original)
+++ xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java Fri Jul 27 06:43:31 2007
@@ -689,19 +689,24 @@
         baos.close();
         String before = baos.toString("UTF-8");
 
+	byte[] serialized = baos.toByteArray();
         EncryptedData encryptedData = cipher.encryptData
             (d, EncryptionConstants.TYPE_ELEMENT,
-             new ByteArrayInputStream(baos.toByteArray()));
+             new ByteArrayInputStream(serialized));
 
         //decrypt
-        cipher = XMLCipher.getInstance(XMLCipher.AES_128);
-        cipher.init(XMLCipher.DECRYPT_MODE, key);
+        XMLCipher dcipher = XMLCipher.getInstance(XMLCipher.AES_128);
+        dcipher.init(XMLCipher.DECRYPT_MODE, key);
         Assert.assertEquals
             (encryptedData.getEncryptionMethod().getAlgorithm(),
              XMLCipher.AES_128);
-        byte[] bytes = cipher.decryptToByteArray(cipher.martial(encryptedData));
+        byte[] bytes = dcipher.decryptToByteArray(dcipher.martial(encryptedData));
         String after = new String(bytes, "UTF-8");
         Assert.assertEquals(before, after);
+
+	// test with null type
+        encryptedData = cipher.encryptData
+            (d, null, new ByteArrayInputStream(serialized));
     }
 
 	private String toString (Node n)