PERMISION NOTICE AND DISCLAIMER This website contains certain downloadable software. This software is copyrighted and the copyrighter claims all exclusive rights to such software. The copyright owner of the software that you download through this site may be indicated in the accompanying read-me file and in the accompanying source code as well as in the area of this Web Site from which the software is downloaded. Permission to use, copy, modify and distribute this software and its source code for non commercial purposes and without fee is hereby granted, provided that the name of the copyright owner or related contributors not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The copyright owner and contributors makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. The copyright owner and its contributors disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author and the contributors be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortuous action, arising out of or in connection with the use or performance of this software. AcceptCancel
Este ejemplo tiene como objetivo descifrar un documento XML mediante el servicio de descifrado de TrustedX. Para la comprensión de este ejemplo, se recomienda haber entendido previamente el ejemplo de Cifrado de XML.
Para poder probar este ejemplo se debe descargar el archivo sampleSW11.zip y seguir las instrucciones que se encuentran en Configuración del entorno.
El contenido a descifrar es el generado en el ejemplo de Cifrado de XML. El archivo descargado ya contiene un documento cifrado, pero si se desea se puede cambiar por el generado en el anterior ejemplo, para comprobar que funciona correctamente.
El mecanismo para el descifrado de documentos XML, es el complementario al de cifrado. La petición de descifrado se incluye dentro de un objeto de tipo SmartDecryptRequest.
Tal y como se ha visto en el resto de ejemplos lo primero es crear el objeto que contendrá la petición, y especificar un perfil, en el caso de los documentos XML y la encriptación este es el perfil de XMLENC.
SmartDecryptRequest sdr = new SmartDecryptRequest(host);
sdr.setProfile(Constants.Profile.XMLENC);
Los datos a cifrar se introducen en este ejemplo codificados en Base64, usando el método setEnvelopeXmlBase64().
sdr.setEnvelopeXmlBase64(Util.readBinaryFileB64(path_in + encryptedfile));
Una vez se han introducido todos los datos en la petición se invoca la operación send() que envía la petición al host y recoge la respuesta en un objeto SmartDecryptResponse.
SmartDecryptResponse sdrs = sdr.send();
Finalmente, después de ejecutar el ejemplo se obtiene un fichero DemoEncryptedDecrypted.xml con el contenido descifrado, que se puede comparar con el contenido del archivo que se ha cifrado en el ejemplo de Cifrado de XML para ver que son iguales.
|