- @Override
- public void marshal(Data data, DataOutputStream os) throws IOException {
- writeHeader(os,MAGIC,VERSION);
- writeString(os, data.id);
- writeString(os, data.x500);
- writeString(os, data.x509);
- writeString(os, data.ca);
- if(data.serial==null) {
- os.writeInt(-1);
- } else {
- byte[] dsba = data.serial.toByteArray();
- int l = dsba.length;
- os.writeInt(l);
- os.write(dsba,0,l);
- }
- }
-
- @Override
- public void unmarshal(Data data, DataInputStream is) throws IOException {
- /*int version = */readHeader(is,MAGIC,VERSION);
- // If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
- byte[] buff = new byte[BUFF_SIZE];
- data.id = readString(is,buff);
- data.x500 = readString(is,buff);
- data.x509 = readString(is,buff);
- data.ca = readString(is,buff);
- int i = is.readInt();
- if(i<0) {
- data.serial=null;
- } else {
- byte[] bytes = new byte[i]; // a bit dangerous, but lessened because of all the previous sized data reads
- is.read(bytes);
- data.serial = new BigInteger(bytes);
- }
- }
+ @Override
+ public void marshal(Data data, DataOutputStream os) throws IOException {
+ writeHeader(os,MAGIC,VERSION);
+ writeString(os, data.id);
+ writeString(os, data.x500);
+ writeString(os, data.x509);
+ writeString(os, data.ca);
+ if (data.serial==null) {
+ os.writeInt(-1);
+ } else {
+ byte[] dsba = data.serial.toByteArray();
+ int l = dsba.length;
+ os.writeInt(l);
+ os.write(dsba,0,l);
+ }
+ }
+
+ @Override
+ public void unmarshal(Data data, DataInputStream is) throws IOException {
+ /*int version = */readHeader(is,MAGIC,VERSION);
+ // If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
+ byte[] buff = new byte[BUFF_SIZE];
+ data.id = readString(is,buff);
+ data.x500 = readString(is,buff);
+ data.x509 = readString(is,buff);
+ data.ca = readString(is,buff);
+ int i = is.readInt();
+ data.serial=null;
+ if (i>=0) {
+ byte[] bytes = new byte[i]; // a bit dangerous, but lessened because of all the previous sized data reads
+ if (is.read(bytes)>0) {
+ data.serial = new BigInteger(bytes);
+ }
+ }
+ }