Class DataEncoder


  • public class DataEncoder
    extends Object
    • Constructor Detail

      • DataEncoder

        public DataEncoder()
    • Method Detail

      • getSignerCertRef

        public static String[] getSignerCertRef​(X509Certificate cert)
                                         throws InvalidNameException
        Return the Signer Identifier and the Certificate Reference based on the the given X.509. Signer Identifier is C + CN Certificate Reference is the serial number of the X509Certificate. It will be encoded as hexstring
        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)
                                 throws ParseException
        Parameters:
        dateString - Date as String formated as yyyy-MM-dd
        Returns:
        date encoded in 3 bytes
        Throws:
        ParseException - if dateString is not in format yyyy-MM-dd
      • 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)
      • setFeatureEncoder

        public static void setFeatureEncoder​(FeatureConverter featureEncoder)
      • buildCertificateReference

        public static byte[] buildCertificateReference​(X509Certificate cert)