Topics found on this page:
Set up E-Signing client API
The E-Signing client API communicates with the E-Signing service through XML messages. These are sent using HTTP. All XML messages to E-Signing must be signed with a Nets issued certificate. The E-Signing client API can be used to sign and send all XML messages.
In order to use E-Signing client API, it should first be initialized with required details as listed below:
- PKCS12 file with Nets issued certificate.
- JKS truststore with Nets E-Signing server SSL certificate.
- Communication timeout.
- Environment to connect to (customer test or production).
- MerchantID (issued by Nets for each customer).
- Customer (merchant) name.
Sample code provided below does the initialization (detailed code is available in demo app source files).
MerchantContext merchantContext = new MerchantContext();
merchantContext.setSslKeystorePath("/path_to_file/esigndemoapp.p12");
merchantContext.setSslKeystorePwd("XXXXXX");
merchantContext.setSigningKeystorePath("/path_to_file/esigndemoapp.p12");
merchantContext.setSigningKeystorePwd("XXXXXX");
merchantContext.setTruststorePath("/path_to_file/esigntruststore.jks");
merchantContext.setTruststorePwd("YYYYYY");
merchantContext.setTruststoreType(KeyStoreType.JKS);
merchantContext.setCommTimeout(10000);
//Environment.PRE_PRODUCTION is an enum value, includes Nets E-Signing service URL
merchantContext.setEnv(Environment.PRE_PRODUCTION);
merchantContext.setMerchantId("1587");
merchantContext.setMerchantName("Demo Merchant");
ESigningFactory.INSTANCE.registerMerchantContext(merchantContext);
Create a sign order
A sign order is created when an InsertOrder XML message is sent to Nets E-Signing service. A basic InsertOrder XML message should contain the following (for one document and one signer):
- MerchantID (issued by Nets).
- OrderID, a unique ID to identify the sign order.
Read more about the OrderID.
- Document details, such as:
- Document reference (unique string value to reference the document in the XML message).
- Type, description and title of the document.
- Document bytes in base64 format.
- Signer details, such as:
- Signer name.
- Allowed eIDs.
- Personal ID to identify the signer (for the eID).
- Signer reference (unique string value to reference signer in the XML message).
- Web context details (Read more about web context), such as:
- Exit URL.
- Abort URL.
- Error URL.
- Style URL.
- Sign URL Base
- Execution details (signing workflow rules connecting signer and document)
Sample code for sending an InsertOrder XML message through E-Signing client API to E-Signing is included below (detailed code is available in demo app source files).
The InsertOrder method (refer sample code below) from E-Signing client API creates an XML message with the details provided, signs the XML message and sends it to E-Signing.
ESigningFacade facade = ESigningFactory.INSTANCE.getESigningFacade("Demo Merchant");
InsertOrderRequest request = new InsertOrderRequest();
request.setMerchantID(1587);
request.setMessageID("esigndemoapp-msgid-1");
request.setTime(new Date());
request.setAdditionalInfo("Additional_info");
request.setOrderID("1587-demo-742819356");
Doc document = new Doc();
PDF pdf = new PDF();
pdf.setB64DocumentBytesAsString("Base64_PDF_Bytes");
document.setDocType(pdf);
doc.setDesc("Document description");
doc.setLocalDocRef("document1");
doc.setTitle("Document title");
request.setDocuments(new ArrayList<>(Arrays.asList(document)));
Signer signer = new Signer();
signer.setName("Signer");
//for BankID eID
BankID bankId = new BankID();
SignerID signerId = new SignerID();
signerId.setIdType("SSN");
signerId.setIdValue("12345678912");
signer.setLocalSignerRef("signer1");
signer.setAcceptedPKIs(new ArrayList<>(Arrays.asList(bankId)));
request.setSigners(new ArrayList<>(Arrays.asList(signer)));
WebContext webContext = new WebContext();
webContext.setExitURL("http://localhost:8080/verify?status=completed");
webContext.setAbortURL("http://localhost:8080/verify?status=canceled");
webContext.setErrorURLBase("http://localhost:8080/error.html");
webContext.setStyleURL("http://localhost:8080/esign/style.css");
webContext.setSignURLBase("https://www.sign-preprod1.nets.eu/sign/index.html?ref=");
webContext.setLocalWebContextRef("webctx1");
request.setWebContexts(new ArrayList<>(Arrays.asList(webContext)));
ExecutionDetails executionDetails = new ExecutionDetails();
executionDetails.setOrderDeadline(new Date(System.currentTimeMillis() + 86400000));
executionDetails.setDisplayProcessInfo("NameStatusTime");
Step step1 = new Step();
step1.setStepNumber(1);
SigningProcess signingProcess = new SigningProcess();
signingProcess.setLocalDocumentReferance("document1");
signingProcess.setLocalSignerReferance("signer1");
signingProcess.setLocalWebContextRef("webctx1");
step1.addSigningProcess(signingProcess);
executionDetails.addStep(step1);
request.setExecutionDetails(executionDetails);
InsertOrderResponse response = facade.insertOrder(request);
On receiving the signed XML message, E-Signing service validates the signature in the incoming message and authenticates the customer. On successful authentication, the XML message is taken for further processing. Once the processing is completed, the E-Signing service sends an OK response back to the customer (received as InsertOrderResponse object as in the code above).
More detailed information on sign order can be found here.
Retrieve sign URL
On successful InsertOrder response, GetSigningProcesses XML message should be sent to E-Signing to retrieve a sign URL. The E-Signing client API can be used to send this message. A basic GetSigningProcesses XML message should contain the following:
- MerchantID (as provided by Nets)
- OrderID (the unique ID that was sent in the InsertOrder XML message)
- Signer reference (that was sent in InsertOrder XML message)
Sample code for retrieving sign URL from E-Signing is provided below (detailed code is available in demo app source files).
ESigningFacade facade = ESigningFactory.INSTANCE.getESigningFacade("Demo Merchant");
GetSigningProcessesRequest req = new GetSigningProcessesRequest();
req.setOrderID("1587-demo-742819356");
req.setMerchantID(1587);
req.setMessageID("esigndemoapp-msgid-2");
req.setTime(new Date());
req.setLocalSignerReference("signer1");
GetSigningProcessesResponse response = facade.getSigningProcesses(req);
ArrayList<SigningProcessResult> signprocesses = response.getSigningProcessResults();
if (null != signprocesses) {
for (SigningProcessResult sp : signprocesses) {
String signUrl = sp.getSignURL();
}
}
Read more about the GetSigningProcesses xml message.
Continue to Step 3 >