Package de.tsenger.vdstools
Class DataEncoder
java.lang.Object
de.tsenger.vdstools.DataEncoder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]static StringencodeBase256(byte[] ba) static byte[]static byte[]encodeDate(String dateString) static byte[]encodeDate(LocalDate localDate) Encode a LocalDate as described in ICAO Doc9303 Part 13 in three bytesstatic byte[]encodeDateTime(LocalDateTime localDatetime) Encode a LocalDate as described in as described in ICAO TR "Datastructure for Barcode" in six bytes.static FeatureencodeDerTlv(String vdsType, DerTlv derTlv) static <T> DerTlvencodeFeature(String vdsType, String feature, T value) static byte[]encodeMaskedDate(String dateString) Encodes a date string with unknown date parts as described in ICAO TR "Datastructure for Barcode".static intgetDocumentRef(String vdsType) static String[]Return the Signer Identifier and the Certificate Reference based on the given X.509.static StringgetVdsType(int documentRef) static voidsetFeatureEncoder(FeatureConverter featureEncoder) static inttoUnsignedInt(byte value) static byte[]zip(byte[] bytesToCompress)
-
Constructor Details
-
DataEncoder
public DataEncoder()
-
-
Method Details
-
getSignerCertRef
Return the Signer Identifier and the Certificate Reference based on the given X.509. Signer Identifier is C + CN Certificate Reference is the serial number of the X509Certificate. It will be encoded as hex string- Parameters:
cert- X509 certificate to get the signer information from- Returns:
- String array that contains the signerIdentifier at index 0 and CertRef at index 1
- Throws:
InvalidNameException- if a syntax violation is detected.
-
encodeDate
- Parameters:
dateString- Date as String formated as yyyy-MM-dd- Returns:
- date encoded in 3 bytes
-
encodeDate
Encode a LocalDate as described in ICAO Doc9303 Part 13 in three bytes- Parameters:
localDate- Date- Returns:
- date encoded in 3 bytes
-
encodeDateTime
Encode a LocalDate as described in as described in ICAO TR "Datastructure for Barcode" in six bytes.- Parameters:
localDatetime- LocalDateTime to encode- Returns:
- local date time encoded in 6 bytes
-
encodeMaskedDate
Encodes a date string with unknown date parts as described in ICAO TR "Datastructure for Barcode". Unknown parts of the date string shall be filled with an 'x', e.g. 19xx-10-xx- Parameters:
dateString- date as String formated as yyyy-MM-dd where unknown parts could be replaced by an x- Returns:
- masked date encoded in 4 bytes
-
encodeC40
-
toUnsignedInt
public static int toUnsignedInt(byte value) -
encodeBase256
-
zip
- Throws:
IOException
-
setFeatureEncoder
-
buildCertificateReference
-
encodeDerTlv
-
getVdsType
-
getDocumentRef
-
encodeFeature
-