https://github.com/opentdf/java-sdk
OpenTDF Java SDK
https://github.com/opentdf/java-sdk
data-encryption data-tagging drm end-to-end-encryption file-encryption java open-source opensource opentdf tdf zero-trust zero-trust-security
Last synced: 5 months ago
JSON representation
OpenTDF Java SDK
- Host: GitHub
- URL: https://github.com/opentdf/java-sdk
- Owner: opentdf
- License: bsd-3-clause-clear
- Created: 2024-03-13T11:24:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T19:45:40.000Z (8 months ago)
- Last Synced: 2024-10-29T20:10:58.040Z (8 months ago)
- Topics: data-encryption, data-tagging, drm, end-to-end-encryption, file-encryption, java, open-source, opensource, opentdf, tdf, zero-trust, zero-trust-security
- Language: Java
- Homepage:
- Size: 1010 KB
- Stars: 0
- Watchers: 11
- Forks: 1
- Open Issues: 34
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# OpenTDF Java SDK
A Java implementation of the OpenTDF protocol, and access library for the services provided by the OpenTDF platform.
This SDK is available from Maven central as:```xml
io.opentdf/platform
sdk
```
### Additional Maven Modules
- cmdline: Command line utility## Quick Start Example
```java
import io.opentdf.platform.sdk.Config;
import io.opentdf.platform.sdk.SDK;
import io.opentdf.platform.sdk.SDKBuilder;
import io.opentdf.platform.sdk.abac.Policy;
import java.io.InputStream;
import java.io.FileInputStream;public class Example {
public static void main(String[] args) {
SDK sdk =
new SDKBuilder
.clientSecret("myClient", "token")
.platformEndpoint("https://your.cluster/")
.build();
// Encrypt a file
try (InputStream in = new FileInputStream("input.plaintext")) {
Config c = Config.newTDFConfig(Config.withDataAttributes("attr1", "attr2"));
new TDF().createTDF(in, System.out, tdfConfig, sdk.getServices().kas());
}// Decrypt a file
try (SeekableByteChannel in =
FileChannel.open("input.ciphertext", StandardOpenOption.READ)) {
TDF.Reader reader = new TDF().loadTDF(in, sdk.getServices().kas());
reader.readPayload(System.out);
}
}}
```### Cryptography Library
This SDK uses the [Bouncy Castle Security library](https://www.bouncycastle.org/) library.
Note: When using this SDK, it may be necessary to register the Bouncy Castle Provider as follows:```java
static{
Security.addProvider(new BouncyCastleProvider());
}
```### Logging
The Java SDK makes use of the [slf4j](https://www.slf4j.org/) library, without providing a backend. log4j2 in leveraged within the included automated tests.
### SSL - Untrusted Certificates
Leverage the SDKBuilder.withSSL methods to create an SDKBuilder as follows:
- An SSLFactory: ```sdkBuilder.sslFactory(mySSLFactory)```
- Directory containing trusted certificates: ```sdkBuilder.sslFactoryFromDirectory(myDirectoryWithCerts)```
- Java Keystore: ```sdkBuilder.sslFactoryFromKeyStore(keystorepath, keystorePassword)```### Buf
Create an account, link that account with GitHub and then under User settings create a `token`
```shell
[INFO] --- antrun:3.1.0:run (generateSources) @ sdk ---
[INFO] Executing tasks
[INFO] [exec] Failure: too many requests
[INFO] [exec]
[INFO] [exec] Please see https://buf.build/docs/bsr/rate-limits for details about BSR rate limiting.
```## Release Process
### SNAPSHOT
Snapshots are from main latest
```shell
mvn versions:set -DnewVersion=1.2.3-SNAPSHOT
```### RELEASE
Releases are from tags created by the GitHub release process.
Enter 'Release Please' to trigger the release process.