summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java')
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java b/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
index 2ea4a51..48c8eaf 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.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 SsbHeader extends SsbTicketPart {
@@ -40,13 +41,28 @@ public class SsbHeader extends SsbTicketPart {
}
- public int encodeContent(byte[] bytes, int offset) {
+ public int encodeContent(byte[] bytes, int offset) throws EncodingFormatException {
BitBuffer bits = new ByteBitBuffer(bytes);
+ if (version < 0 || version > 15) {
+ throw new EncodingFormatException("SSB Version too big");
+ }
+
bits.putInteger(0, 4, version);
+
+ if (issuer < 0 || issuer > 9999) {
+ throw new EncodingFormatException("SSB Issuer code too big");
+ }
+
bits.putInteger(4, 14, issuer);
+
+ if (keyId < 0 || keyId > 15) {
+ throw new EncodingFormatException("SSB Key Id too big");
+ }
+
bits.putInteger(18, 4, keyId);
+
bits.putInteger(22, 5, ticketType.ordinal());
return 4 + 14 + 4 + 5;