Skip to content

Commit

Permalink
Merge pull request #35 from telefonicaid/release/0.3.0
Browse files Browse the repository at this point in the history
Release/0.3.0
  • Loading branch information
dmoranj committed Nov 11, 2014
2 parents bc12e38 + 129a5bc commit 431ea3c
Show file tree
Hide file tree
Showing 24 changed files with 608 additions and 115 deletions.
48 changes: 33 additions & 15 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
Keypass is multi-tenant XACML server with PAP (Policy Administration Point) and
PDP (Policy Detention Point) capabilities.

Tenancy is defined by means of an HTTP header. Default configuration uses
`Fiware-Service` as the tenant header name, but it can be easily changed
modifying it in the config file.

The PDP endpoint will evaluate the Policies for the subjects contained in a
XACML request. This is a design decision took by Keypass in order to simplify
how the application is used.
Expand All @@ -30,7 +34,8 @@ they are not resources _per se_.
### Create or update a policy

```
POST /pap/v1/:tenant/subject/:subjectId
POST /pap/v1/subject/:subjectId
<TENANT-HEADER>:<tenant>
<Policy/>
```
Expand All @@ -44,9 +49,10 @@ replaced (updated) with the new policy.
Examples:

```HTTP
POST /pap/v1/myTenant/subject/role12345 HTTP/1.1
POST /pap/v1/subject/role12345 HTTP/1.1
Content-type: application/xml
Accept: application/xml
Fiware-Service: myTenant
<Policy xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17
http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd"
Expand Down Expand Up @@ -97,13 +103,14 @@ Response

```HTTP
HTTP/1.1 201 Created
Location: http://localhost:8080/pap/v1/myTenant/subject/role12345/policy/policy03
Location: http://localhost:8080/pap/v1/subject/role12345/policy/policy03
```

### Get a policy

```
GET /pap/v1/:tenant/subject/:subjectId/policy/:policyId
GET /pap/v1/subject/:subjectId/policy/:policyId
<TENANT-HEADER>:<tenant>
```

Retrieves an existing policy. Returns `404` if the policy does not exist. Please
Expand All @@ -112,7 +119,8 @@ note that `404` is returned also if the Tenant or Subject does not exists.
Example:

```
GET http://localhost:8080/pap/v1/myTenant/subject/role12345/policy/policy03
GET http://localhost:8080/pap/v1/subject/role12345/policy/policy03
Fiware-Service: myTenant
```

Response
Expand Down Expand Up @@ -169,7 +177,8 @@ Content-Type: application/xml
### Delete a policy

```
DELETE /pap/v1/:tenant/subject/:subjectId/policy/:policyId
DELETE /pap/v1/subject/:subjectId/policy/:policyId
<TENANT-HEADER>:<tenant>
```

Removes a policy. If removed successfully, returns the removed policy. In case
Expand All @@ -179,7 +188,8 @@ the policy does not exists, returns `404`.
Example:

```
DELETE http://localhost:8080/pap/v1/myTenant/subject/role12345/policy/policy03
DELETE http://localhost:8080/pap/v1/subject/role12345/policy/policy03
Fiware-Service: myTenant
```

Response
Expand Down Expand Up @@ -236,7 +246,8 @@ Content-Type: application/xml
### Get subject policies

```
GET /pap/v1/:tenant/subject/:subjectId
GET /pap/v1/subject/:subjectId
<TENANT-HEADER>:<tenant>
```

Retrieves all the policies of a given subject as PolicySet element. If there
Expand All @@ -248,7 +259,8 @@ policies.
Exmple:

```
GET http://localhost:8080/pap/v1/myTenant/subject/role12345
GET http://localhost:8080/pap/v1/subject/role12345
Fiware-Service: myTenant
```

Response
Expand All @@ -263,7 +275,8 @@ Content-Type: application/xml
### Delete subject policies

```
DELETE /pap/v1/:tenant/subject/:subjectId
DELETE /pap/v1/subject/:subjectId
<TENANT-HEADER>:<tenant>
```

Convenience method to remove all the policies of the subject. Will return `204`
Expand All @@ -273,7 +286,8 @@ a subject is not a resource from the Keypass point of view).
Example:

```
DELETE http://localhost:8080/pap/v1/myTenant/subject/role12345
DELETE http://localhost:8080/pap/v1/subject/role12345
Fiware-Service: myTenant
```

Response
Expand All @@ -285,7 +299,8 @@ HTTP/1.1 204 No Content
### Delete tenant policies

```
DELETE /pap/v1/:tenant
DELETE /pap/v1
<TENANT-HEADER>:<tenant>
```

Convenience method to remove all the policies of the given tenant. As previous
Expand All @@ -294,7 +309,8 @@ method, returns `204` always.
Example:

```
DELETE http://localhost:8080/pap/v1/myTenant
DELETE http://localhost:8080/pap/v1
Fiware-Service: myTenant
```

Response
Expand All @@ -307,7 +323,8 @@ HTTP/1.1 204 No Content
## PDP API

```
POST /pdp/v3/:tenant
POST /pdp/v3
<TENANT-HEADER>:<tenant>
<xacmlRequest/>
```
Expand All @@ -319,7 +336,8 @@ with Decision `NotApplicable`.
Example:

```HTTP
POST /pdp/v3/myTenant
POST /pdp/v3
Fiware-Service: myTenant
Content-type: application/xml
Accept: application/xml
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ $ java -jar target/keypass-<VERSION>.jar server conf/config.yml

```
curl -i -H "Accept: application/xml" -H "Content-type: application/xml" \
-H "Fiware-Service: myTenant" \
-X POST -d @src/test/resources/es/tid/fiware/iot/ac/xacml/policy03.xml \
http://localhost:8080/pap/v1/myTenant/subject/role12345
http://localhost:8080/pap/v1/subject/role12345
```

Response should be something like this:
Expand All @@ -67,7 +68,8 @@ Content-Length: 0
## Retrieve a policy

```
curl -i http://localhost:8080/pap/v1/myTenant/subject/role12345/policy/policy03
curl -i -H "Fiware-Service: myTenant" \
http://localhost:8080/pap/v1/subject/role12345/policy/policy03
```

Response will be the previously uploaded policy.
Expand All @@ -76,8 +78,9 @@ Response will be the previously uploaded policy.

```
curl -i -H "Accept: application/xml" -H "Content-type: application/xml" \
-H "Fiware-Service: myTenant" \
-X POST -d @src/test/resources/es/tid/fiware/iot/ac/xacml/policy01_request01.xml \
http://localhost:8080/pdp/v3/myTenant
http://localhost:8080/pdp/v3
```
Response:

Expand Down
2 changes: 1 addition & 1 deletion TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ time=15:12:54.743 | lvl=INFO | corr= | trans=n/a | op=ServerFactory | msg=Starti
__/ |
|___/
v0.2.0
v0.3.0-SNAPSHOT
time=15:12:55.106 | lvl=INFO | corr= | trans=n/a | op=DropwizardResourceConfig | msg=The following paths were found for the configured resources:
Expand Down
2 changes: 2 additions & 0 deletions conf/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ server:
port: 8081
bindHost: 127.0.0.1

tenantHeader: Fiware-Service

database:
# the name of your JDBC driver
driverClass: com.mysql.jdbc.Driver
Expand Down
135 changes: 135 additions & 0 deletions jmeter-test-plan.jmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.6" jmeter="2.11 r1554548">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="build-web-test-plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="JMeter Users" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">2</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">5</stringProp>
<stringProp name="ThreadGroup.ramp_time">5</stringProp>
<longProp name="ThreadGroup.start_time">1373789594000</longProp>
<longProp name="ThreadGroup.end_time">1373789594000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP Request Defaults" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">127.0.0.1</stringProp>
<stringProp name="HTTPSampler.port">8080</stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
<stringProp name="HTTPSampler.concurrentPool">4</stringProp>
</ConfigTestElement>
<hashTree/>
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
<collectionProp name="HeaderManager.headers">
<elementProp name="Content-type" elementType="Header">
<stringProp name="Header.name">Content-type</stringProp>
<stringProp name="Header.value"> application/xml</stringProp>
</elementProp>
<elementProp name="Fiware-Service" elementType="Header">
<stringProp name="Header.name">Fiware-Service</stringProp>
<stringProp name="Header.value"> myTenant</stringProp>
</elementProp>
</collectionProp>
</HeaderManager>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="PDP" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&#xd;
&lt;Request xsi:schemaLocation=&quot;urn:oasis:names:tc:xacml:3.0:core:schema:wd-17 http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd&quot; ReturnPolicyIdList=&quot;false&quot; CombinedDecision=&quot;false&quot; xmlns=&quot;urn:oasis:names:tc:xacml:3.0:core:schema:wd-17&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;&#xd;
&lt;Attributes Category=&quot;urn:oasis:names:tc:xacml:1.0:subject-category:access-subject&quot;&gt;&#xd;
&lt;Attribute IncludeInResult=&quot;false&quot; AttributeId=&quot;urn:oasis:names:tc:xacml:1.0:subject:subject-id&quot;&gt;&#xd;
&lt;AttributeValue DataType=&quot;http://www.w3.org/2001/XMLSchema#string&quot;&gt;role12345&lt;/AttributeValue&gt;&#xd;
&lt;/Attribute&gt;&#xd;
&lt;/Attributes&gt;&#xd;
&lt;Attributes Category=&quot;urn:oasis:names:tc:xacml:3.0:attribute-category:resource&quot;&gt;&#xd;
&lt;Attribute IncludeInResult=&quot;false&quot; AttributeId=&quot;urn:oasis:names:tc:xacml:1.0:resource:resource-id&quot;&gt;&#xd;
&lt;AttributeValue DataType=&quot;http://www.w3.org/2001/XMLSchema#string&quot;&gt;fiware:orion:tenant1234:us-west-1:res9876&lt;/AttributeValue&gt;&#xd;
&lt;/Attribute&gt;&#xd;
&lt;/Attributes&gt;&#xd;
&lt;Attributes Category=&quot;urn:oasis:names:tc:xacml:3.0:attribute-category:action&quot;&gt;&#xd;
&lt;Attribute IncludeInResult=&quot;false&quot; AttributeId=&quot;urn:oasis:names:tc:xacml:1.0:action:action-id&quot;&gt;&#xd;
&lt;AttributeValue DataType=&quot;http://www.w3.org/2001/XMLSchema#string&quot;&gt;read&lt;/AttributeValue&gt;&#xd;
&lt;/Attribute&gt;&#xd;
&lt;/Attributes&gt;&#xd;
&lt;/Request&gt;</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/pdp/v3</stringProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<ResultCollector guiclass="GraphVisualizer" testclass="ResultCollector" testname="Graph Results" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>es.tid.fiware</groupId>
<artifactId>keypass</artifactId>
<version>0.2.0</version>
<version>0.3.0</version>

<description>
Keypass is multi-tenant XACML server with PAP (Policy Administration
Expand Down Expand Up @@ -278,7 +278,7 @@
</script>
</preremoveScriptlet>
<requires>
<require>java &gt; 1.6</require>
<require>java &gt; 1.7</require>
</requires>
</configuration>
<executions>
Expand Down
3 changes: 2 additions & 1 deletion src/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<include>*.jar</include>
</includes>
<excludes>
<exclude>original*</exclude>
<exclude>**/original-*</exclude>
</excludes>
</fileSet>

Expand All @@ -62,6 +62,7 @@
<outputDirectory>/behavior</outputDirectory>
<excludes>
<exclude>VENV/**</exclude>
<exclude>**/*.pyc</exclude>
</excludes>
</fileSet>

Expand Down
Loading

0 comments on commit 431ea3c

Please sign in to comment.