Package se.digg.dgc.service.impl
Class DefaultDGCEncoder
- java.lang.Object
-
- se.digg.dgc.service.impl.DefaultDGCEncoder
-
- All Implemented Interfaces:
DGCEncoder
- Direct Known Subclasses:
DefaultDGCBarcodeEncoder
public class DefaultDGCEncoder extends Object implements DGCEncoder
A bean implementing theDGCEncoder
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 DefaultDGCEncoder(DGCSigner dgcSigner)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
encode(byte[] dcc, Instant expiration)
Based on the CBOR encoded DCC payload and a expiration time, the method signs it, deflates it, and delivers it in Base45 encoding (with a HCERT header).String
encode(DigitalCovidCertificate dcc, Instant expiration)
Based on the DCC payload and a expiration time, the method encodes the payload to CBOR, signs it, deflates it, and delivers it in Base45 encoding (with a HCERT header).byte[]
sign(byte[] dcc, Instant expiration)
Given the CBOR-encoding of the DCC payload the method creates a CWT and signs it.byte[]
sign(DigitalCovidCertificate dcc, Instant expiration)
Given the DCC payload the method creates a CWT and signs it.
-
-
-
Constructor Detail
-
DefaultDGCEncoder
public DefaultDGCEncoder(DGCSigner dgcSigner)
Constructor.- Parameters:
dgcSigner
- a signer for signing the DCC:s
-
-
Method Detail
-
encode
public String encode(DigitalCovidCertificate dcc, Instant expiration) throws DGCSchemaException, IOException, SignatureException
Based on the DCC payload and a expiration time, the method encodes the payload to CBOR, signs it, deflates it, and delivers it in Base45 encoding (with a HCERT header).- Specified by:
encode
in interfaceDGCEncoder
- Parameters:
dcc
- the contents of the DCCexpiration
- the expiration of the DCC- Returns:
- the Base45 encoding of the signed DCC
- Throws:
DGCSchemaException
- for DCC schema errorsIOException
- for errors encoding data, for example CBOR related errorsSignatureException
- errors concerning signing the DCC
-
encode
public String encode(byte[] dcc, Instant expiration) throws IOException, SignatureException
Based on the CBOR encoded DCC payload and a expiration time, the method signs it, deflates it, and delivers it in Base45 encoding (with a HCERT header).- Specified by:
encode
in interfaceDGCEncoder
- Parameters:
dcc
- the contents of the DCC in its CBOR encodingexpiration
- the expiration of the DCC- Returns:
- the Base45 encoding of the signed DCC
- Throws:
IOException
- for errors encoding data, for example CBOR related errorsSignatureException
- errors concerning signing the DCC
-
sign
public byte[] sign(DigitalCovidCertificate dcc, Instant expiration) throws DGCSchemaException, IOException, SignatureException
Given the DCC payload the method creates a CWT and signs it.- Specified by:
sign
in interfaceDGCEncoder
- Parameters:
dcc
- the DCC payloadexpiration
- the expiration time of the DCC- Returns:
- the CBOR encoding of the signed DCC (CWT)
- Throws:
DGCSchemaException
- for DCC schema errorsIOException
- for errors encoding data, for example CBOR related errorsSignatureException
- errors concerning signing the DCC
-
sign
public byte[] sign(byte[] dcc, Instant expiration) throws IOException, SignatureException
Given the CBOR-encoding of the DCC payload the method creates a CWT and signs it.- Specified by:
sign
in interfaceDGCEncoder
- Parameters:
dcc
- the DCC payload in its CBOR encodingexpiration
- the expiration of the DCC- Returns:
- the CBOR encoding of the signed DCC (CWT)
- Throws:
IOException
- for errors encoding data, for example CBOR related errorsSignatureException
- errors concerning signing the DCC
-
-