Resources

The PMP contains different resources for policies, timers, and components. In the following, we show how to use them.

Components

Components like PEPs, PIPs and PXPs can be registered and queried using the /ws/component endpoint.

Register a Component

A POST request registers a component (PEP,PIP,PXP) at PMP. The following examples show how to register PEPs, PIPs and PXPs by providing an Component.

Example requests

{
  "id": {
    "componentType" : "PEP",
    "identifier": "urn:component:test:pep:example1"
  },
  "urls": [
    "rmi://localhost:1111/mydataPEP"
  ],
  "componentInterfaces": [
    {
      "type": "PepInterfaceDescription",
      "event": {
        "platform":"test",
        "context":"local",
        "action": "createConstructionSite"
      },
      "preventive": true,
      "methodName": "delete",
      "returnType": "java.lang.Boolean",
      "description": "Log",
      "parameters": []
    },
    {
      "type": "PepInterfaceDescription",
      "event": {
        "platform":"test",
        "context":"local",
        "action": "closeConstructionSite"
      },
      "preventive": true,
      "methodName": "delete",
      "returnType": "java.lang.Boolean",
      "description": "Log",
      "parameters": [
        {
          "name": "id",
          "description": "id of construction site",
          "type": "java.lang.String"
        }
      ]
    },
    {
      "type": "PepInterfaceDescription",
      "event": {
        "platform":"test",
        "context":"local",
        "action": "showEmployee"
      },
      "preventive": true,
      "methodName": "delete",
      "returnType": "java.lang.Boolean",
      "description": "Log",
      "parameters": [
        {
          "name": "id",
          "description": "id of employee",
          "type": "java.lang.String"
        },{
          "name": "role",
          "description": "role of employee",
          "type": "java.lang.String"
        }
      ]
    }
  ]
}
{
  "id": {
    "componentType": "PIP",
    "identifier": "pipDummy1"
  },
  "urls": [
    "http://localhost:1111/mydataPIP1"
  ],
  "componentInterfaces": [
    {
      "type": "InterfaceDescription",
      "methodName": "getName",
      "returnType": "java.lang.String",
      "description": "Name magic",
      "parameters": [
        {
          "name": "id",
          "description": "Id of employee",
          "type": "java.lang.String",
          "mandatory": true
        }
      ]
    },
 {
      "type": "InterfaceDescription",
      "methodName": "getAddress",
      "returnType": "java.lang.String",
      "description": "Address magic",
      "parameters": [
        {
          "name": "id",
          "description": "Id of employee",
          "type": "java.lang.String",
          "mandatory": true
        }
      ]
    },
{
      "type": "InterfaceDescription",
      "methodName": "isConstructionSiteManager",
      "returnType": "java.lang.Boolean",
      "description": "check if construction site manager",
      "parameters": [
        {
          "name": "id",
          "description": "Id of employee",
          "type": "java.lang.String",
          "mandatory": true
        }
      ]
    },
    {
      "type": "InterfaceDescription",
      "methodName": "isAllWorkDone",
      "returnType": "java.lang.Boolean",
      "description": "check if construction site manager",
      "parameters": [
        {
          "name": "siteId",
          "description": "Id of construction site",
          "type": "java.lang.String",
          "mandatory": true
        },
        {
          "name": "fulfillmentRate",
          "description": "fulfillment rate of all work in percentage",
          "type": "java.lang.Float",
          "mandatory": false
        }
      ]
    },
{
      "type": "InterfaceDescription",
      "methodName": "getEmployees",
      "returnType": "java.util.List",
      "description": "List of all employees on construction site",
      "parameters": []
    },
    {
      "type": "InterfaceDescription",
      "methodName": "getCityOfConstructionSite",
      "returnType": "java.lang.String",
      "description": "Get city in which construction site is located",
      "parameters": [
        {
          "name": "siteId",
          "description": "id of construction site",
          "type": "java.lang.String",
          "mandatory": true
        },
{
          "name": "country",
          "description": "country of construction site",
          "type": "java.lang.String",
          "mandatory": false
        }
      ]
    },
    {
      "type": "InterfaceDescription",
      "methodName": "getConstructionSiteMatchingTo",
      "returnType": "java.lang.String",
      "description": "Find construction site",
      "parameters": [
        {
          "name": "name",
          "description": "search for string in construction site name",
          "type": "java.lang.String",
          "mandatory": true
        },
{
          "name": "active",
          "description": "is the construction site still active",
          "type": "java.lang.Boolean",
          "mandatory": true
        }
        ,{
          "name": "numberOfEmployee",
          "description": "number of employees",
          "type": "java.lang.Integer",
          "mandatory": false
        }
      ]
    }
  ]
}
{
  "id": {
    "componentType":"PXP",
    "identifier": "pxpDummy1"
  },
  "urls": [
    "rmi://localhost:1111/mydataPXP"
  ],
  "componentInterfaces": [
    {
      "type": "InterfaceDescription",
      "methodName": "urn:action:test:log",
      "returnType": "java.lang.Boolean",
      "description": "Log",
      "parameters": [{
          "name": "message",
          "description": "Message to log",
          "type": "java.lang.String",
          "mandatory": true
        }]
    },
    {
      "type": "InterfaceDescription",
      "methodName": "urn:action:test:sendMail",
      "returnType": "java.lang.Boolean",
      "description": "Send a message to receiver",
      "parameters": [{
          "name": "address",
          "description": "Email address",
          "type": "java.lang.String",
          "mandatory": true
        },
        {
          "name": "content",
          "description": "Content of Email",
          "type": "java.lang.String",
          "mandatory": true
        }]
    },
    {
      "type": "InterfaceDescription",
      "methodName": "urn:action:test:alertOnSite",
      "returnType": "java.lang.Boolean",
      "description": "Honk the alert horn on construction site",
      "parameters": [{
          "name": "duration",
          "description": "Duration of alert",
          "type": "java.lang.Integer",
          "mandatory": true
        }]
    },
    {
      "type": "InterfaceDescription",
      "methodName": "urn:action:test:fireEmployee",
      "returnType": "java.lang.Boolean",
      "description": "Fire an employee",
      "parameters": [{
          "name": "daysUntilFiring",
          "description": "Duration of action",
          "type": "java.lang.Integer",
          "mandatory": true
        },{
          "name": "isFiringDoneNicely",
          "description": "is firing done nicely",
          "type": "java.lang.Boolean",
          "mandatory": false
        },{
          "name": "messageToTell",
          "description": "Message to tell the employee",
          "type": "java.lang.String",
          "mandatory": true
        }]
    }
  ]
}

Example response

If everything is fine, true is returned.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4

true

Lookup Component

A GET request retreives a component by its id.

Example request

$ curl 'http://localhost:8080/ws/component/urn:component:test:pip:211' -i -H 'Accept: application/json'

Example response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 119

{
  "componentInterfaces": [],
  "id": {
    "componentType": "PIP",
    "identifier": "211",
    "scope": "test"
  }
}

Policies

PolicyId and Policies have methods to deploy, revoke, remove and list policies. The PolicyId resource is a projection on policy objects that extracts just the id to reduce the bandwidth, as the xml content of a policy could be quite large. The structure of policyId and policy are defined in the relevant section below.

The Policy resources is used to deploy, remove and list policies

The API contains the following services:

Show Policy by id

A GET request that provides a policy.

Example request

$ curl 'http://localhost:8080/policy/urn:policy:banking-demo:policy1/export' -i -H 'Accept: application/json'

Example response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 2536

{
  "id": {
    "policyType": "ILP",
    "scope": "banking-demo",
    "identifier": "policy1"
  },
  "xmlValid": true,
  "languageValid": true,
  "scopeValid": true,
  "invalidPolicyExceptions": [],
  "deployed": true,
  "metaData": {},
  "policy": "<policy id=\"urn:policy:banking-demo:foo\" name=\"foo\" description=\"basic policy for the tests\" \nxmlns=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/ind2uceLanguage\u0027\n        xmlns:parameter=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/parameter\u0027\n        xmlns:pip=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/pip\u0027\n        xmlns:constant=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/constant\u0027        \n        xmlns:variable=\"http://www.iese.fraunhofer.de/ind2uce/3.2.46/variable\"\n        xmlns:variableDeclaration=\"http://www.iese.fraunhofer.de/ind2uce/3.2.46/variableDeclaration\" \n        xmlns:event=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/event\u0027  xmlns:valueChanged=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/valueChanged\u0027>\n\n\t<variableDeclaration:string name=\"role\">\n\t\t<pip:string method=\"urn:info:banking-demo:checkRole\" default=\"\">\n\t\t\t<parameter:number name=\"loggedUser\">\n\t\t\t\t<event:number eventParameter=\"userId\" default=\"1\" />\n\t\t\t</parameter:number>\n\t\t</pip:string>\n\t</variableDeclaration:string>\n\n  <variableDeclaration:number name=\"temperature\">\n    <pip:number method=\"urn:info:banking-demo:getTemperature\" default=\"0\">\n      <parameter:number name=\"zip\">\n        <event:number eventParameter=\"zip\" default=\"1\" />\n      </parameter:number>\n    </pip:number>\n  </variableDeclaration:number>\n\n\t<mechanism event=\"urn:action:banking-demo:get-foobar\">\n\t\t<if>\n\t\t\t<valueChanged:boolean to=\"true\" id=\"b6309a2b-bbf5-41cd-86f1-b4badd73ff0c\">\n\t\t\t\t<equals>\n\t\t\t\t\t<variable:string reference=\"role\" />\n\t\t\t\t\t<constant:string value=\"ALLOW\" />\n\t\t\t\t</equals>\n\t\t\t</valueChanged:boolean>\n\t\t\t<then>\n\t\t\t\t<allow />\n\t\t\t</then>\n\t\t</if>\n\t</mechanism>\n</policy>\n\n"
}

Response structure

Path Type Description

policy

String

The policy in in its xml notation

id

Object

The id of the policy

deployed

Boolean

Deployment status

metaData

Object

Key, value pair of tags for the policy

xmlValid

Boolean

The policy is valid

languageValid

Boolean

The language version is valid

scopeValid

Boolean

The scope is correct

invalidPolicyExceptions

Array

the list of exceptions

Listing deployed Policies

A GET request will list all deployed policies.

Response structure

Path Type Description

[]

Array

The list of deployed policies

[0].id.policyType

String

type

[0].id.scope

String

scope

[0].id.identifier

String

identifier

Example request

$ curl 'http://localhost:8080/ws/policy/deployed' -i -H 'Accept: application/json'

Example response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 2569

[
  {
    "id": {
      "policyType": "ILP",
      "scope": "banking-demo",
      "identifier": "policy1"
    },
    "xmlValid": true,
    "languageValid": true,
    "scopeValid": true,
    "invalidPolicyExceptions": [],
    "deployed": false,
    "metaData": {},
    "policy": "<policy id=\"urn:policy:banking-demo:foo\" name=\"foo\" description=\"basic policy for the tests\" \nxmlns=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/ind2uceLanguage\u0027\n        xmlns:parameter=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/parameter\u0027\n        xmlns:pip=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/pip\u0027\n        xmlns:constant=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/constant\u0027        \n        xmlns:variable=\"http://www.iese.fraunhofer.de/ind2uce/3.2.46/variable\"\n        xmlns:variableDeclaration=\"http://www.iese.fraunhofer.de/ind2uce/3.2.46/variableDeclaration\" \n        xmlns:event=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/event\u0027  xmlns:valueChanged=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/valueChanged\u0027>\n\n\t<variableDeclaration:string name=\"role\">\n\t\t<pip:string method=\"urn:info:banking-demo:checkRole\" default=\"\">\n\t\t\t<parameter:number name=\"loggedUser\">\n\t\t\t\t<event:number eventParameter=\"userId\" default=\"1\" />\n\t\t\t</parameter:number>\n\t\t</pip:string>\n\t</variableDeclaration:string>\n\n  <variableDeclaration:number name=\"temperature\">\n    <pip:number method=\"urn:info:banking-demo:getTemperature\" default=\"0\">\n      <parameter:number name=\"zip\">\n        <event:number eventParameter=\"zip\" default=\"1\" />\n      </parameter:number>\n    </pip:number>\n  </variableDeclaration:number>\n\n\t<mechanism event=\"urn:action:banking-demo:get-foobar\">\n\t\t<if>\n\t\t\t<valueChanged:boolean to=\"true\" id=\"b6309a2b-bbf5-41cd-86f1-b4badd73ff0c\">\n\t\t\t\t<equals>\n\t\t\t\t\t<variable:string reference=\"role\" />\n\t\t\t\t\t<constant:string value=\"ALLOW\" />\n\t\t\t\t</equals>\n\t\t\t</valueChanged:boolean>\n\t\t\t<then>\n\t\t\t\t<allow />\n\t\t\t</then>\n\t\t</if>\n\t</mechanism>\n</policy>\n\n"
  }
]

Add a policy

A POST request that adds a new policy to the list of policies. The content of the post is the policy in its xml notation.

Example request

$ curl 'http://localhost:8080/policy/' -i -X POST -H 'Accept: application/json' -d '"<policy id=\"urn:policy:banking-demo:foo\" name=\"foo\" description=\"basic policy for the tests\" \nxmlns=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/ind2uceLanguage\u0027\n        xmlns:parameter=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/parameter\u0027\n        xmlns:pip=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/pip\u0027\n        xmlns:constant=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/constant\u0027        \n        xmlns:variable=\"http://www.iese.fraunhofer.de/ind2uce/3.2.46/variable\"\n        xmlns:variableDeclaration=\"http://www.iese.fraunhofer.de/ind2uce/3.2.46/variableDeclaration\" \n        xmlns:event=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/event\u0027  xmlns:valueChanged=\u0027http://www.iese.fraunhofer.de/ind2uce/3.2.46/valueChanged\u0027>\n\n\t<variableDeclaration:string name=\"role\">\n\t\t<pip:string method=\"urn:info:banking-demo:checkRole\" default=\"\">\n\t\t\t<parameter:number name=\"loggedUser\">\n\t\t\t\t<event:number eventParameter=\"userId\" default=\"1\" />\n\t\t\t</parameter:number>\n\t\t</pip:string>\n\t</variableDeclaration:string>\n\n  <variableDeclaration:number name=\"temperature\">\n    <pip:number method=\"urn:info:banking-demo:getTemperature\" default=\"0\">\n      <parameter:number name=\"zip\">\n        <event:number eventParameter=\"zip\" default=\"1\" />\n      </parameter:number>\n    </pip:number>\n  </variableDeclaration:number>\n\n\t<mechanism event=\"urn:action:banking-demo:get-foobar\">\n\t\t<if>\n\t\t\t<valueChanged:boolean to=\"true\" id=\"b6309a2b-bbf5-41cd-86f1-b4badd73ff0c\">\n\t\t\t\t<equals>\n\t\t\t\t\t<variable:string reference=\"role\" />\n\t\t\t\t\t<constant:string value=\"ALLOW\" />\n\t\t\t\t</equals>\n\t\t\t</valueChanged:boolean>\n\t\t\t<then>\n\t\t\t\t<allow />\n\t\t\t</then>\n\t\t</if>\n\t</mechanism>\n</policy>\n\n"'

Example response

The response contains true if creating the policy was successful.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4

true

Deploy an existing policy

A POST request that deploys an existing policy. The policy is defined by the id that is part of the url.

Example request

$ curl 'http://localhost:8080/policy/urn:policy:banking-demo:policy1/deploy' -i -H 'Accept: application/json'

Example response

The response contains true if deployment was successful.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4

true

Revokes an existing policy

A GET request that revokes (undeployes) an existing policy. The policy is defined by the id that is part of the url.

Example request

$ curl 'http://localhost:8080/policy/urn:policy:banking-demo:policy1/revoke' -i -H 'Accept: application/json'

Example response

The response contains true if the undeployment was successful, false otherwise.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4

true

Removes an existing policy

A DELETE request that removes an existing policy. The policy is defined by the id that is part of the url. If the policy is deployed, PMP undeployes it first.

Example request

$ curl 'http://localhost:8080/policy/urn:policy:banking-demo:policy1/' -i -X DELETE -H 'Accept: application/json'

Example response

The response contains true if deletion was successful, false otherwise.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4

true

Status of an existing policy

A GET request that retrieves the deployment status of an existing policy. The policy is defined by the id that is part of the url.

Example request

$ curl 'http://localhost:8080/ws/policy/urn:policy:banking-demo:policy1/status' -i -H 'Accept: application/json'

Example response

The response contains true if the policy is currently being deployed.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4

true

List of ids for all existing policies

A GET request that retreives the ids of all policies.

Example request

$ curl 'http://localhost:8080/ws/policyId/test' -i -H 'Accept: application/json'

Example response

The response contains the ids all the policies.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 93

[
  {
    "policyType": "ILP",
    "scope": "banking-demo",
    "identifier": "policy1"
  }
]

Response structure

The policy ID consists of 3 parts appended with ":".

Path Type Description

[0].policyType

String

One of ILP,SLP,SLPT,ILPT

[0].scope

String

1st part of the id, the scope of the policy

[0].identifier

String

2nd part of the id, the specific identifier of the policy

List of ids for all deployed policies

A GET request that retreives the ids of all deployed policies.

Example request

$ curl 'http://localhost:8080/ws/policyId/test' -i -H 'Accept: application/json'

Example response

The response contains the ids all deployed policies. The response struture is described in All PolicyIds.

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 93

[
  {
    "policyType": "ILP",
    "scope": "banking-demo",
    "identifier": "policy1"
  }
]

Security

In order to use the decision service, you have to provide an OAuth access-token. This can be retrieved at the Management Service. The client credentials can be configured in your solutions settings. The token should be provided in the Bearer Authorization Header. To get the access token do the following, query the Authorization Header like follows (credentials are located in form body):

$ curl -i -H 'Content-Type: application/x-www-form-urlencoded'
  	-X POST 'https://management.mydata-control.de/oauth/token‚
    -d 'grant_type=client_credentials&client_id=example-id&client_secret=myPa55s0rd