JSON Parser sample configuration
In this example, the attribute connector is configured to parse the contents of the attribute pip.payload, which originated from the JSON Attribute Connector. The parsing uses the parameterized JSONPath expression $.authorizations[?(@.id=='##1##')].status to extract values.
The parameter ##1## within the expression is populated by the value of the attribute pip.username.
Finally, the extracted values are provided to the connector host in the attribute pip.status.
- XML
- JSON
- YAML
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://www.axiomatics.com/attributeconnector/parser/json/configuration"
identifier="json-parser">
<source>
<xacmlAttribute AttributeId="pip.payload"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
DataType="http://www.w3.org/2001/XMLSchema#string"/>
</source>
<mapping>
<xacmlAttribute AttributeId="pip.status"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
DataType="http://www.w3.org/2001/XMLSchema#string"/>
<jsonPath>$.authorizations[?(@.id=='##1##')].status</jsonPath>
<key>
<xacmlAttribute AttributeId="pip.username"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
DataType="http://www.w3.org/2001/XMLSchema#string"/>
</key>
</mapping>
JSON configuration files offer the option to use either ALFA or XACML for policy definitions.
- XACML
- ALFA
{
"identifier": "json-parser",
"source": {
"xacmlAttribute": {
"category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
"attributeId": "pip.payload",
"datatype": "http://www.w3.org/2001/XMLSchema#string",
"issuer": ""
}
},
"mappings": [
{
"xacmlAttribute": {
"category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
"attributeId": "pip.status",
"datatype": "http://www.w3.org/2001/XMLSchema#string",
"issuer": ""
},
"jsonPath": "$.authorizations[?(@.id=='##1##')].status",
"keys": [
{
"xacmlAttribute": {
"category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
"attributeId": "pip.username",
"datatype": "http://www.w3.org/2001/XMLSchema#string",
"issuer": ""
}
}
]
}
]
}
{
"identifier": "json-parser",
"source": {
"attributeName": "pip.payload"
},
"mappings": [
{
"attributeName": "pip.status",
"jsonPath": "$.authorizations[?(@.id=='##1##')].status",
"keys": [
{
"attributeName": "pip.username"
}
]
}
]
}
YAML configuration files offer the option to use either ALFA or XACML for policy definitions.
- XACML
- ALFA
identifier: json-parser
source:
xacmlAttribute:
category: "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
attributeId: "pip.payload"
datatype: "http://www.w3.org/2001/XMLSchema#string"
issuer: ""
mappings:
- xacmlAttribute:
category: "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
attributeId: "pip.status"
datatype: "http://www.w3.org/2001/XMLSchema#string"
issuer: ""
jsonPath: "$.authorizations[?(@.id=='##1##')].status"
keys:
- xacmlAttribute:
category: "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
attributeId: "pip.username"
datatype: "http://www.w3.org/2001/XMLSchema#string"
issuer: ""
identifier: json-parser
source:
attributeName: pip.payload
mappings:
- attributeName: pip.status
jsonPath: "$.authorizations[?(@.id=='##1##')].status"
keys:
- attributeName: pip.username
In this configuration, when the connector is queried for the attribute pip.status with the following values:
pip.payloadas{ "authorizations": [ { "id": "a123", "status": "ok"} ] }pip.usernameasa123
it will return ok.