Safelayer Secure Communications
 
 
Search
Home arrow Try arrow Axis examples arrow XML Decryption


TeleTrust Innovation Price

Innovation Award
for TrustedX 2007

The European ICT Price. Nominee

for TrustedX 2007

Safelayer Labs
 
Try

Axis examples

XML Decryption Print E-mail
22 January 2008

The objective of this example is to decrypt an XML document using the TrustedX decryption service. In order to understand this example, it is recommended that first you understand the previously seen example: XML Encryption.

To try this example, you must download the file called sampleAxis10.zip and follow the instructions in Configuration of the Environment.

The content to be decrypted is the one generated in the XML Encryption example. The downloaded file already contains an encrypted document, but, if you wish, you can replace this document with the one generated in the previous example, to check that it functions correctly.

The method used for decrypting the XML documents is complementary to the encryption method. The decryption request is included inside a DecryptRequest object.

DecryptRequest dr = new DecryptRequest();
dr.setProfile(new URI(PROF_XML_DECRYPT));
UtilTrustedX.addUsernameToken(bindingDe, user, password);

The request includes the data to be decrypted, which must be included in an EnvelopedObject object. In this case, we include the content in XML format.

EnvelopedObject eobj = new EnvelopedObject();
String filecontent = Util.readFile(path_in + encryptedfile);
AnyType any = new AnyType();
MessageElement me = getMessageElementFromString(filecontent);
any.set_any(new MessageElement[]{me});
eobj.setXMLEnvelope(any);
dr.setEnvelopedObject(eobj);

Once all the data have been entered in the request, the decrypt() operation is invoked; this operation sends the request to the host and collects the response in a DecryptResponse object.

DecryptResponse drs = bindingDe.decrypt(dr);

Finally, after executing the example, we obtain a DemoEncryptedDecrypted.xml file with the decrypted content. This can be compared with the content of the file that was encrypted in the XML Encryption example to see if they are, indeed, the same.