public class BERInputStream
extends DERInputStream
{
- private DERObject END_OF_STREAM = new DERObject() {
- void encode(
- DEROutputStream out)
- throws IOException
- {
- throw new IOException("Eeek!");
- }
-
- };
+ private DERObject END_OF_STREAM = new DERObject() {
+ void encode(
+ DEROutputStream out)
+ throws IOException
+ {
+ throw new IOException("Eeek!");
+ }
+
+ };
public BERInputStream(
InputStream is)
{
while ((b = read()) >= 0)
{
- if (b1 == 0 && b == 0)
- {
- break;
- }
+ if (b1 == 0 && b == 0)
+ {
+ break;
+ }
bOut.write(b1);
b1 = b;
return bOut.toByteArray();
}
- private BERConstructedOctetString buildConstructedOctetString()
- throws IOException
- {
+ private BERConstructedOctetString buildConstructedOctetString()
+ throws IOException
+ {
Vector octs = new Vector();
- for (;;)
- {
- DERObject o = readObject();
+ for (;;)
+ {
+ DERObject o = readObject();
- if (o == END_OF_STREAM)
- {
- break;
- }
+ if (o == END_OF_STREAM)
+ {
+ break;
+ }
octs.addElement(o);
- }
+ }
- return new BERConstructedOctetString(octs);
- }
+ return new BERConstructedOctetString(octs);
+ }
public DERObject readObject()
throws IOException
case SEQUENCE | CONSTRUCTED:
BERConstructedSequence seq = new BERConstructedSequence();
- for (;;)
- {
- DERObject obj = readObject();
-
- if (obj == END_OF_STREAM)
- {
- break;
- }
-
- seq.addObject(obj);
- }
- return seq;
+ for (;;)
+ {
+ DERObject obj = readObject();
+
+ if (obj == END_OF_STREAM)
+ {
+ break;
+ }
+
+ seq.addObject(obj);
+ }
+ return seq;
case OCTET_STRING | CONSTRUCTED:
- return buildConstructedOctetString();
+ return buildConstructedOctetString();
case SET | CONSTRUCTED:
DEREncodableVector v = new DEREncodableVector();
- for (;;)
- {
- DERObject obj = readObject();
-
- if (obj == END_OF_STREAM)
- {
- break;
- }
-
- v.add(obj);
- }
- return new BERSet(v);
+ for (;;)
+ {
+ DERObject obj = readObject();
+
+ if (obj == END_OF_STREAM)
+ {
+ break;
+ }
+
+ v.add(obj);
+ }
+ return new BERSet(v);
default:
//
// with tagged object tag number is bottom 5 bits
//
// either constructed or explicitly tagged
//
- DERObject dObj = readObject();
+ DERObject dObj = readObject();
- if (dObj == END_OF_STREAM) // empty tag!
+ if (dObj == END_OF_STREAM) // empty tag!
{
return new DERTaggedObject(tag & 0x1f);
}
readFully(bytes);
- return buildObject(tag, bytes);
+ return buildObject(tag, bytes);
}
}
}