XmlEncryptor - An XML Encryption Demonstrator
Author: Ed Simon
XmlEncryptor demonstrates how to encrypt XML nodes within the DOM.
In this version, the types of nodes that are encrypted are
- whole elements - (the element's tags and its contents)
- element content - just the content of an element
- attribute values - the values of specific attributes
To run XmlEncryptor,
-
Copy the XmlEncryptor.java and
XmlEncryptionTest.xml
files in a folder.
-
Install JCE 1.2.1 (or higher) from "http://java.sun.com"
and the Xerces parser from "http://xml.apache.org".
-
Compile XmlEncryptor.java using the classpath illustrated here:
javac -classpath d:\xerces-1_2_0\xerces.jar;d:\jce1.2.1\lib\jce1_2_1.jar;d:\jce1.2.1\lib\sunjce_provider.jar; XmlEncryptor.java
-
Run the XmlEncryptor program using the classpath illustrated here:
java -cp .;d:\xerces-1_2_0\xerces.jar;d:\jce1.2.1\lib\jce1_2_1.jar;d:\jce1.2.1\lib\sunjce_provider.jar; XmlEncryptor
When run, XmlEncryptor creates two files:
XmlEncryptionTestEncryptedNodes.xml and
XmlEncryptionTestDecryptedNodes.xml.
-
XmlEncryptionTestEncryptedNodes.xml shows the result of encrypting specific nodes in
XmlEncryptionTest.xml
-
XmlEncryptionTestDecryptedNodes.xml is the result of decrypting
XmlEncryptionTestEncryptedNodes.xml's encrypted nodes.
(XmlEncryptionTestDecryptedNodes.xml should be identical to XmlEncryptionTest.xml.)
Please see the source code of XmlEncryptor.java
for descriptions of the coding details.
Note: XmlEncryptor is intended to serve solely as a point of discussion for
the XML Encryption Work Group and will only be added to and maintained
according to the needs of the Work Group.