Skip to content

Commit

Permalink
Javadoc updates
Browse files Browse the repository at this point in the history
Update to 0.0.7-SNAPSHOT
  • Loading branch information
Razumain committed Feb 14, 2025
1 parent e63d328 commit 7023946
Show file tree
Hide file tree
Showing 40 changed files with 1,256 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* A generic class representing input data required for a presentation. This class is used to encapsulate
* details such as tokens, cryptographic parameters, and disclosures that may be needed during the
* presentation process.
*
* @param <T> the type of the disclosures associated with this presentation input
*/
@Getter
@NoArgsConstructor
public class PresentationInput<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* Represents a token attribute used in various token operations.
* <p>
* This class encapsulates an attribute with a specific type and value. The type
* of the attribute is defined by {@link TokenAttributeType}, which specifies the
* namespace and attribute name. The value is stored as an object, allowing flexibility
* to represent various data types such as String, Integer, or LocalDate depending on the
* context of the attribute.
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Enum representing namespaces associated with token attributes.
*
* Each namespace is identified by a unique string identifier (id),
* which groups attributes under a specific category or standard.
* This allows for better organization and management of token attributes
* across different implementations or frameworks.
*/
@Getter
@AllArgsConstructor
public enum TokenAttributeNameSpace {
/** EUDI wallet PID attribute name space */
EUDI_WALLET_PID("eu.europa.ec.eudi.pid.1"),
/** Mdoc mDL attribute namespace */
MDOC_MDL("org.iso.18013.5.1");

/**
* The string identifier representing a namespace associated with token attributes.
*/
final String id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,38 @@
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* Represents a structured type for a token attribute, which can be used in various
* token-related operations such as selective disclosure, validation, or issuance.
*
* This class encapsulates the namespace and the attribute name associated with
* a specific token attribute. The namespace may define a specific scope or context,
* while the attribute name identifies the attribute within that namespace. If the
* namespace is not specified, only the attribute name is considered.
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TokenAttributeType {

/** Optional name space for this attribute */
private String nameSpace;
/** The unique name of the attribute within its name space if applicable */
private String attributeName;

/**
* Constructs a TokenAttributeType instance with the specified attribute name.
*
* @param attributeName the name of the token attribute to be associated with this type.
* This parameter specifies the name of the attribute and it is
* required while creating the instance. The namespace is set to null.
*/
public TokenAttributeType(String attributeName) {
this.attributeName = attributeName;
this.nameSpace = null;
}

/** {@inheritDoc} */
@Override
public String toString() {
if (nameSpace == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@
@Getter
@AllArgsConstructor
public enum TokenDigestAlgorithm {
/** SHA 256 */
SHA_256("SHA-256", "SHA-256", "sha-256"),
/** SHA 384 */
SHA_384("SHA-384", "SHA-384", "sha-384"),
/** SHA 512 */
SHA_512("SHA-512", "SHA-512", "sha-512");

/** Name of hash algorithm used in mDL documents */
private final String mdlName;
/** Name of hash algorithm used in JDK MessageDigest instantiations */
private final String jdkName;
/** Name of hash algorithm used in SD JWT representations (sd_alg) */
private final String sdJwtName;

/**
* Converts a given mDL hash algorithm name to a corresponding {@code TokenDigestAlgorithm} instance.
*
* @param mdlName the name of the hash algorithm as specified in mDL documents.
* @return the corresponding {@code TokenDigestAlgorithm} instance.
* @throws NoSuchAlgorithmException if the provided mDL hash algorithm name is not supported.
*/
public static TokenDigestAlgorithm fromMdlName(String mdlName)
throws NoSuchAlgorithmException {
return Arrays.stream(values())
Expand All @@ -35,6 +48,13 @@ public static TokenDigestAlgorithm fromMdlName(String mdlName)
.orElseThrow(() -> new NoSuchAlgorithmException("Unsupported mDL hash algorithm"));
}

/**
* Converts a given SD-JWT hash algorithm name to a corresponding {@code TokenDigestAlgorithm} instance.
*
* @param sdJwtName the name of the hash algorithm as specified in SD-JWT representations.
* @return the corresponding {@code TokenDigestAlgorithm} instance.
* @throws NoSuchAlgorithmException if the provided SD-JWT hash algorithm name is not supported.
*/
public static TokenDigestAlgorithm fromSdJwtName(String sdJwtName) throws NoSuchAlgorithmException {
return Arrays.stream(values())
.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package se.digg.wallet.datatypes.common;

import com.nimbusds.jose.JWSAlgorithm;
import java.security.PublicKey;
import java.time.Duration;
import java.util.List;
Expand All @@ -14,12 +13,16 @@
import lombok.NoArgsConstructor;
import se.swedenconnect.security.credential.PkiCredential;

/**
* Represents the input data required for issuing a token.
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TokenInput {

/** Issuer name */
protected String issuer;
/** Attributes enabled for selective disclosure */
protected List<TokenAttribute> attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public interface TokenIssuer<T extends TokenInput> {
* @param tokenInput the token input object containing attributes, issuer credential, expiration duration,
* signing algorithm, and wallet public key
* @return a byte array representing the issued token
* @throws TokenIssuingException if an error occurs during token issuance
*/
byte[] issueToken(T tokenInput) throws TokenIssuingException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@
import java.io.Serial;

/**
* Exception caugth while issuing a token
* Exception caught while issuing a token
*/
public class TokenIssuingException extends Exception {

@Serial
private static final long serialVersionUID = -3234309120112902779L;

/** {@inheritDoc} */
/**
* Constructs a new TokenIssuingException with the specified detail message.
*
* @param message the detail message explaining the reason for the exception
*/
public TokenIssuingException(String message) {
super(message);
}

/** {@inheritDoc} */
/**
* Constructs a new TokenIssuingException with the specified detail message and cause.
*
* @param message the detail message explaining the reason for the exception
* @param cause the cause of the exception, which can be retrieved later using the {@code getCause()} method
*/
public TokenIssuingException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,46 @@

import java.io.Serial;

/**
* A custom exception that is thrown when an error occurs during token parsing.
*
* This exception can be used to indicate issues such as invalid token structure,
* parsing failures, or other errors encountered while processing a token.
*/
public class TokenParsingException extends Exception {
@Serial
private static final long serialVersionUID = -150091799709439631L;


/**
* Default constructor for the TokenParsingException class.
*
* This constructor creates a new instance of TokenParsingException without any
* specific error message or cause. It is typically used when there is a token
* parsing error that does not require additional context.
*/
public TokenParsingException() {
}

/**
* Constructs a new TokenParsingException with the specified detail message.
*
* @param message the detail message, which provides additional information
* about the token parsing error. This message is typically
* intended for debugging or logging purposes.
*/
public TokenParsingException(String message) {
super(message);
}

/**
* Constructs a TokenParsingException with the specified detail message and cause.
*
* @param message the detail message, which provides additional context about the token parsing error.
* This message is typically useful for debugging or logging purposes.
* @param cause the cause of the token parsing error. This can be another throwable that represents
* the underlying issue that led to this exception.
*/
public TokenParsingException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,51 @@

import java.io.Serial;

/**
* Exception thrown to indicate an error during the token presentation process.
*
* This exception is used in cases where the process of creating a verifiable token
* presentation with selective disclosures fails due to invalid inputs, cryptographic
* errors, or other issues that prevent successful presentation. It provides constructors
* for specifying detailed error messages and causes.
*/
public class TokenPresentationException extends Exception {
@Serial
private static final long serialVersionUID = 942635978985209161L;

/**
* Default constructor for the TokenPresentationException.
* This constructor initializes a new instance of the exception without any
* specific message or cause, indicating a generic error during the token
* presentation process.
*/
public TokenPresentationException() {
}

/**
* Constructs a new TokenPresentationException with the specified detail message.
*
* @param message the detail message, which provides additional information about the error
*/
public TokenPresentationException(String message) {
super(message);
}

/**
* Constructs a new TokenPresentationException with the specified detail message and cause.
*
* @param message the detail message providing additional context about the error
* @param cause the underlying cause of the exception, typically another throwable
*/
public TokenPresentationException(String message, Throwable cause) {
super(message, cause);
}

/**
* Constructs a new TokenPresentationException with the specified cause.
*
* @param cause the underlying cause of this exception, typically another throwable
*/
public TokenPresentationException(Throwable cause) {
super(cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public interface TokenPresenter<T extends PresentationInput<?>> {
* Creates a presentation token with selective disclosures
*
* @param presentationInput the verifiable presentation token input
* @param privateKey the wallet private key used for generating device proof signature
* @return token with disclosures and device provided key proof
* @throws TokenPresentationException if the presentation process fails due to invalid input, cryptographic
* errors, or any other processing issues
*/
byte[] presentToken(PresentationInput<?> presentationInput, PrivateKey privateKey) throws TokenPresentationException;

Expand Down
Loading

0 comments on commit 7023946

Please sign in to comment.