Java
Java
Extract XML string from a .p7m byte array (e.g. FATTURA ELETTRONICA, ITALY)
See more Digital Signatures Examples
_LANGUAGE_ example to extract the original XML from a .p7m (Signed-Data PKCS7 Format) provided as a byte array.One use for this example is to extract the original XML from a Fattura Elettronica .p7m signature.
Chilkat Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkFileAccess fac = new CkFileAccess();
CkByteData p7mBytes = new CkByteData();
success = fac.ReadEntireFile("testData/p7m/fattura_signature.p7m",p7mBytes);
if (fac.get_LastMethodSuccess() != true) {
System.out.println(fac.lastErrorText());
return;
}
CkCrypt2 crypt = new CkCrypt2();
String originalXml = crypt.opaqueVerifyString(p7mBytes);
if (crypt.get_LastMethodSuccess() != true) {
System.out.println(fac.lastErrorText());
return;
}
System.out.println("Original XML:");
System.out.println(originalXml);
System.out.println("Success!");
}
}