-
Notifications
You must be signed in to change notification settings - Fork 2
feat(sdk): custom assertions #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
sdk/src/main/java/io/opentdf/platform/sdk/AssertionBinder.java
This file contains hidden or 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,15 @@ | ||
| package io.opentdf.platform.sdk; | ||
|
|
||
| import io.opentdf.platform.sdk.Manifest.Assertion; | ||
|
|
||
| public interface AssertionBinder { | ||
| /** | ||
| * Creates and signs an assertion, binding it to the manifest. | ||
| * | ||
| * @param manifest The manifest of the TDF. | ||
| * @param aggregateHash The aggregate hash of the TDF payload. | ||
| * @return The signed assertion. | ||
| * @throws SDK.AssertionException If an error occurs during binding. | ||
| */ | ||
| Assertion bind(Manifest manifest, byte[] aggregateHash) throws SDK.AssertionException; | ||
| } |
17 changes: 17 additions & 0 deletions
17
sdk/src/main/java/io/opentdf/platform/sdk/AssertionUtils.java
This file contains hidden or 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,17 @@ | ||
| package io.opentdf.platform.sdk; | ||
|
|
||
| public class AssertionUtils { | ||
| /** | ||
| * Computes the data to be signed for an assertion. | ||
| * | ||
| * @param aggregateHash The hash of the TDF payload segments. | ||
| * @param assertionHash The hash of the assertion itself. | ||
| * @return The concatenated hash. | ||
| */ | ||
| public static byte[] computeAssertionSignature(byte[] aggregateHash, byte[] assertionHash) { | ||
| byte[] completeHash = new byte[aggregateHash.length + assertionHash.length]; | ||
| System.arraycopy(aggregateHash, 0, completeHash, 0, aggregateHash.length); | ||
| System.arraycopy(assertionHash, 0, completeHash, aggregateHash.length, assertionHash.length); | ||
| return completeHash; | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
sdk/src/main/java/io/opentdf/platform/sdk/AssertionValidator.java
This file contains hidden or 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,31 @@ | ||
| package io.opentdf.platform.sdk; | ||
|
|
||
| import io.opentdf.platform.sdk.Manifest.Assertion; | ||
|
|
||
| public interface AssertionValidator { | ||
| /** | ||
| * Returns the schema URI that this validator can handle. | ||
| * | ||
| * @return The schema URI. | ||
| */ | ||
| String getSchema(); | ||
|
|
||
| /** | ||
| * Performs a cryptographic check of the assertion. | ||
| * | ||
| * @param assertion The assertion to verify. | ||
| * @param reader The TDF reader. | ||
| * @param aggregateHash The aggregate hash of the TDF payload. | ||
| * @throws SDK.AssertionException If the verification fails. | ||
| */ | ||
| void verify(Assertion assertion, TDFReader reader, byte[] aggregateHash) throws SDK.AssertionException; | ||
|
|
||
| /** | ||
| * Performs a policy check of the assertion. | ||
| * | ||
| * @param assertion The assertion to validate. | ||
| * @param reader The TDF reader. | ||
| * @throws SDK.AssertionException If the validation fails. | ||
| */ | ||
| void validate(Assertion assertion, TDFReader reader) throws SDK.AssertionException; | ||
| } |
This file contains hidden or 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 hidden or 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
7 changes: 7 additions & 0 deletions
7
sdk/src/main/java/io/opentdf/platform/sdk/VerificationMode.java
This file contains hidden or 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,7 @@ | ||
| package io.opentdf.platform.sdk; | ||
|
|
||
| public enum VerificationMode { | ||
| PERMISSIVE, | ||
| FAIL_FAST, | ||
| STRICT | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this private?