diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-14 10:15:31 +0100 |
---|---|---|
committer | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-14 10:15:31 +0100 |
commit | f1a08e7fb82e813ce6985460cc2606fc7b19ae13 (patch) | |
tree | 5b68ec0289b228cef09420fc985043ff33105951 /src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java | |
parent | ssb non-standard signature encoding covered (decode only) (diff) | |
download | UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.gz UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.bz2 UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.lz UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.xz UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.tar.zst UIC-barcode-f1a08e7fb82e813ce6985460cc2606fc7b19ae13.zip |
Diffstat (limited to '')
-rw-r--r-- | src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java b/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java index 73017d7..c70c2d1 100644 --- a/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java +++ b/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java @@ -2,6 +2,7 @@ package org.uic.barcode.ssbFrame; import org.uic.barcode.asn1.uper.BitBuffer; import org.uic.barcode.asn1.uper.ByteBitBuffer; +import org.uic.barcode.ticket.EncodingFormatException; public class SsbReservation extends SsbCommonTicketPart { @@ -81,12 +82,15 @@ public class SsbReservation extends SsbCommonTicketPart { } @Override - protected int encodeContent(byte[] bytes, int offset) { + protected int encodeContent(byte[] bytes, int offset) throws EncodingFormatException { offset = offset + encodeCommonPart(bytes, offset); BitBuffer bits = new ByteBitBuffer(bytes); + if (ticketSubType < 0 || ticketSubType > 3) { + throw new EncodingFormatException("SSB pass type too big"); + } bits.putInteger(offset, 2,ticketSubType); offset = offset + 2; @@ -103,27 +107,48 @@ public class SsbReservation extends SsbCommonTicketPart { Open Tekst 6 Bit ASCII (27 Car) 162,000 */ + if (departureDate < 0 || departureDate > 512) { + throw new EncodingFormatException("SSB departure date too big"); + } bits.putInteger(offset, 9, departureDate); offset = offset + 9; + if (departureTime < 0 || departureTime > 1440) { + throw new EncodingFormatException("SSB departure time too big"); + } bits.putInteger(offset, 11,departureTime); offset = offset + 11; + if (train.length() > 5) { + throw new EncodingFormatException("SSB train too big"); + } bits.putChar6String(offset, 30,train); offset = offset + 30; + if (coach < 0 || coach > 999) { + throw new EncodingFormatException("SSB coach too big"); + } bits.putInteger(offset, 10,coach); offset = offset + 10; + if (place.length() > 3) { + throw new EncodingFormatException("SSB coach too big"); + } bits.putChar6String(offset, 18,place); offset = offset + 18; bits.put(offset, overbooking); offset++; + if (infoCode < 0 || infoCode > 9999) { + throw new EncodingFormatException("SSB info code too big"); + } bits.putInteger(offset, 14, infoCode); offset = offset + 14; + if (text.length() > 27) { + throw new EncodingFormatException("SSB text too big"); + } bits.putChar6String(offset, 162, text); offset = offset + 162; |