public BERConstructedOctetString(
byte[] string)
{
- super(string);
+ super(string);
}
public BERConstructedOctetString(
Vector octs)
{
- super(toBytes(octs));
+ super(toBytes(octs));
this.octs = octs;
}
public BERConstructedOctetString(
DERObject obj)
{
- super(obj);
+ super(obj);
}
public BERConstructedOctetString(
return string;
}
- public Vector getDEROctets()
+ /**
+ * return the DER octets that make up this string.
+ */
+ public Enumeration getObjects()
{
if (octs == null)
{
octs = generateOcts();
}
- return octs;
+ return octs.elements();
}
private Vector generateOcts()
int end = 0;
Vector vec = new Vector();
- while (end < string.length)
+ while ((end + 1) < string.length)
{
- if ((end + 1) < string.length)
+ if (string[end] == 0 && string[end + 1] == 0)
{
- if (string[end] == 0 && string[end + 1] == 0)
- {
- byte[] nStr = new byte[end - start + 1];
+ byte[] nStr = new byte[end - start + 1];
- for (int i = 0; i != nStr.length; i++)
- {
- nStr[i] = string[start + i];
- }
-
- vec.addElement(new DEROctetString(nStr));
- start = end + 1;
+ for (int i = 0; i != nStr.length; i++)
+ {
+ nStr[i] = string[start + i];
}
+
+ vec.addElement(new DEROctetString(nStr));
+ start = end + 1;
}
end++;
}
- byte[] nStr = new byte[end - start];
+ byte[] nStr = new byte[string.length - start];
for (int i = 0; i != nStr.length; i++)
{
nStr[i] = string[start + i];
DEROutputStream out)
throws IOException
{
- if (out instanceof BEROutputStream)
- {
+ if (out instanceof ASN1OutputStream || out instanceof BEROutputStream)
+ {
out.write(CONSTRUCTED | OCTET_STRING);
out.write(0x80);
out.write(0x00);
out.write(0x00);
- }
- else
- {
- super.encode(out);
- }
+ }
+ else
+ {
+ super.encode(out);
+ }
}
}