1 package org.bouncycastle.asn1;
6 public class BERConstructedOctetString
10 * convert a vector of octet strings into a single byte string
12 static private byte[] toBytes(
15 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
17 for (int i = 0; i != octs.size(); i++)
19 DEROctetString o = (DEROctetString)octs.elementAt(i);
23 bOut.write(o.getOctets());
27 throw new RuntimeException("exception converting octets " + e.toString());
31 return bOut.toByteArray();
37 * @param string the octets making up the octet string.
39 public BERConstructedOctetString(
45 public BERConstructedOctetString(
53 public BERConstructedOctetString(
59 public BERConstructedOctetString(
62 super(obj.getDERObject());
65 public byte[] getOctets()
70 public Vector getDEROctets()
74 octs = generateOcts();
80 private Vector generateOcts()
84 Vector vec = new Vector();
86 while (end < string.length)
88 if ((end + 1) < string.length)
90 if (string[end] == 0 && string[end + 1] == 0)
92 byte[] nStr = new byte[end - start + 1];
94 for (int i = 0; i != nStr.length; i++)
96 nStr[i] = string[start + i];
99 vec.addElement(new DEROctetString(nStr));
106 byte[] nStr = new byte[end - start];
107 for (int i = 0; i != nStr.length; i++)
109 nStr[i] = string[start + i];
112 vec.addElement(new DEROctetString(nStr));
121 if (out instanceof BEROutputStream)
123 out.write(CONSTRUCTED | OCTET_STRING);
129 octs = generateOcts();
132 for (int i = 0; i != octs.size(); i++)
134 out.writeObject(octs.elementAt(i));