Package se.digg.dgc.service.impl
Class DefaultDGCDecoder
- java.lang.Object
-
- se.digg.dgc.service.impl.DefaultDGCDecoder
-
- All Implemented Interfaces:
DGCDecoder
- Direct Known Subclasses:
DefaultDGCBarcodeDecoder
public class DefaultDGCDecoder extends Object implements DGCDecoder
A bean implementing theDGCDecoder
interface.- Author:
- Martin Lindström (martin@idsec.se), Henrik Bengtsson (extern.henrik.bengtsson@digg.se), Henric Norlander (extern.henric.norlander@digg.se)
-
-
Constructor Summary
Constructors Constructor Description DefaultDGCDecoder(DGCSignatureVerifier dgcSignatureVerifier, CertificateProvider certificateProvider)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DigitalCovidCertificate
decode(String base45)
Given the base45-encoding of a signed DCC the method verifies and decodes it into the DCC payload representation.DigitalCovidCertificate
decodeRaw(byte[] cwt)
Verifies a "raw" DCC (i.e., a signed CWT holding the DCC payload) and decodes it to the actual DCC payload.byte[]
decodeRawToBytes(byte[] cwt)
Verifies a "raw" DCC (i.e., a signed CWT holding the DCC payload) and returns the CBOR encoding of the DCC payload.byte[]
decodeToBytes(String base45)
Given the base45-encoding of a signed DCC the method verifies and decodes it into the CBOR encoding of the DCC payload.
-
-
-
Constructor Detail
-
DefaultDGCDecoder
public DefaultDGCDecoder(DGCSignatureVerifier dgcSignatureVerifier, CertificateProvider certificateProvider)
Constructor.- Parameters:
dgcSignatureVerifier
- the signature verifier - if null, an instance ofDefaultDGCSignatureVerifier
will be usedcertificateProvider
- the certificate provider that is used to locate certificates to use when verifying signatures
-
-
Method Detail
-
decode
public DigitalCovidCertificate decode(String base45) throws DGCSchemaException, SignatureException, CertificateExpiredException, IOException
Given the base45-encoding of a signed DCC the method verifies and decodes it into the DCC payload representation.- Specified by:
decode
in interfaceDGCDecoder
- Parameters:
base45
- the base45-encoding of the signed DCC (including the HCERT header)- Returns:
- the DCC payload
- Throws:
DGCSchemaException
- for DCC schema errorsSignatureException
- for signature verification errorsCertificateExpiredException
- if the DCC has expiredIOException
- for errors decoding data, for example CBOR related errors- See Also:
#decodeBarcodeToBytes(byte[])
-
decodeToBytes
public byte[] decodeToBytes(String base45) throws SignatureException, CertificateExpiredException, IOException
Given the base45-encoding of a signed DCC the method verifies and decodes it into the CBOR encoding of the DCC payload.- Specified by:
decodeToBytes
in interfaceDGCDecoder
- Parameters:
base45
- the base45-encoding of the signed DCC (including the HCERT header)- Returns:
- the CBOR encoding of the DCC payload
- Throws:
SignatureException
- for signature verification errorsCertificateExpiredException
- if the DCC has expiredIOException
- for errors decoding data, for example CBOR related errors- See Also:
#decodeBarcode(byte[])
-
decodeRaw
public DigitalCovidCertificate decodeRaw(byte[] cwt) throws DGCSchemaException, SignatureException, CertificateExpiredException, IOException
Verifies a "raw" DCC (i.e., a signed CWT holding the DCC payload) and decodes it to the actual DCC payload.- Specified by:
decodeRaw
in interfaceDGCDecoder
- Parameters:
cwt
- the signed CWT holding the DCC- Returns:
- the DCC payload
- Throws:
DGCSchemaException
- for DCC schema errorsSignatureException
- for signature verification errorsCertificateExpiredException
- if the DCC has expiredIOException
- for errors decoding data, for example CBOR related errors- See Also:
DGCDecoder.decodeRawToBytes(byte[])
-
decodeRawToBytes
public byte[] decodeRawToBytes(byte[] cwt) throws SignatureException, CertificateExpiredException, IOException
Verifies a "raw" DCC (i.e., a signed CWT holding the DCC payload) and returns the CBOR encoding of the DCC payload.- Specified by:
decodeRawToBytes
in interfaceDGCDecoder
- Parameters:
cwt
- the signed CWT holding the DCC- Returns:
- the CBOR encoded DCC payload
- Throws:
SignatureException
- for signature verification errorsCertificateExpiredException
- if the DCC has expiredIOException
- for errors decoding data, for example CBOR related errors- See Also:
DGCDecoder.decodeRaw(byte[])
-
-