Seal completed documets from SWF

This document will give you an example on how to configure the solution to seal all documents when the workflow is complete.

Prerequisites

  • PhenixID Autentication Services 4.4 or later installed
  • Signing Workflow 2.0 or later installed
  • Seal certificate (p12) stored as a keystore resource in PhenixID Autentication Services

Configuration SWF

Enable the webhook in SWF according to the documentation. The webhook should be directed to the "seal pipe" configured later in this instruction, example:

https://signing.company.org/pipes/sealoncomplete

A complete example could look like this:

"webHook": { 
"enabled": true, 
"endpoint": "https://signing.company.org/pipes/sealoncomplete" 
}

Enable the automation api, example:

 "automationApiEnabled": true

Configuration PAS

The configuration below is an example that has to be modified in order to suite the customer requirements.

Replace "https://signingworkflowapi.company.org" with the url the automation api of your SWF server.

Replace "ID_OF_YOUR_KEYSTORE" with the ID of keystore previously uploaded to your PAS server.

{
"id": "sealoncomplete",
"http_enabled": "true",
"http_path_pattern": "POST:/pipes/sealoncomplete",
"valves": [
{
    "name": "ItemCreateFromRequestValve",
    "_description": "Creates an item from the incomming request",
    "config": {
        "dest_id": "test"
    }
},
{
    "name": "PropertyStringBase64DecoderValve",
    "_description": "Base64 decodes the body",
    "config": {
        "source": "body",
        "dest": "decodedBody"
    }
},
{
    "name": "ScriptEvalValve",
    "_description": "Extracts eventType and orderId from the decoded body and adds them as item properties",
    "config": {
        "mime_type": "application/javascript",
        "script": "var string = flow.items().get(0).getPropertyValue('decodedBody'); var json = JSON.parse(string); var eventType = json['eventType']; var orderId = json['orderId'];flow.items().get(0).replaceProperty('eventType', eventType); flow.items().get(0).replaceProperty('orderId', orderId);"
    }
},
{
    "name": "ItemRemoveValve",
    "_description": "Remove item if the eventType not equals OrderAccepted",
    "config": {
        "skip_if_expr": "flow.getPropertyValue('eventType','a').equals('OrderAccepted')"
    }
},
{
    "name": "HttpGetValve",
    "_description": "Gets the pdf-document from the orderId in flow",
    "config": {
        "url": "https://signingworkflowapi.company.org/api/document_signing/orders/{{item.orderId}}/document",
        "dest": "http_response_body",
        "binary_content": "true",
        "skip_if_expr": "flow.isEmpty()"
    }
},
{
    "name": "PropertyAddValve",
    "_description": "Adds the text that should appear in the visual signature",
    "config": {
        "name": "signText",
        "value": "Sigill @ PhenixID Demo",
        "splitter": "$",
        "skip_if_expr": "flow.isEmpty()"
    }
},
{
    "name": "PADESSignVisibleSignatureValve",
    "_description": "Seals the document in flow, with the configured keystore",
    "config": {
        "keyStoreID": "ID_OF_YOUR_KEYSTORE",
        "pdfSourceData": "{{item.http_response_body}}",
        "backDropImage": "C:/Program Files/PhenixID/SigningService/custom/sign-visual-rect.png",
        "signingPage": "C:/Program Files/PhenixID/SigningService/custom/sign-visual-template.pdf",
        "signText": "{{item.signText}}",
        "topOffset": "85",
        "leftOffset": "35",
        "padding": "5",
        "pdfTarget": "document",
        "skip_if_expr": "flow.isEmpty()"
    }
},
{
    "name": "HttpFileUploadValve",
    "_description": "Will upload and replace the document in SWF",
    "config": {
        "url": "https://signingworkflowapi.company.org/api/document_signing/orders/{{item.orderId}}/document",
        "content": "{{item.document}}",
        "skip_if_expr": "flow.isEmpty()"
    }
}
]
}

Testing

  1. Restart the SWF server
  2. Start and complete a SWF flow
  3. Download the PDF and verify that the document i sealed.