Class SDCombinedFormat
- java.lang.Object
-
- com.authlete.sd.SDCombinedFormat
-
- Direct Known Subclasses:
SDIssuance,SDPresentation
public abstract class SDCombinedFormat extends Object
The common super class forSDIssuanceandSDPresentation, which represent the "Combined Format for Issuance" and the "Combined Format for Presentation" defined in the SD-JWT specification, respectively.Instances of this class (and the subclasses) are immutable. References to
Disclosureinstances given to the constructor are internally copied and thegetDisclosures()method returns the copied list as an unmodifiable list.- Since:
- 1.0
- See Also:
- Selective Disclosure for JWTs (SD-JWT)
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSDCombinedFormat(String sdJwt, Collection<Disclosure> disclosures)Constructor with an SD-JWT and disclosures.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Disclosure>getDisclosures()Get the list of disclosures.StringgetSDJwt()Get the SD-JWT.booleanisIssuance()Check whether this instance is an instance ofSDIssuancethat represents the "Combined Format for Issuance".booleanisPresentation()Check whether this instance is an instance ofSDPresentationthat represents the "Combined Format for Presentation".static SDCombinedFormatparse(String input)Parse the given string as a "Combined Format".StringtoString()Get the string representation of this Combined Format.
-
-
-
Constructor Detail
-
SDCombinedFormat
protected SDCombinedFormat(String sdJwt, Collection<Disclosure> disclosures)
Constructor with an SD-JWT and disclosures.The references to
Disclosureinstances in the given disclosure collection are internally copied and thegetDisclosures()method returns the copied list as an unmodifiable list. On copy, null elements in the given collection are filtered out.- Parameters:
sdJwt- An SD-JWT. Must not be null.disclosures- Disclosures. May be null.- Throws:
IllegalArgumentException- The given SD-JWT is null.
-
-
Method Detail
-
getSDJwt
public String getSDJwt()
Get the SD-JWT.- Returns:
- The SD-JWT.
-
getDisclosures
public List<Disclosure> getDisclosures()
Get the list of disclosures.- Returns:
- The list of disclosures. The returned list is always non-null and unmodifiable.
-
isIssuance
public boolean isIssuance()
Check whether this instance is an instance ofSDIssuancethat represents the "Combined Format for Issuance".When this method returns
true, this instance can be cast toSDIssuance.- Returns:
trueif this instance is an instance ofSDIssuance.
-
isPresentation
public boolean isPresentation()
Check whether this instance is an instance ofSDPresentationthat represents the "Combined Format for Presentation".When this method returns
true, this instance can be cast toSDPresentation.- Returns:
trueif this instance is an instance ofSDPresentation.
-
toString
public String toString()
Get the string representation of this Combined Format.- Case 1: Combined Format for Issuance
-
{SD-JWT}
~{Disclosure-1}~...~{Disclosure-N} - Case 2: Combined Format for Presentation with no Binding JWT
-
{SD-JWT}
~{Disclosure-1}~...~{Disclosure-M}~ - Case 3: Combined Format for Presentation with a Binding JWT
-
{SD-JWT}
~{Disclosure-1}~...~{Disclosure-M}~{Binding-JWT}
-
parse
public static SDCombinedFormat parse(String input)
Parse the given string as a "Combined Format".When the given string has been parsed successfully, this method returns an instance of either
SDIssuanceorSDPresentation.- Parameters:
input- A "Combined Format". When null is given, null is returned.- Returns:
- An instance of either
SDIssuanceorSDPresentationcreated as a result of parsing the input string. - Throws:
IllegalArgumentException- The given string is malformed.
-
-