1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
package org.uic.barcode.ssbFrame;
import org.uic.barcode.asn1.uper.BitBuffer;
import org.uic.barcode.asn1.uper.ByteBitBuffer;
public class SsbHeader extends SsbTicketPart {
private int version = 3;
private SsbTicketType ticketType = null;
private int keyId = 0;
private int issuer = 0;
/*
Version Num 0-4 Bits
Issuer code Num 14 Bits
ID Num 4 Bits
Ticket type code Num 5 Bits
*/
public SsbHeader(int version, SsbTicketType type, int keyId, int issuer) {
this.issuer = issuer;
this.keyId = keyId;
this.ticketType = type;
this.version = version;
}
public SsbHeader() {
}
public int decodeContent(byte[] headerData, int offset) {
BitBuffer bits = new ByteBitBuffer(headerData);
version = bits.getInteger(0, 4);
issuer = bits.getInteger(4, 14);
keyId = bits.getInteger(18, 4);
ticketType = SsbTicketType.values()[bits.getInteger(22, 5)];
return 4 + 14 + 4 + 5;
}
public int encodeContent(byte[] bytes, int offset) {
BitBuffer bits = new ByteBitBuffer(bytes);
bits.putInteger(0, 4, version);
bits.putInteger(4, 14, issuer);
bits.putInteger(18, 4, keyId);
bits.putInteger(22, 5, ticketType.ordinal());
return 4 + 14 + 4 + 5;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public SsbTicketType getTicketType() {
return ticketType;
}
public void setTicketType(SsbTicketType ticketType) {
this.ticketType = ticketType;
}
public int getKeyId() {
return keyId;
}
public void setKeyId(int keyId) {
this.keyId = keyId;
}
public int getIssuer() {
return issuer;
}
public void setIssuer(int issuer) {
this.issuer = issuer;
}
}
|