Class SDCombinedFormat

  • Direct Known Subclasses:
    SDIssuance, SDPresentation

    public abstract class SDCombinedFormat
    extends Object
    The common super class for SDIssuance and SDPresentation, 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 Disclosure instances given to the constructor are internally copied and the getDisclosures() method returns the copied list as an unmodifiable list.

    Since:
    1.0
    See Also:
    Selective Disclosure for JWTs (SD-JWT)
    • Constructor Detail

      • SDCombinedFormat

        protected SDCombinedFormat​(String sdJwt,
                                   Collection<Disclosure> disclosures)
        Constructor with an SD-JWT and disclosures.

        The references to Disclosure instances in the given disclosure collection are internally copied and the getDisclosures() 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 of SDIssuance that represents the "Combined Format for Issuance".

        When this method returns true, this instance can be cast to SDIssuance.

        Returns:
        true if this instance is an instance of SDIssuance.
      • isPresentation

        public boolean isPresentation()
        Check whether this instance is an instance of SDPresentation that represents the "Combined Format for Presentation".

        When this method returns true, this instance can be cast to SDPresentation.

        Returns:
        true if this instance is an instance of SDPresentation.
      • 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}
        Overrides:
        toString in class Object
        Returns:
        The string representation of this Combined Format.
      • 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 SDIssuance or SDPresentation.

        Parameters:
        input - A "Combined Format". When null is given, null is returned.
        Returns:
        An instance of either SDIssuance or SDPresentation created as a result of parsing the input string.
        Throws:
        IllegalArgumentException - The given string is malformed.