{
  "encassConfigs": [
    {
      "goid": "798b6df309d84eb8bc4e7ad5ecbf3fe9",
      "guid": "4b6d95de-4403-4037-a678-9b9df3d448ed",
      "name": "APIKeySecretValidation1.0",
      "description": "Validates an incoming API key supplied via HTTP Basic credentials (username = API key, password = API key secret) and verifies the secret against the value stored for the API key (with hashed-secret support).",
      "policyName": "APIKeySecretValidation1.0",
      "encassArgs": [
        {
          "name": "portal.managed.service.apiId",
          "type": "STRING",
          "ordinal": 1,
          "guiPrompt": false
        }
      ],
      "encassResults": [
        {
          "name": "apiKeyRecord.accountPlanMappingId",
          "type": "STRING"
        },
        {
          "name": "apiKeyRecord.accountPlanMappingName",
          "type": "STRING"
        },
        {
          "name": "apiKeyRecord.id",
          "type": "STRING"
        },
        {
          "name": "apiKeyRecord.key",
          "type": "STRING"
        },
        {
          "name": "apiKeyRecord.plan",
          "type": "STRING"
        },
        {
          "name": "apiKeyRecord.status",
          "type": "STRING"
        },
        {
          "name": "errorMsg",
          "type": "STRING"
        }
      ],
      "properties": [
        {
          "name": "paletteFolder",
          "value": "customAssertions"
        },
        {
          "name": "passMetricsToParent",
          "value": "false"
        },
        {
          "name": "allowTracing",
          "value": "false"
        }
      ]
    }
  ],
  "policies": [
    {
      "goid": "2db16b4766164a33910b976661824899",
      "guid": "2822cd43-199e-4b5d-b323-9ec47cb531db",
      "name": "APIKeySecretValidation1.0",
      "policyType": "FRAGMENT",
      "enabled": true,
      "folderPath": "/Portal Templates",
      "soap": false,
      "policy": {
        "xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<wsp:Policy xmlns:L7p=\"http://www.layer7tech.com/ws/policy\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\">\n    <wsp:All wsp:Usage=\"Required\">\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"QVBJX0tFWQ==\"/>\n            <L7p:VariableToSet stringValue=\"portal.analytics.authType\"/>\n        </L7p:SetVariable>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"JHtwb3J0YWwubWFuYWdlZC5zZXJ2aWNlLmFwaUlkfQ==\"/>\n            <L7p:VariableToSet stringValue=\"portal.analytics.api.uuid\"/>\n        </L7p:SetVariable>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"\"/>\n            <L7p:VariableToSet stringValue=\"errorMsg\"/>\n        </L7p:SetVariable>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"\"/>\n            <L7p:VariableToSet stringValue=\"lookupApiKey\"/>\n        </L7p:SetVariable>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"\"/>\n            <L7p:VariableToSet stringValue=\"keySecret\"/>\n        </L7p:SetVariable>\n        <L7p:HttpBasic>\n            <L7p:Realm stringValue=\"\"/>\n        </L7p:HttpBasic>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"JHtyZXF1ZXN0LnVzZXJuYW1lfQ==\"/>\n            <L7p:VariableToSet stringValue=\"lookupApiKey\"/>\n        </L7p:SetVariable>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"JHtyZXF1ZXN0LnBhc3N3b3JkfQ==\"/>\n            <L7p:VariableToSet stringValue=\"keySecret\"/>\n        </L7p:SetVariable>\n        <wsp:OneOrMore wsp:Usage=\"Required\">\n            <wsp:All wsp:Usage=\"Required\">\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${lookupApiKey}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    <L7p:Negated booleanValue=\"true\"/>\n                    <L7p:Operator operator=\"EMPTY\"/>\n                    <L7p:RightValue stringValue=\"\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${keySecret}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    <L7p:Negated booleanValue=\"true\"/>\n                    <L7p:Operator operator=\"EMPTY\"/>\n                    <L7p:RightValue stringValue=\"\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n            </wsp:All>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"QVBJIGtleSBvciBzZWNyZXQgbWlzc2luZyBmcm9tIEhUVFAgQmFzaWMgY3JlZGVudGlhbHM=\"/>\n            <L7p:VariableToSet stringValue=\"errorMsg\"/>\n        </L7p:SetVariable>\n        </wsp:OneOrMore>\n        <wsp:OneOrMore wsp:Usage=\"Required\">\n            <wsp:All wsp:Usage=\"Required\">\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${errorMsg}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:Operator operator=\"EMPTY\"/>\n                    <L7p:RightValue stringValue=\"\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n        <L7p:Encapsulated>\n            <L7p:EncapsulatedAssertionConfigGuid stringValue=\"b74008fa-97b2-4556-9b5b-30e057641570\"/>\n            <L7p:EncapsulatedAssertionConfigName stringValue=\"Portal Look Up API Key (Generic)\"/>\n            <L7p:Parameters mapValue=\"included\">\n                <L7p:entry>\n                    <L7p:key stringValue=\"apikey\"/>\n                    <L7p:value stringValue=\"${lookupApiKey}\"/>\n                </L7p:entry>\n                <L7p:entry>\n                    <L7p:key stringValue=\"serviceid\"/>\n                    <L7p:value stringValue=\"${portal.managed.service.apiId}\"/>\n                </L7p:entry>\n            </L7p:Parameters>\n        </L7p:Encapsulated>\n        <wsp:OneOrMore wsp:Usage=\"Required\">\n            <wsp:All wsp:Usage=\"Required\">\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${apiKeyRecord.found}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    \n                    <L7p:RightValue stringValue=\"true\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${apiKeyRecord.service}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    \n                    <L7p:RightValue stringValue=\"${portal.managed.service.apiId}\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${apiKeyRecord.status}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    \n                    <L7p:RightValue stringValue=\"active\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n            </wsp:All>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"QVBJIGtleSBub3QgZm91bmQgb3IgaW52YWxpZA==\"/>\n            <L7p:VariableToSet stringValue=\"errorMsg\"/>\n        </L7p:SetVariable>\n        </wsp:OneOrMore>\n            </wsp:All>\n            <L7p:TrueAssertion/>\n        </wsp:OneOrMore>\n        <wsp:OneOrMore wsp:Usage=\"Required\">\n            <wsp:All wsp:Usage=\"Required\">\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${errorMsg}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:Operator operator=\"EMPTY\"/>\n                    <L7p:RightValue stringValue=\"\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n        <wsp:OneOrMore wsp:Usage=\"Required\">\n            <wsp:All wsp:Usage=\"Required\">\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${apiKeyRecord.secret}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    \n                    <L7p:RightValue stringValue=\"${keySecret}\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n            </wsp:All>\n            <wsp:All wsp:Usage=\"Required\">\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${apiKeyRecord.hashingMetadata}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    <L7p:Negated booleanValue=\"true\"/>\n                    <L7p:Operator operator=\"EMPTY\"/>\n                    <L7p:RightValue stringValue=\"\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"JHthcGlLZXlSZWNvcmQuaGFzaGluZ01ldGFkYXRhfQ==\"/>\n            <L7p:ContentType stringValue=\"application/json; charset=utf-8\"/>\n            <L7p:DataType variableDataType=\"message\"/>\n            <L7p:VariableToSet stringValue=\"hashing_metadata\"/>\n        </L7p:SetVariable>\n                <L7p:Encapsulated>\n                    <L7p:EncapsulatedAssertionConfigGuid stringValue=\"1d682484-d9d7-47f7-9671-9ae9e10f5af4\"/>\n                    <L7p:EncapsulatedAssertionConfigName stringValue=\"Portal Read Hashed Metadata\"/>\n                    <L7p:NoOpIfConfigMissing booleanValue=\"true\"/>\n                </L7p:Encapsulated>\n                <L7p:Encapsulated>\n                    <L7p:EncapsulatedAssertionConfigGuid stringValue=\"532dd6d5-7326-4e86-aaba-bd20f99ec899\"/>\n                    <L7p:EncapsulatedAssertionConfigName stringValue=\"Portal Create Hash\"/>\n                    <L7p:NoOpIfConfigMissing booleanValue=\"true\"/>\n                    <L7p:Parameters mapValue=\"included\">\n                        <L7p:entry>\n                            <L7p:key stringValue=\"algorithm\"/>\n                            <L7p:value stringValue=\"${algorithm.result}\"/>\n                        </L7p:entry>\n                        <L7p:entry>\n                            <L7p:key stringValue=\"inputPlaintext\"/>\n                            <L7p:value stringValue=\"${keySecret}\"/>\n                        </L7p:entry>\n                        <L7p:entry>\n                            <L7p:key stringValue=\"salt\"/>\n                            <L7p:value stringValue=\"${salt.result}\"/>\n                        </L7p:entry>\n                    </L7p:Parameters>\n                </L7p:Encapsulated>\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${apiKeyRecord.secret}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    \n                    <L7p:RightValue stringValue=\"${hashedValue}\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n            </wsp:All>\n        <L7p:SetVariable>\n            <L7p:Base64Expression stringValue=\"SW52YWxpZCBBUEkga2V5IHNlY3JldA==\"/>\n            <L7p:VariableToSet stringValue=\"errorMsg\"/>\n        </L7p:SetVariable>\n        </wsp:OneOrMore>\n            </wsp:All>\n            <L7p:TrueAssertion/>\n        </wsp:OneOrMore>\n        <wsp:OneOrMore wsp:Usage=\"Required\">\n            <wsp:All wsp:Usage=\"Required\">\n                <L7p:ComparisonAssertion>\n                    <L7p:CaseSensitive booleanValue=\"false\"/>\n                    <L7p:Expression1 stringValue=\"${errorMsg}\"/>\n                    <L7p:Operator operatorNull=\"null\"/>\n                    <L7p:Predicates predicates=\"included\">\n                        <L7p:item dataType=\"included\">\n                            <L7p:Type variableDataType=\"string\"/>\n                        </L7p:item>\n                        <L7p:item binary=\"included\">\n                            <L7p:Operator operator=\"EMPTY\"/>\n                            <L7p:RightValue stringValue=\"\"/>\n                        </L7p:item>\n                    </L7p:Predicates>\n                </L7p:ComparisonAssertion>\n                <L7p:SetVariable>\n                    <L7p:Base64Expression stringValue=\"JHthcGlLZXlSZWNvcmQuaWR9\"/>\n                    <L7p:VariableToSet stringValue=\"portal.analytics.apikey\"/>\n                </L7p:SetVariable>\n                <L7p:SetVariable>\n                    <L7p:Base64Expression stringValue=\"JHthcGlLZXlSZWNvcmQuaWR9\"/>\n                    <L7p:VariableToSet stringValue=\"portal.analytics.application.uuid\"/>\n                </L7p:SetVariable>\n                <L7p:SetVariable>\n                    <L7p:Base64Expression stringValue=\"JHthcGlLZXlSZWNvcmQubGFiZWx9\"/>\n                    <L7p:VariableToSet stringValue=\"portal.analytics.application.name\"/>\n                </L7p:SetVariable>\n                <L7p:SetVariable>\n                    <L7p:Base64Expression stringValue=\"JHthcGlLZXlSZWNvcmQuYWNjb3VudFBsYW5NYXBwaW5nSWR9\"/>\n                    <L7p:VariableToSet stringValue=\"portal.analytics.organization.uuid\"/>\n                </L7p:SetVariable>\n                <L7p:SetVariable>\n                    <L7p:Base64Expression stringValue=\"JHthcGlLZXlSZWNvcmQuYWNjb3VudFBsYW5NYXBwaW5nTmFtZX0=\"/>\n                    <L7p:VariableToSet stringValue=\"portal.analytics.organization.name\"/>\n                </L7p:SetVariable>\n            </wsp:All>\n            <wsp:All wsp:Usage=\"Required\">\n                <L7p:SetVariable>\n                    <L7p:Base64Expression stringValue=\"NDAx\"/>\n                    <L7p:VariableToSet stringValue=\"portal.analytics.response.code\"/>\n                </L7p:SetVariable>\n            </wsp:All>\n        </wsp:OneOrMore>\n        <L7p:ExportVariables>\n            <L7p:ExportedVars stringArrayValue=\"included\">\n                <L7p:item stringValue=\"apiKeyRecord.accountPlanMappingId\"/>\n                <L7p:item stringValue=\"apiKeyRecord.accountPlanMappingName\"/>\n                <L7p:item stringValue=\"apiKeyRecord.id\"/>\n                <L7p:item stringValue=\"apiKeyRecord.key\"/>\n                <L7p:item stringValue=\"apiKeyRecord.plan\"/>\n                <L7p:item stringValue=\"apiKeyRecord.status\"/>\n                <L7p:item stringValue=\"errorMsg\"/>\n                <L7p:item stringValue=\"portal.analytics.authType\"/>\n                <L7p:item stringValue=\"portal.analytics.api.uuid\"/>\n                <L7p:item stringValue=\"portal.analytics.apikey\"/>\n                <L7p:item stringValue=\"portal.analytics.application.uuid\"/>\n                <L7p:item stringValue=\"portal.analytics.application.name\"/>\n                <L7p:item stringValue=\"portal.analytics.organization.uuid\"/>\n                <L7p:item stringValue=\"portal.analytics.organization.name\"/>\n                <L7p:item stringValue=\"portal.analytics.response.code\"/>\n            </L7p:ExportedVars>\n        </L7p:ExportVariables>\n        <wsp:OneOrMore wsp:Usage=\"Required\">\n        <L7p:ComparisonAssertion>\n            <L7p:CaseSensitive booleanValue=\"false\"/>\n            <L7p:Expression1 stringValue=\"${errorMsg}\"/>\n            <L7p:Operator operatorNull=\"null\"/>\n            <L7p:Predicates predicates=\"included\">\n                <L7p:item dataType=\"included\">\n                    <L7p:Type variableDataType=\"string\"/>\n                </L7p:item>\n                <L7p:item binary=\"included\">\n                    <L7p:Operator operator=\"EMPTY\"/>\n                    <L7p:RightValue stringValue=\"\"/>\n                </L7p:item>\n            </L7p:Predicates>\n        </L7p:ComparisonAssertion>\n            <wsp:All wsp:Usage=\"Required\">\n                <L7p:CustomizeErrorResponse>\n                    <L7p:Content stringValue=\"${errorMsg}\"/>\n                    <L7p:ExtraHeaders nameValuePairArray=\"included\"/>\n                    <L7p:HttpStatus stringValue=\"401\"/>\n                </L7p:CustomizeErrorResponse>\n                <L7p:FalseAssertion/>\n            </wsp:All>\n        </wsp:OneOrMore>\n    </wsp:All>\n</wsp:Policy>\n"
      }
    }
  ],
  "properties": {
    "meta": {
      "name": "APIKeySecretValidation1.0 Bundle",
      "schema": "11.2.1"
    },
    "defaultAction": "NEW_OR_UPDATE"
  }
}