Class DigitalCovidCertificate


  • public class DigitalCovidCertificate
    extends Eudcc
    A wrapper for the root element generated from the Schema. This class offers methods for encoding and decoding to/from CBOR and JSON.

    The class also ensures that subject names are properly transliterated.

    If you are using the builder pattern (withXX-methods) you need to cast the result to a DigitalCovidCertificate instance.

     final DigitalCovidCertificate dcc = (DigitalCovidCertificate) new DigitalCovidCertificate()
           .withNam(new PersonName().withGn("...").withFn("..."))
           .withDob(LocalDate.parse("1969-11-11"))
           .withV(Arrays.asList(new VaccinationEntry()
           .withTg("840539006")
           .withVp("1119349007")
           ...
           .withCi("01:SE:JKJKHJGHG6768686HGJGH#M")));
     
    Author:
    Martin Lindström (martin@idsec.se), Henrik Bengtsson (extern.henrik.bengtsson@digg.se), Henric Norlander (extern.henric.norlander@digg.se)
    • Constructor Detail

      • DigitalCovidCertificate

        public DigitalCovidCertificate()
        Default constructor.
      • DigitalCovidCertificate

        public DigitalCovidCertificate​(PersonName name,
                                       LocalDate dateOfBirth)
        Constructor assigning the subject name and date of birth of the subject.
        Parameters:
        name - the subject name
        dateOfBirth - the date of birth of the subject
    • Method Detail

      • setNam

        public void setNam​(PersonName name)
        Makes sure that the names supplied are transliterated.
        Overrides:
        setNam in class Eudcc
      • withNam

        public Eudcc withNam​(PersonName name)
        Makes sure that the names supplied are transliterated.
        Overrides:
        withNam in class Eudcc
      • setDob

        public void setDob​(LocalDate dob)
        Setter that takes a LocalDate representing the date of birth instead of string.
        Parameters:
        dob - the date of birth
      • setDob

        public void setDob​(DateOfBirth dob)
        Setter that takes a DateOfBirth representing the date of birth instead of string.
        Parameters:
        dob - the date of birth
      • encode

        public byte[] encode()
                      throws DGCSchemaException
        Encodes this object to its CBOR byte representation.
        Returns:
        the CBOR encoding
        Throws:
        DGCSchemaException - for encoding errors
      • getCBORMapper

        public static com.fasterxml.jackson.dataformat.cbor.databind.CBORMapper getCBORMapper()
        Gets a configured CBORMapper to use for serializing and deserializing.
        Returns:
        a CBORMapper
      • getJSONMapper

        public static com.fasterxml.jackson.databind.ObjectMapper getJSONMapper()
        Gets a configured ObjectMapper to use for JSON serializing and deserializing.
        Returns:
        an ObjectMapper
      • setTagDateTimes

        public void setTagDateTimes​(boolean tagDateTimes)
        The specification dictates that we should tag date-time strings with 0, but during interoperability testing some validator apps have had problems with this. Therefore, it is possible to turn off tagging.

        The default is to add the CBOR tag 0 for date-times.

        Parameters:
        tagDateTimes - whether to tag date-times.