﻿{
  "Id": "53e1f95c-4608-4d6d-b970-650c6c9d7e74",
  "DisplayName": "Update-Metadata-Field-On-Revoke",
  "Description": "Update the Notes metadata field on revoke with revocation code and comment",
  "Key": "1",
  "KeyDisplayName": "ejbca6\\Corporate_CorpWebServer-MultiKey",
  "IsPublished": true,
  "WorkflowType": "Revocation",
  "Steps": [
    {
      "Id": "e08eeedc-9b1f-4525-9e5b-05adb26a6532",
      "DisplayName": "End-NOOP",
      "UniqueName": "EndNOOP",
      "ExtensionName": "NOOPStep",
      "Enabled": true,
      "ConfigurationParameters": {},
      "Signals": [],
      "Conditions": [],
      "Outputs": {}
    },
    {
      "Id": "5b790519-ff9b-48af-9794-0ce4d55e3a1c",
      "DisplayName": "Start-NOOP",
      "UniqueName": "StartNOOP",
      "ExtensionName": "NOOPStep",
      "Enabled": true,
      "ConfigurationParameters": {},
      "Signals": [],
      "Conditions": [],
      "Outputs": {
        "continue": "PowerShell1"
      }
    },
    {
      "Id": "0b404bec-f1e6-49cd-9251-36346eb140d1",
      "DisplayName": "Update Metadata Field",
      "UniqueName": "RESTRequest1",
      "ExtensionName": "OAuthRESTRequest",
      "Enabled": true,
      "ConfigurationParameters": {
        "Headers": {
          "x-keyfactor-requested-with": [
            "APIClient"
          ]
        },
        "DataBucketProperty": "",
        "Verb": "PUT",
        "client_id": "Keyfactor-API-User",
        "client_secret": null,
        "TokenEndpoint": "https://appsrvr187.keyexample.com:5443/realms/Keyfactor/protocol/openid-connect/token",
        "scope": "",
        "audience": "",
        "URL": "https://keyfactor.keyexample.com/KeyfactorAPI/Certificates/Metadata",
        "ContentType": "application/json",
        "RequestContent": "{\n   \"Id\": \"$(certid)\",\n   \"Metadata\": {\n      \"Notes\": \"$(MyNotes)\"\n   }\n}"
      },
      "Signals": [],
      "Conditions": [],
      "Outputs": {
        "continue": "KeyfactorRevoke"
      }
    },
    {
      "Id": "bc327b27-89ad-4255-8246-5500cbbb8abf",
      "DisplayName": "Keyfactor-Revoke",
      "UniqueName": "KeyfactorRevoke",
      "ExtensionName": "RevokeStep",
      "Enabled": true,
      "ConfigurationParameters": {},
      "Signals": [],
      "Conditions": [],
      "Outputs": {
        "continue": "EndNOOP"
      }
    },
    {
      "Id": "9d79f867-1b85-4946-a854-97e03cc97628",
      "DisplayName": "Build Notes String",
      "UniqueName": "PowerShell1",
      "ExtensionName": "PowerShell",
      "Enabled": true,
      "ConfigurationParameters": {
        "ScriptParameters": {
          "Comment": "$(cmnt)",
          "Notes": "$(metadata:Notes)",
          "Date": "$(subdate)",
          "RevCode": "$(code)",
          "RevokeBy": "$(revoker)"
        },
        "ScriptContent": "# Declare your parameters at the beginning ($Comment, $Notes, $RevCode, $Date, and $RevokeBy)\r\nparam(\r\n   [string]$Comment,\r\n   [string]$Notes,\r\n   [string]$RevCode,\r\n   [datetime]$Date,\r\n   [string]$RevokeBy\r\n)\r\n\r\n# Append your additional text to the existing text in the metadata Notes field along with the revoker (removing\r\n# the leading 'DOMAIN\\' part for AD users), submission date, revocation code, and comment entered at revocation, \r\n# and beginning the entry with a newline.\r\n$Notes += \"`nRevoked on \" + $Date.ToString(\"MMMM d, yyyy\") + \" by \" + $RevokeBy.SubString($RevokeBy.IndexOf('\\')+1) + \" with revocation option '\" + $RevCode + \"' and comment '\" + $Comment + \"'.\"\r\n\r\n# Return the updated metadata Notes value as MyNotes to the workflow as a hashtable\r\n$result = @{ \"MyNotes\" = $Notes }\r\nreturn $result"
      },
      "Signals": [],
      "Conditions": [],
      "Outputs": {
        "continue": "RESTRequest1"
      }
    }
  ],
  "DraftVersion": 1,
  "PublishedVersion": 1,
  "Enabled": true
}