From 8f7af5fde7283b519a2efccdaf84c63ecd9c680d Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Fri, 18 Dec 2020 17:20:12 +0100 Subject: FCB version number missmatch corrected supported FCB version 13 ( = asn 1.3) supported FCB version 02 ( = asn 2.0) reading FCB supported version 01 ( = asn 1.3) --- src/org/uic/ticket/UicRailTicketCoder.java | 49 ++-------------------- .../omv1/uicBarcodeV1finalDelayConfirmation1.3.asn | 2 +- .../uic/ticket/api/utils/Api2OpenAsnEncoderV2.java | 4 +- 3 files changed, 8 insertions(+), 47 deletions(-) (limited to 'src/org/uic/ticket') diff --git a/src/org/uic/ticket/UicRailTicketCoder.java b/src/org/uic/ticket/UicRailTicketCoder.java index 82a546f..a4dc97f 100644 --- a/src/org/uic/ticket/UicRailTicketCoder.java +++ b/src/org/uic/ticket/UicRailTicketCoder.java @@ -19,47 +19,6 @@ import org.uic.ticket.api.utils.OpenAsn2ApiDecoderV2; * The Class UicRailTicketCoder. */ public class UicRailTicketCoder { - - - /** - * encode an UicRailTicket to asn.1 format using PER unaligned encoding - * - * @param outputStream the output stream for the encoded data - * @param uicRailTicket the uic rail ticket to be encoded - * @param version version of the asn1 specification - * @throws IOException signals that an I/O exception has occurred. - * @throws EncodingFormatException signals that a format rule of the asn.1 specification was violated. - */ - public byte[] encodeTag(IUicRailTicket uicRailTicket, int version) throws IOException, EncodingFormatException { - - - byte[] content = encode(uicRailTicket, version); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - String idTag = "U_FLEX"; - String versionId = "01"; - int length = 8; - - //size of data - length = length + content.length; - - //size of length element - length = length + 4; - String lengthElement = String.format("%04d",length); - - outputStream.write(idTag.getBytes()); - outputStream.write(versionId.getBytes()); - outputStream.write(lengthElement.getBytes()); - - outputStream.write(content); - - return outputStream.toByteArray(); - -} - - - /** * encode an UicRailTicket to asn.1 format using PER unaligned encoding @@ -73,7 +32,7 @@ public class UicRailTicketCoder { public byte[] encode (IUicRailTicket uicRailTicket, int version) throws IOException, EncodingFormatException{ - if (version == 1) { + if (version == 13) { Api2OpenAsnEncoder uicEncoder = new Api2OpenAsnEncoder(); @@ -107,7 +66,7 @@ public class UicRailTicketCoder { - if (version == 1) { + if (version == 13) { Api2OpenAsnEncoder uicEncoder = new Api2OpenAsnEncoder(); @@ -144,7 +103,7 @@ public class UicRailTicketCoder { */ public IUicRailTicket decodeFromAsn (byte[] byteData, int version) throws IOException, EncodingFormatException{ - if (version == 1) { + if (version == 1 || version == 13) { OpenAsn2ApiDecoder uicDecoder = new OpenAsn2ApiDecoder(); @@ -177,7 +136,7 @@ public class UicRailTicketCoder { */ public IUicRailTicket decodeFromAsn (InputStream input, int version) throws IOException, EncodingFormatException{ - if (version != 1) { + if (version != 1 && version != 2 && version != 13) { throw new EncodingFormatException(String.format("Encoding version %d not supported", version)); } diff --git a/src/org/uic/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn b/src/org/uic/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn index c850c75..dfb9be0 100644 --- a/src/org/uic/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn +++ b/src/org/uic/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn @@ -9,7 +9,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN -- ############################################################################################## -- # --- # Final version 1.3 - value 1 in the UIC bar code version element +-- # Final version 1.3 - value 13 in the UIC bar code version element -- # (see element 2 in U_FLEX record definition in leaflet 918.9) -- # -- ############################################################################################## diff --git a/src/org/uic/ticket/api/utils/Api2OpenAsnEncoderV2.java b/src/org/uic/ticket/api/utils/Api2OpenAsnEncoderV2.java index c651192..7e5a6dc 100644 --- a/src/org/uic/ticket/api/utils/Api2OpenAsnEncoderV2.java +++ b/src/org/uic/ticket/api/utils/Api2OpenAsnEncoderV2.java @@ -2215,7 +2215,9 @@ public class Api2OpenAsnEncoderV2 { asnTraveler.setFirstName(traveler.getFirstName()); asnTraveler.setSecondName(traveler.getSecondName()); asnTraveler.setLastName(traveler.getLastName()); - asnTraveler.setGender(GenderType.valueOf(traveler.getGender().toString())); + if (traveler.getGender() != null) { + asnTraveler.setGender(GenderType.valueOf(traveler.getGender().toString())); + } asnTraveler.setIdCard(UicEncoderUtils.getIA5(traveler.getIdCard())); asnTraveler.setPassportId(UicEncoderUtils.getIA5(traveler.getPassportId())); asnTraveler.setTitle(UicEncoderUtils.getIA5(traveler.getTitle())); -- cgit v1.2.3