Skip to content

Commit c8f81e1

Browse files
authored
JCL-479: Add acp module (#2338)
1 parent ebe64fd commit c8f81e1

File tree

21 files changed

+1580
-1
lines changed

21 files changed

+1580
-1
lines changed

acp/pom.xml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>com.inrupt.client</groupId>
6+
<artifactId>inrupt-client</artifactId>
7+
<version>2.0.0-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>inrupt-client-acp</artifactId>
11+
<name>Inrupt Java Client Libraries - Access Control Policies</name>
12+
<description>
13+
Access Control Policy support for the Inrupt Client Libraries.
14+
</description>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.inrupt.client</groupId>
19+
<artifactId>inrupt-client-api</artifactId>
20+
<version>${project.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>com.inrupt.client</groupId>
24+
<artifactId>inrupt-client-vocabulary</artifactId>
25+
<version>${project.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.inrupt.client</groupId>
29+
<artifactId>inrupt-client-solid</artifactId>
30+
<version>${project.version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.slf4j</groupId>
34+
<artifactId>slf4j-api</artifactId>
35+
<version>${slf4j.version}</version>
36+
</dependency>
37+
38+
<!-- test dependencies -->
39+
<dependency>
40+
<groupId>org.junit.jupiter</groupId>
41+
<artifactId>junit-jupiter-engine</artifactId>
42+
<version>${junit.version}</version>
43+
<scope>test</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.junit.jupiter</groupId>
47+
<artifactId>junit-jupiter-params</artifactId>
48+
<version>${junit.version}</version>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.wiremock</groupId>
53+
<artifactId>wiremock</artifactId>
54+
<version>${wiremock.version}</version>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>com.inrupt.client</groupId>
59+
<artifactId>inrupt-client-jackson</artifactId>
60+
<version>${project.version}</version>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>com.inrupt.client</groupId>
65+
<artifactId>inrupt-client-guava</artifactId>
66+
<version>${project.version}</version>
67+
<scope>test</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>com.inrupt.client</groupId>
71+
<artifactId>inrupt-client-core</artifactId>
72+
<version>${project.version}</version>
73+
<scope>test</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>com.inrupt.client</groupId>
77+
<artifactId>inrupt-client-httpclient</artifactId>
78+
<version>${project.version}</version>
79+
<scope>test</scope>
80+
</dependency>
81+
<dependency>
82+
<groupId>com.inrupt.client</groupId>
83+
<artifactId>inrupt-client-jena</artifactId>
84+
<version>${project.version}</version>
85+
<scope>test</scope>
86+
</dependency>
87+
<dependency>
88+
<groupId>org.slf4j</groupId>
89+
<artifactId>slf4j-simple</artifactId>
90+
<version>${slf4j.version}</version>
91+
<scope>test</scope>
92+
</dependency>
93+
</dependencies>
94+
95+
<build>
96+
<plugins>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-surefire-plugin</artifactId>
100+
</plugin>
101+
<plugin>
102+
<groupId>org.apache.maven.plugins</groupId>
103+
<artifactId>maven-failsafe-plugin</artifactId>
104+
<configuration>
105+
<systemPropertyVariables />
106+
</configuration>
107+
</plugin>
108+
<plugin>
109+
<groupId>org.jacoco</groupId>
110+
<artifactId>jacoco-maven-plugin</artifactId>
111+
</plugin>
112+
</plugins>
113+
</build>
114+
</project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright Inrupt Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to use,
7+
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8+
* Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
package com.inrupt.client.acp;
22+
23+
import static com.inrupt.client.acp.AccessControlResource.asIRI;
24+
25+
import com.inrupt.client.vocabulary.ACP;
26+
import com.inrupt.client.vocabulary.RDF;
27+
import com.inrupt.rdf.wrapping.commons.ValueMappings;
28+
import com.inrupt.rdf.wrapping.commons.WrapperIRI;
29+
30+
import java.util.Set;
31+
32+
import org.apache.commons.rdf.api.Graph;
33+
import org.apache.commons.rdf.api.IRI;
34+
import org.apache.commons.rdf.api.RDFTerm;
35+
36+
/**
37+
* An AccessControl type for use with Access Control Policies.
38+
*
39+
* <p>An access control applies {@link Policy} objects directly to a resource
40+
* via {@code acp:accessControl} or to container members via {@code acp:memberAccessControl}
41+
*/
42+
public class AccessControl extends WrapperIRI {
43+
44+
/**
45+
* Create a new AccessControl.
46+
*
47+
* @param identifier the access control identifier
48+
* @param graph the underlying graph
49+
*/
50+
public AccessControl(final RDFTerm identifier, final Graph graph) {
51+
super(identifier, graph);
52+
graph.add((IRI) identifier, asIRI(RDF.type), asIRI(ACP.AccessControl));
53+
}
54+
55+
public Set<Policy> apply() {
56+
return objects(asIRI(ACP.apply), Policy::asResource, ValueMappings.as(Policy.class));
57+
}
58+
59+
static IRI asResource(final AccessControl accessControl, final Graph graph) {
60+
graph.add(accessControl, asIRI(RDF.type), asIRI(ACP.AccessControl));
61+
accessControl.apply().forEach(policy -> {
62+
graph.add(accessControl, asIRI(ACP.apply), policy);
63+
Policy.asResource(policy, graph);
64+
});
65+
66+
return accessControl;
67+
}
68+
}
69+

0 commit comments

Comments
 (0)