Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
01cd832
add it to the manifest
elizabethhealy Aug 13, 2024
35f0a71
add split logic on decrypt
elizabethhealy Aug 13, 2024
ec5e91b
update cli exception handling
elizabethhealy Aug 13, 2024
484dcaa
make custom exception type
elizabethhealy Aug 13, 2024
4552d07
null check
elizabethhealy Aug 13, 2024
8b006dd
check for null pointer
elizabethhealy Aug 13, 2024
fb889a3
encrypt w key splits
elizabethhealy Aug 14, 2024
03fae78
try to fix test, exception fix, sets
elizabethhealy Aug 14, 2024
ee193e3
fix test
elizabethhealy Aug 14, 2024
93bae72
Merge branch 'main' into split-key-implementation
elizabethhealy Aug 14, 2024
44a8d96
set up attributes client
elizabethhealy Aug 16, 2024
895592e
add autoconfigure
elizabethhealy Aug 19, 2024
7828af8
Merge branch 'main' into add-attributes-client
elizabethhealy Aug 19, 2024
caccf55
Merge branch 'autoconfiguration-key-splitting' into add-multikas-auto…
elizabethhealy Aug 19, 2024
3dfb9c3
Merge branch 'main' into add-multikas-autoconfigure
elizabethhealy Aug 19, 2024
3610633
most tests working
elizabethhealy Aug 19, 2024
8d2ea13
tests passing
elizabethhealy Aug 20, 2024
dc8a1ba
multikas e2e (#122)
elizabethhealy Aug 20, 2024
b17950c
fix ci trigger
elizabethhealy Aug 20, 2024
8d512f7
Merge branch 'main' into add-multikas-autoconfigure
elizabethhealy Aug 20, 2024
d879fff
addressing some comments
elizabethhealy Aug 20, 2024
d337c92
resolving more suggestions
elizabethhealy Aug 20, 2024
1ac7a20
hashcode
elizabethhealy Aug 20, 2024
42d05e9
Merge branch 'main' into add-multikas-autoconfigure
elizabethhealy Aug 20, 2024
06aedff
reverting attributes client change
elizabethhealy Aug 20, 2024
45961a5
change specificity, use attr only if value not present
elizabethhealy Aug 21, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
--client-secret=secret \
--platform-endpoint=localhost:8080 \
-i \
encrypt --kas-url=localhost:8080 --mime-type=text/plain --attr https://example.com/attr/attr1/value/value1 -f data -m 'here is some metadata' > test.tdf
encrypt --kas-url=localhost:8080 --mime-type=text/plain --attr https://example.com/attr/attr1/value/value1 --autoconfigure=false -f data -m 'here is some metadata' > test.tdf

java -jar target/cmdline.jar \
--client-id=opentdf-sdk \
Expand Down
19 changes: 11 additions & 8 deletions cmdline/src/main/java/io/opentdf/platform/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
import javax.crypto.NoSuchPaddingException;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
Expand All @@ -30,6 +28,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;

@CommandLine.Command(name = "tdf")
Expand All @@ -54,8 +53,9 @@ void encrypt(
@Option(names = {"-m", "--metadata"}, defaultValue = Option.NULL_VALUE) Optional<String> metadata,
// cant split on optional parameters
@Option(names = {"-a", "--attr"}, defaultValue = Option.NULL_VALUE) Optional<String> attributes,
@Option(names = {"-c", "--autoconfigure"}, defaultValue = Option.NULL_VALUE) Optional<Boolean> autoconfigure,
@Option(names = {"--mime-type"}, defaultValue = Option.NULL_VALUE) Optional<String> mimeType) throws
IOException, JOSEException {
IOException, JOSEException, AutoConfigureException, InterruptedException, ExecutionException {

var sdk = buildSDK();
var kasInfos = kas.stream().map(k -> {
Expand All @@ -67,15 +67,18 @@ void encrypt(
List<Consumer<Config.TDFConfig>> configs = new ArrayList<>();
configs.add(Config.withKasInformation(kasInfos));
metadata.map(Config::withMetaData).ifPresent(configs::add);
autoconfigure.map(Config::withAutoconfigure).ifPresent(configs::add);
mimeType.map(Config::withMimeType).ifPresent(configs::add);
attributes.ifPresent(attr -> {
configs.add(Config.withDataAttributes(attr.split(",")));
});

if (attributes.isPresent()){
configs.add(Config.withDataAttributes(attributes.get().split(",")));
}
var tdfConfig = Config.newTDFConfig(configs.toArray(Consumer[]::new));
try (var in = file.isEmpty() ? new BufferedInputStream(System.in) : new FileInputStream(file.get())) {
try (var out = new BufferedOutputStream(System.out)) {
new TDF().createTDF(in, out, tdfConfig, sdk.getServices().kas());
new TDF().createTDF(in, out, tdfConfig,
sdk.getServices().kas(),
sdk.getServices().attributes()
);
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,13 @@
<artifactId>java-json-canonicalization</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.opentdf.platform.sdk;

public class AutoConfigureException extends RuntimeException {
public AutoConfigureException(String message) {
super(message);
}

public AutoConfigureException(Exception e) {
super(e);
}

public AutoConfigureException(String message, Exception e) {
super(message, e);
}
}
Loading