Skip to content

Commit 5ede7dd

Browse files
authored
fix(main): make examples runnable (#311)
This change updates `examples/pom.xml` and adds a readme with instructions for how to run the examples. Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
1 parent 9bd9ce5 commit 5ede7dd

File tree

2 files changed

+129
-3
lines changed

2 files changed

+129
-3
lines changed

examples/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# OpenTDF Java SDK Examples
2+
3+
This directory contains example code demonstrating how to use the OpenTDF Java SDK.
4+
5+
## Running the Examples
6+
7+
The examples can be run using the `exec-maven-plugin`. The general format is:
8+
9+
```bash
10+
mvn -f examples/pom.xml exec:java@<ExampleName>
11+
```
12+
13+
Replace `<ExampleName>` with the name of the example you want to run. For example, to run the `EncryptExample`, use the following command:
14+
15+
```bash
16+
mvn -f examples/pom.xml exec:java@EncryptExample
17+
```
18+
19+
### Available Examples
20+
21+
* `CreateAttribute`
22+
* `CreateNamespace`
23+
* `CreateSubjectConditionSet`
24+
* `CreateSubjectMapping`
25+
* `DecryptCollectionExample`
26+
* `DecryptExample`
27+
* `EncryptCollectionExample`
28+
* `EncryptExample`
29+
* `GetDecisions`
30+
* `GetEntitlements`
31+
* `GetManifestInformation`
32+
* `ListAttributes`
33+
* `ListNamespaces`
34+
* `ListSubjectMappings`
35+
36+
### Example with Arguments
37+
38+
Some examples, like `GetManifestInformation`, require command-line arguments. You can pass arguments to the examples using the `exec.args` property. For example:
39+
40+
```bash
41+
mvn -f examples/pom.xml exec:java@GetManifestInformation -Dexec.args="my.ciphertext"
42+
```

examples/pom.xml

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
<maven.compiler.release>11</maven.compiler.release>
2020
<platform.branch>protocol/go/v0.3.0</platform.branch>
21+
<exec.cleanupDaemonThreads>false</exec.cleanupDaemonThreads>
2122
</properties>
2223

2324
<dependencyManagement>
@@ -121,9 +122,92 @@
121122
<groupId>org.codehaus.mojo</groupId>
122123
<artifactId>exec-maven-plugin</artifactId>
123124
<version>3.0.0</version>
124-
<configuration>
125-
<mainClass>io.opentdf.platform.App</mainClass>
126-
</configuration>
125+
<executions>
126+
<execution>
127+
<id>CreateAttribute</id>
128+
<configuration>
129+
<mainClass>io.opentdf.platform.CreateAttribute</mainClass>
130+
</configuration>
131+
</execution>
132+
<execution>
133+
<id>CreateNamespace</id>
134+
<configuration>
135+
<mainClass>io.opentdf.platform.CreateNamespace</mainClass>
136+
</configuration>
137+
</execution>
138+
<execution>
139+
<id>CreateSubjectConditionSet</id>
140+
<configuration>
141+
<mainClass>io.opentdf.platform.CreateSubjectConditionSet</mainClass>
142+
</configuration>
143+
</execution>
144+
<execution>
145+
<id>CreateSubjectMapping</id>
146+
<configuration>
147+
<mainClass>io.opentdf.platform.CreateSubjectMapping</mainClass>
148+
</configuration>
149+
</execution>
150+
<execution>
151+
<id>DecryptCollectionExample</id>
152+
<configuration>
153+
<mainClass>io.opentdf.platform.DecryptCollectionExample</mainClass>
154+
</configuration>
155+
</execution>
156+
<execution>
157+
<id>DecryptExample</id>
158+
<configuration>
159+
<mainClass>io.opentdf.platform.DecryptExample</mainClass>
160+
</configuration>
161+
</execution>
162+
<execution>
163+
<id>EncryptCollectionExample</id>
164+
<configuration>
165+
<mainClass>io.opentdf.platform.EncryptCollectionExample</mainClass>
166+
</configuration>
167+
</execution>
168+
<execution>
169+
<id>EncryptExample</id>
170+
<configuration>
171+
<mainClass>io.opentdf.platform.EncryptExample</mainClass>
172+
</configuration>
173+
</execution>
174+
<execution>
175+
<id>GetDecisions</id>
176+
<configuration>
177+
<mainClass>io.opentdf.platform.GetDecisions</mainClass>
178+
</configuration>
179+
</execution>
180+
<execution>
181+
<id>GetEntitlements</id>
182+
<configuration>
183+
<mainClass>io.opentdf.platform.GetEntitlements</mainClass>
184+
</configuration>
185+
</execution>
186+
<execution>
187+
<id>GetManifestInformation</id>
188+
<configuration>
189+
<mainClass>io.opentdf.platform.GetManifestInformation</mainClass>
190+
</configuration>
191+
</execution>
192+
<execution>
193+
<id>ListAttributes</id>
194+
<configuration>
195+
<mainClass>io.opentdf.platform.ListAttributes</mainClass>
196+
</configuration>
197+
</execution>
198+
<execution>
199+
<id>ListNamespaces</id>
200+
<configuration>
201+
<mainClass>io.opentdf.platform.ListNamespaces</mainClass>
202+
</configuration>
203+
</execution>
204+
<execution>
205+
<id>ListSubjectMappings</id>
206+
<configuration>
207+
<mainClass>io.opentdf.platform.ListSubjectMappings</mainClass>
208+
</configuration>
209+
</execution>
210+
</executions>
127211
</plugin>
128212
</plugins>
129213
<!-- </pluginManagement> -->

0 commit comments

Comments
 (0)