Safelayer Secure Communications
 
 
Search
Home arrow Try arrow Axis examples arrow Updating an XML Signature to a Long-Term XML Signature


TeleTrust Innovation Price

Innovation Award
for TrustedX 2007

The European ICT Price. Nominee

for TrustedX 2007

Safelayer Labs
 
Try

Axis examples

Updating an XML Signature to a Long-Term XML Signature Print E-mail
22 January 2008

The objective of this example is to update a signature with a time-stamp in an XML document to a long-term signature format, using the TrustedX verification service.

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

The signature to be updated is the one generated in the XML Signature Generation with Time-Stamp example. The downloaded file already contains a signature to be used for the update, but, if you wish, you can replace this file with the one generated in the previous example, to check that it functions correctly.

To update a signature, we must perform a verification request with a VerifyRequest object, and, unlike the other examples, we must indicate that it is the NONREP (or non-repudiation) and not the verification signature profile that must be used.

VerifyRequest vr = new VerifyRequest();
vr.setProfile(new URI(PROF_NO_REP));

The request must include the signature data, encoded in Base64, in a SignatureObject object.

SignatureObject sobj = new SignatureObject();
Base64Binary b64bin = new Base64Binary();
b64bin.set_value(Util.readBinaryFile(path_in + filename));
sobj.setBase64XMLSignature(b64bin);
vr.setSignatureObject(sobj);

Moreover, the format of the document to be returned and the format of the updated signature (ES-A) will also be indicated. This format allows preservation of the signature for a period of time that is longer than the validity period of the cryptographic material used to generate it. To indicate that we want to update the signature, we must create a ReturnUpdatedSignature object and include the format of the new signature.

OptionalInputs opt = new OptionalInputs();
opt.setReturnBase64XML("");
ReturnUpdatedSignature rus = new ReturnUpdatedSignature();
rus.setType(new URI(SIGN_TYPE_ESA));
opt.setReturnUpdatedSignature(rus);

The setAddCertificateValues(), setAddRevocationValues() and setAddTimeStampValues() method calls have also been added to this request , so that the response will return information about the certificates, the revocation lists and the time-stamps. These method calls are performed from the previously created OptionalInputs object. Furthermore, it is indicated that these parameters must be included in the response in binary format.

AddCertificateValuesType acv = new AddCertificateValuesType();
acv.setBinary(true);
opt.setAddCertificateValues(acv);
AddRevocationValuesType arvt = new AddRevocationValuesType();
acv.setBinary(true);
opt.setAddRevocationValues(arvt);
AddTimeStampValues atsv = new AddTimeStampValues();
atsv.setBinary(true);
opt.setAddTimeStampValues(atsv);
vr.setOptionalInputs(opt);

Once all the data have been entered in the request, the update() operation is invoked; this operation sends the request and obtains a VerifyResponse object.

VerifyResponse vrs = bindingDr.update(vr);

Once the request has been sent, we can check if it has been processed correctly by consulting the response parameters. The functions of the UtilTrustedX auxiliary class are used for this. If all goes well, the signature will be retrieved from the response. The OptionalOutputs object contains the updated signature in an UpdatedSignature object.

if (UtilTrustedXAxis.check(vrs.getResult(), bindingDr)) {								
   byte[] data = vrs.getOptionalOutputs().getUpdatedSignature().getSignatureObject().getBase64XMLSignature().get_value();
   String destFilename = path_out + filename.substring(0, filename.lastIndexOf("."))
         + "Archive.xml";
   Util.writeBinaryFile(destFilename, data);
               
   UtilTrustedXAxis.printResponse(vrs);
   System.out.println("\n\n\n ** SOAP Response ** \n---------------------\n");
   UtilTrustedXAxis.printResponse(bindingDr);
}

After executing the example, we obtain a response, such as the one below, and a file with the signature.

** RESPONSE **
---------------------
Major: urn:oasis:names:tc:dss:1.0:resultmajor:Success
Minor: urn:oasis:names:tc:dss:1.0:resultminor:ValidSignature_OnAllDocuments
DN: CN=trustedx, OU=Demo, O=TrustedX, C=ES
Issuer Trust Level: 0
Issuer Trust Label: Administration

Moreover, in this particular case, once the example has been executed, the content of the response will be shown. Here, we can observe all the additional information that is included, due to it having been specified in the request.