Class DataEncoder

java.lang.Object
de.tsenger.vdstools.DataEncoder

public class DataEncoder extends Object
  • Constructor Details

    • DataEncoder

      public DataEncoder()
  • Method Details

    • getSignerCertRef

      public static String[] getSignerCertRef(X509Certificate cert) throws InvalidNameException
      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

      public static byte[] encodeDate(String dateString)
      Parameters:
      dateString - Date as String formated as yyyy-MM-dd
      Returns:
      date encoded in 3 bytes
    • encodeDate

      public static byte[] encodeDate(LocalDate localDate)
      Encode a LocalDate as described in ICAO Doc9303 Part 13 in three bytes
      Parameters:
      localDate - Date
      Returns:
      date encoded in 3 bytes
    • encodeDateTime

      public static byte[] encodeDateTime(LocalDateTime localDatetime)
      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

      public static byte[] encodeMaskedDate(String dateString)
      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

      public static byte[] encodeC40(String dataString)
    • toUnsignedInt

      public static int toUnsignedInt(byte value)
    • encodeBase256

      public static String encodeBase256(byte[] ba)
    • zip

      public static byte[] zip(byte[] bytesToCompress) throws IOException
      Throws:
      IOException
    • setFeatureEncoder

      public static void setFeatureEncoder(FeatureConverter featureEncoder)
    • buildCertificateReference

      public static byte[] buildCertificateReference(X509Certificate cert)
    • encodeDerTlv

      public static Feature encodeDerTlv(String vdsType, DerTlv derTlv)
    • getVdsType

      public static String getVdsType(int documentRef)
    • getDocumentRef

      public static int getDocumentRef(String vdsType)
    • encodeFeature

      public static <T> DerTlv encodeFeature(String vdsType, String feature, T value)