-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from diggsweden/mdl-presentation
MDL Presentation and updated API
- Loading branch information
Showing
52 changed files
with
2,238 additions
and
433 deletions.
There are no files selected for viewing
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
17 changes: 17 additions & 0 deletions
17
src/main/java/se/digg/wallet/datatypes/common/PresentationInput.java
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,17 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class PresentationInput<T extends Object> { | ||
|
||
protected byte[] token; | ||
protected String nonce; | ||
protected TokenSigningAlgorithm algorithm; | ||
protected T disclosures; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/se/digg/wallet/datatypes/common/PresentationValidationInput.java
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,19 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* Input to presentation validation for mDoc and SD JWT | ||
*/ | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class PresentationValidationInput { | ||
protected String requestNonce; | ||
} | ||
|
||
|
||
|
39 changes: 39 additions & 0 deletions
39
src/main/java/se/digg/wallet/datatypes/common/PresentationValidator.java
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,39 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Defines an interface for validating verifiable presentations. | ||
* <p> | ||
* A verifiable presentation, which may include selective disclosures, can be validated using this interface. | ||
* Validation is performed using a combination of the presented token, a set of validation input parameters, | ||
* and a list of trusted signing keys. | ||
* <p> | ||
* Proving signing keys is optional. If keys are provided, validation verifies that a trusted key is used to sign the presentation. | ||
* If no trusted keys are provided, then the result lists the used signing key/path. | ||
* <p> | ||
* The process ensures the integrity and authenticity of the token, while also verifying its structural correctness, | ||
* optional expiration, and the presence of a valid nonce. | ||
* <p> | ||
* Methods in this interface may throw exceptions indicating issues with the token's integrity, parsing, or validation. | ||
*/ | ||
public interface PresentationValidator { | ||
|
||
/** | ||
* Validates a verifiable presentation and ensures its integrity, authenticity, and adherence to the required structure. | ||
* The validation process involves verifying the structural correctness of the presentation, checking the expiration time, | ||
* ensuring the presence and validity of a nonce, and optionally validating it against a specified list of trusted keys. | ||
* | ||
* @param presentation the byte array representation of the verifiable presentation to be validated. | ||
* @param presentationValidationInput input parameters needed for the validation process, such as a request nonce. | ||
* @param trustedKeys an optional list of trusted keys used to verify the signing key of the presentation. If no trusted | ||
* keys are provided, the result will include details of the signing key/path used for validation. | ||
* @return an instance of {@code TokenValidationResult} containing validation details such as the validation key, | ||
* issue time, expiration time, and nonce. | ||
* @throws TokenValidationException if the presentation validation fails due to structural or cryptographic errors. | ||
* @throws TokenParsingException if an error occurs during parsing of the presentation. | ||
*/ | ||
TokenValidationResult validatePresentation(byte[] presentation, PresentationValidationInput presentationValidationInput, | ||
List<TrustedKey> trustedKeys) throws TokenValidationException, TokenParsingException; | ||
|
||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/se/digg/wallet/datatypes/common/TokenAttributeNameSpace.java
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,13 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum TokenAttributeNameSpace { | ||
EUDI_WALLET_PID("eu.europa.ec.eudi.pid.1"), | ||
MDOC_MDL("org.iso.18013.5.1"); | ||
|
||
String id; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/se/digg/wallet/datatypes/common/TokenAttributeType.java
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,19 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class TokenAttributeType { | ||
|
||
private String nameSpace; | ||
private String attributeName; | ||
|
||
public TokenAttributeType(String attributeName) { | ||
this.attributeName = attributeName; | ||
this.nameSpace = null; | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/main/java/se/digg/wallet/datatypes/common/TokenParsingException.java
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,20 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import java.io.Serial; | ||
|
||
public class TokenParsingException extends Exception { | ||
@Serial | ||
private static final long serialVersionUID = -150091799709439631L; | ||
|
||
|
||
public TokenParsingException() { | ||
} | ||
|
||
public TokenParsingException(String message) { | ||
super(message); | ||
} | ||
|
||
public TokenParsingException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/se/digg/wallet/datatypes/common/TokenPresentationException.java
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,23 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import java.io.Serial; | ||
|
||
public class TokenPresentationException extends Exception { | ||
@Serial | ||
private static final long serialVersionUID = 942635978985209161L; | ||
|
||
public TokenPresentationException() { | ||
} | ||
|
||
public TokenPresentationException(String message) { | ||
super(message); | ||
} | ||
|
||
public TokenPresentationException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public TokenPresentationException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/se/digg/wallet/datatypes/common/TokenPresenter.java
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,23 @@ | ||
package se.digg.wallet.datatypes.common; | ||
|
||
import java.security.PrivateKey; | ||
|
||
/** | ||
* Represents an interface for creating verifiable presentation of a token with selective disclosures. | ||
* It defines the contract for handling a token issued by a token issuer and generating a | ||
* token with disclosures and cryptographic proof using a private key. | ||
* | ||
* @param <T> the type of PresentationInput, where the input contains the token, | ||
* cryptographic settings, and disclosures. | ||
*/ | ||
public interface TokenPresenter<T extends PresentationInput<?>> { | ||
|
||
/** | ||
* Creates a presentation token with selective disclosures | ||
* | ||
* @param presentationInput the verifiable presentation token input | ||
* @return token with disclosures and device provided key proof | ||
*/ | ||
byte[] presentToken(PresentationInput<?> presentationInput, PrivateKey privateKey) throws TokenPresentationException; | ||
|
||
} |
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.