Package se.digg.dgc.payload.v1
Class MapperUtils
- java.lang.Object
-
- se.digg.dgc.payload.v1.MapperUtils
-
public class MapperUtils extends Object
Utility methods for serializing and deserializing aDigitalGreenCertificate
.- Author:
- Martin Lindström (martin@idsec.se), Henrik Bengtsson (extern.henrik.bengtsson@digg.se), Henric Norlander (extern.henric.norlander@digg.se)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.dataformat.cbor.databind.CBORMapper
getCBORMapper()
Gets a configuredCBORMapper
to use for serializing and deserializing.static byte[]
toCBOREncoding(DigitalGreenCertificate dgc)
Given a HCERT payload its CBOR encoding is returned.static DigitalGreenCertificate
toDigitalGreenCertificate(byte[] cbor)
Decodes a CBOR encoding to aDigitalGreenCertificate
.static DigitalGreenCertificate
toDigitalGreenCertificate(String json)
Decodes a JSON string into aDigitalGreenCertificate
.static String
toJSONString(DigitalGreenCertificate dgc)
Given a HCERT payload its string JSON representation is returned.
-
-
-
Method Detail
-
toCBOREncoding
public static byte[] toCBOREncoding(DigitalGreenCertificate dgc) throws DGCSchemaException
Given a HCERT payload its CBOR encoding is returned.- Parameters:
dgc
- the HCERT/DGC payload to encode- Returns:
- the CBOR encoding
- Throws:
DGCSchemaException
- for encoding errors
-
toJSONString
public static String toJSONString(DigitalGreenCertificate dgc) throws DGCSchemaException
Given a HCERT payload its string JSON representation is returned.Mainly for debugging.
- Parameters:
dgc
- the HCERT/DGC payload to encode- Returns:
- JSON string
- Throws:
DGCSchemaException
- fort encoding errors
-
toDigitalGreenCertificate
public static DigitalGreenCertificate toDigitalGreenCertificate(byte[] cbor) throws DGCSchemaException
Decodes a CBOR encoding to aDigitalGreenCertificate
.- Parameters:
cbor
- the CBOR encoding- Returns:
- a DigitalGreenCertificate
- Throws:
DGCSchemaException
- for decoding errors
-
toDigitalGreenCertificate
public static DigitalGreenCertificate toDigitalGreenCertificate(String json) throws DGCSchemaException
Decodes a JSON string into aDigitalGreenCertificate
.- Parameters:
json
- the JSON representation- Returns:
- a DigitalGreenCertificate
- Throws:
DGCSchemaException
- for decoding errors
-
getCBORMapper
public static com.fasterxml.jackson.dataformat.cbor.databind.CBORMapper getCBORMapper()
Gets a configuredCBORMapper
to use for serializing and deserializing.- Returns:
- a CBORMapper
-
-