Signing

Use the packaging service to create a PAdES from an LtvSDO

629 views August 4, 2017 November 29, 2017 2

Given one or more LTV SDO’s, you may invoke the packaging service to create a PAdES containing the signed documents.

[TestMethod]
public void How_to_use_the_packaging_service_to_create_a_PAdES_from_an_LtvSdo()
{
	string resultSdoUri = "https://preprod.signicat.com/doc/demo/order/3008201345nxiv5g9tnofl7qqgf56p9kr27gl6gxfjf5jqdwwxx984wj48/task_1/doc_1/sdo";
	using (var client = new PackagingEndPointClient())
	{
		var request = new createpackagerequest
		{
			service = "demo",
			password = "Bond007",
			version = "4",
			packagingmethod = "pades",
			validationpolicy = "ltvsdo-validator",
			Items = new documentid[]
			{
				new documentid
				{
					uridocumentid = resultSdoUri
				}
			},
			sendresulttoarchive = false
		};

		var createPackageResponse = client.createpackage(request);
		string padesDocumentId = createPackageResponse.id;
		string padesDownloadUrl = "https://preprod.signicat.com/doc/demo/sds/" + padesDocumentId;
		// if you set sendresulttoarchive=true, the url must also be updated:
		//string padesDownloadUrl = "https://preprod.signicat.com/doc/demo/archive/" + padesDocumentId;


		Console.WriteLine("documentId=" + padesDocumentId);
		Console.WriteLine(padesDownloadUrl);
		Assert.IsNull(createPackageResponse.error);
		Assert.IsNotNull(padesDocumentId);
	}
}
package com.signicat.signature;

import com.signicat.packaging.v4.*;
import org.junit.Assert;
import org.junit.Test;

import javax.xml.ws.Service;

public class CreatePadesFromLtvSdo {

	@Test
	public void how_to_use_the_packaging_service_to_create_a_PAdES_from_an_LtvSdo() throws Exception {
		String resultSdoUri = "https://preprod.signicat.com/doc/demo/order/3008201345nxiv5g9tnofl7qqgf56p9kr27gl6gxfjf5jqdwwxx984wj48/task_1/doc_1/sdo";

		Service packagingService = new PackagingService();
		PackagingEndPoint client = packagingService.getPort(PackagingEndPoint.class);

		CreatePackageRequest request = new CreatePackageRequest();
		request.setService("demo");
		request.setPassword("Bond007");
		request.setVersion("4");
		request.setPackagingMethod("pades");
		request.setValidationPolicy("ltvsdo-validator");

		DocumentId documentId = new DocumentId();
		documentId.setUriDocumentId(resultSdoUri);
		request.getSdoOrSdoExtended().add(documentId);
		request.setSendResultToArchive(false);

		CreatePackageResponse createPackageResponse = client.createPackage(request);
		String padesDocumentId = createPackageResponse.getId();
		String padesDownloadUrl = "https://preprod.signicat.com/doc/demo/sds/" + padesDocumentId;
		// if you set sendresulttoarchive=true, the url must also be updated:
		//string padesDownloadUrl = "https://preprod.signicat.com/doc/demo/archive/" + padesDocumentId;

		System.out.println("documentId=" + padesDocumentId);
		System.out.println(padesDownloadUrl);
		Assert.assertNull(createPackageResponse.getError());
		Assert.assertNotNull(padesDocumentId);
	}
}

Was this helpful?