{"id":15149883,"url":"https://github.com/opentdf/java-sdk","last_synced_at":"2026-04-09T20:31:27.433Z","repository":{"id":237772881,"uuid":"771478527","full_name":"opentdf/java-sdk","owner":"opentdf","description":"OpenTDF Java SDK","archived":false,"fork":false,"pushed_at":"2026-01-12T21:41:49.000Z","size":1504,"stargazers_count":0,"open_issues_count":47,"forks_count":2,"subscribers_count":12,"default_branch":"main","last_synced_at":"2026-01-13T01:54:07.642Z","etag":null,"topics":["data-encryption","data-tagging","drm","end-to-end-encryption","file-encryption","java","open-source","opensource","opentdf","tdf","zero-trust","zero-trust-security"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause-clear","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opentdf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-13T11:24:26.000Z","updated_at":"2026-01-08T21:23:00.000Z","dependencies_parsed_at":"2024-05-20T16:06:01.553Z","dependency_job_id":"bdbf3054-a58d-4a6e-b10b-a6fcdbad84d3","html_url":"https://github.com/opentdf/java-sdk","commit_stats":{"total_commits":109,"total_committers":14,"mean_commits":7.785714285714286,"dds":0.8165137614678899,"last_synced_commit":"90bbbc505016c4edde402746352bd6d6e80c6433"},"previous_names":["opentdf/java-sdk"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/opentdf/java-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fjava-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fjava-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fjava-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fjava-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentdf","download_url":"https://codeload.github.com/opentdf/java-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fjava-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-encryption","data-tagging","drm","end-to-end-encryption","file-encryption","java","open-source","opensource","opentdf","tdf","zero-trust","zero-trust-security"],"created_at":"2024-09-26T14:01:25.283Z","updated_at":"2026-04-09T20:31:27.427Z","avatar_url":"https://github.com/opentdf.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenTDF Java SDK\n\nA Java implementation of the OpenTDF protocol, and access library for the services provided by the OpenTDF platform.\n\n**New to the OpenTDF SDK?** See the [OpenTDF SDK Quickstart Guide](https://opentdf.io/category/sdk) for a comprehensive introduction.\n\nThis SDK is available from Maven central as:\n\n```xml\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.opentdf/platform\u003c/groupId\u003e\n        \u003cartifactId\u003esdk\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n```\n### Additional Maven Modules\n- cmdline: Command line utility\n\n## Quick Start Example\n\nThis example demonstrates how to create and read TDF (Trusted Data Format) files using the OpenTDF SDK.\n\n**Prerequisites:** Follow the [OpenTDF Quickstart](https://opentdf.io/quickstart) to get a local platform running, or if you already have a hosted version, replace the values with your OpenTDF platform details.\n\nFor more code examples, see:\n- [Creating TDFs](https://opentdf.io/sdks/tdf)\n- [Managing policy](https://opentdf.io/sdks/policy)\n\n```java\npackage io.opentdf.platform;\n\nimport io.opentdf.platform.sdk.Config;\nimport io.opentdf.platform.sdk.SDK;\nimport io.opentdf.platform.sdk.SDKBuilder;\nimport io.opentdf.platform.sdk.TDF;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.FileOutputStream;\nimport java.nio.channels.FileChannel;\nimport java.nio.charset.StandardCharsets;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.nio.file.StandardOpenOption;\n\npublic class Example {\n    public static void main(String[] args) throws Exception {\n        // Initialize SDK with platform endpoint and authentication\n        // Replace these values with your actual configuration:\n        String platformEndpoint = \"localhost:8080\";           // Your platform URL\n        String clientId = \"opentdf\";                          // Your OAuth client ID\n        String clientSecret = \"secret\";                       // Your OAuth client secret\n        String kasUrl = \"http://localhost:8080/kas\";          // Your KAS URL\n\n        SDK sdk = new SDKBuilder()\n                .platformEndpoint(platformEndpoint)\n                .clientSecret(clientId, clientSecret)\n                .useInsecurePlaintextConnection(true)         // Only for local development with HTTP\n                .build();\n\n        // Create a TDF\n        // This attribute is created in the quickstart guide\n        String dataAttribute = \"https://opentdf.io/attr/department/value/finance\";\n\n        String plaintext = \"Hello, world!\";\n        var plaintextInputStream = new ByteArrayInputStream(plaintext.getBytes(StandardCharsets.UTF_8));\n\n        var kasInfo = new Config.KASInfo();\n        kasInfo.URL = kasUrl;\n\n        var tdfConfig = Config.newTDFConfig(\n            Config.withKasInformation(kasInfo),\n            Config.withDataAttributes(dataAttribute)\n        );\n\n        // Write encrypted TDF to file\n        try (FileOutputStream out = new FileOutputStream(\"encrypted.tdf\")) {\n            sdk.createTDF(plaintextInputStream, out, tdfConfig);\n        }\n\n        System.out.println(\"TDF created successfully\");\n\n        // Decrypt the TDF\n        // LoadTDF contacts the Key Access Service (KAS) to verify that this client\n        // has been granted access to the data attributes, then decrypts the TDF.\n        // Note: The client must have entitlements configured on the platform first.\n        Path tdfPath = Paths.get(\"encrypted.tdf\");\n        try (FileChannel tdfChannel = FileChannel.open(tdfPath, StandardOpenOption.READ)) {\n            TDF.Reader reader = sdk.loadTDF(tdfChannel, Config.newTDFReaderConfig());\n\n            // Write the decrypted plaintext to a file\n            try (FileOutputStream out = new FileOutputStream(\"output.txt\")) {\n                reader.readPayload(out);\n            }\n        }\n\n        System.out.println(\"Successfully created and decrypted TDF\");\n    }\n}\n```\n\n### Configuration Values\n\nReplace these placeholder values with your actual configuration:\n\n| Variable | Default (Quickstart) | Description |\n|----------|---------------------|-------------|\n| `platformEndpoint` | `localhost:8080` | Your OpenTDF platform URL |\n| `clientId` | `opentdf` | OAuth client ID (from quickstart) |\n| `clientSecret` | `secret` | OAuth client secret (from quickstart) |\n| `kasUrl` | `http://localhost:8080/kas` | Your Key Access Service URL |\n| `dataAttribute` | `https://opentdf.io/attr/department/value/finance` | Data attribute FQN (created in quickstart) |\n\n**Before running:**\n1. Follow the [OpenTDF Quickstart](https://opentdf.io/quickstart) to start the platform\n2. Create an OAuth client in Keycloak and note the credentials\n3. Grant your client entitlements to the `department` attribute (see [Managing policy](https://opentdf.io/sdks/policy))\n\n**Expected Output:**\n```\nTDF created successfully\nSuccessfully created and decrypted TDF\n```\n\nThe `output.txt` file will contain the decrypted plaintext: `Hello, world!`\n\n### Cryptography Library\n\nThis SDK uses the [Bouncy Castle Security library](https://www.bouncycastle.org/) library. \nNote: When using this SDK, it may be necessary to register the Bouncy Castle Provider as follows:\n\n```java\n    static {\n        Security.addProvider(new BouncyCastleProvider());\n    }\n```\n\n### Logging\n\nThe Java SDK makes use of the [slf4j](https://www.slf4j.org/) library, without providing a backend. log4j2 in leveraged within the included automated tests.\n\n### SSL - Untrusted Certificates\n\nLeverage the SDKBuilder.withSSL methods to create an SDKBuilder as follows:\n\n- An SSLFactory: ```sdkBuilder.sslFactory(mySSLFactory)```\n- Directory containing trusted certificates: ```sdkBuilder.sslFactoryFromDirectory(myDirectoryWithCerts)```\n- Java Keystore: ```sdkBuilder.sslFactoryFromKeyStore(keystorepath, keystorePassword)```\n\n### Buf\n\nCreate an account, link that account with GitHub and then under User settings create a `token`\n\n```shell\n[INFO] --- antrun:3.1.0:run (generateSources) @ sdk ---\n[INFO] Executing tasks\n[INFO]      [exec] Failure: too many requests\n[INFO]      [exec] \n[INFO]      [exec] Please see https://buf.build/docs/bsr/rate-limits for details about BSR rate limiting.\n```\n\n## Release Process\n\n### SNAPSHOT\n\nSnapshots are from main latest\n\n```shell\nmvn versions:set -DnewVersion=1.2.3-SNAPSHOT\n```\n\n### RELEASE\n\nReleases are from tags created by the GitHub release process.\nEnter 'Release Please' to trigger the release process.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentdf%2Fjava-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentdf%2Fjava-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentdf%2Fjava-sdk/lists"}