-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feature/sdk-encrypt
- Loading branch information
Showing
20 changed files
with
1,256 additions
and
749 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# CODEOWNERS | ||
|
||
* @opentdf/java-sdk | ||
* @opentdf/java-sdk @opentdf/architecture | ||
|
||
## High Security Area | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# java-sdk | ||
|
||
OpenTDF Java SDK | ||
|
||
### Logging | ||
We use [slf4j](https://www.slf4j.org/), without providing a backend. We use log4j2 in our tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.opentdf.platform.sdk; | ||
|
||
import io.grpc.Channel; | ||
import io.opentdf.platform.kas.AccessServiceGrpc; | ||
import io.opentdf.platform.kas.PublicKeyRequest; | ||
import io.opentdf.platform.kas.RewrapRequest; | ||
|
||
import java.util.HashMap; | ||
import java.util.function.Function; | ||
|
||
public class KASClient implements SDK.KAS { | ||
|
||
private final Function<SDK.KASInfo, Channel> channelFactory; | ||
|
||
public KASClient(Function <SDK.KASInfo, Channel> channelFactory) { | ||
this.channelFactory = channelFactory; | ||
} | ||
|
||
@Override | ||
public String getPublicKey(SDK.KASInfo kasInfo) { | ||
return getStub(kasInfo).publicKey(PublicKeyRequest.getDefaultInstance()).getPublicKey(); | ||
} | ||
|
||
@Override | ||
public byte[] unwrap(SDK.KASInfo kasInfo, SDK.Policy policy) { | ||
// this is obviously wrong. we still have to generate a correct request and decrypt the payload | ||
return getStub(kasInfo).rewrap(RewrapRequest.getDefaultInstance()).getEntityWrappedKey().toByteArray(); | ||
} | ||
|
||
private final HashMap<SDK.KASInfo, AccessServiceGrpc.AccessServiceBlockingStub> stubs = new HashMap<>(); | ||
|
||
private synchronized AccessServiceGrpc.AccessServiceBlockingStub getStub(SDK.KASInfo kasInfo) { | ||
if (!stubs.containsKey(kasInfo)) { | ||
var channel = channelFactory.apply(kasInfo); | ||
var stub = AccessServiceGrpc.newBlockingStub(channel); | ||
stubs.put(kasInfo, stub); | ||
} | ||
|
||
return stubs.get(kasInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.