Class SDJWT
Instances of this class are immutable. References to Disclosure
instances given to the constructor are internally copied and the
getDisclosures()
method returns the copied list as an
unmodifiable list.
- Since:
- 1.2
-
Constructor Summary
ConstructorDescriptionSDJWT
(String credentialJwt, Collection<Disclosure> disclosures) Constructor with a credential JWT and disclosures.SDJWT
(String credentialJwt, Collection<Disclosure> disclosures, String bindingJwt) Constructor with a credential JWT, disclosures and a binding JWT. -
Method Summary
Modifier and TypeMethodDescriptionGet the binding JWT, which is the JWT placed optionally at the end of SD-JWT.Get the credential JWT, which is the JWT placed at the head of SD-JWT.Get the list of disclosures.Get the hash algorithm used for the disclosures.Get the SD hash value that can be used as the value of the"sd_hash"
claim in a key binding JWT.static SDJWT
Parse the given string as SD-JWT.toString()
Get the string representation of this SD-JWT.
-
Constructor Details
-
SDJWT
Constructor with a credential JWT and disclosures.- Parameters:
credentialJwt
- A credential JWT. Must not be null.disclosures
- Disclosures. May be null.
-
SDJWT
Constructor with a credential JWT, disclosures and a binding JWT.- Parameters:
credentialJwt
- A credential JWT. Must not be null.disclosures
- Disclosures. May be null.bindingJwt
- A binding JWT. May be null.
-
-
Method Details
-
toString
-
getCredentialJwt
Get the credential JWT, which is the JWT placed at the head of SD-JWT.- Returns:
- The credential JWT.
-
getDisclosures
Get the list of disclosures.- Returns:
- The list of disclosures. The returned list is always non-null and unmodifiable.
-
getBindingJwt
Get the binding JWT, which is the JWT placed optionally at the end of SD-JWT.- Returns:
- The binding JWT. May be null.
-
getHashAlgorithm
Get the hash algorithm used for the disclosures.This method returns the value of the
"_sd_alg"
claim in the credential JWT. If the claim is not available,"sha-256"
(the default hash algorithm) is returned.- Returns:
- The hash algorithm.
- Since:
- 1.5
-
getSDHash
Get the SD hash value that can be used as the value of the"sd_hash"
claim in a key binding JWT. If this SD-JWT includes a key binding JWT, the value of the"sd_hash"
claim in the key binding JWT must match the value returned by this method.The input for the hash computation is the serialized form of this SD-JWT, excluding the key binding JWT, which may be appended at the end.
The algorithm for the hash computation is the same as used for disclosures. This algorithm is provided by the
getHashAlgorithm()
method.The returned value is base64url-encoded as required by the SD-JWT specification.
- Returns:
- The SD hash value computed using the credential JWT and disclosures of this SD-JWT.
- Since:
- 1.5
-
parse
Parse the given string as SD-JWT.The expected format of the input string is as follows.
{Credential-JWT}~{Disclosure1}~...~{DisclosureN}~[{Binding-JWT}]
- Parameters:
input
- A string representing SD-JWT. If null is given, null is returned.- Returns:
- An
SDJWT
instance created as a result of parsing the input string.
-