01: package org.bouncycastle.asn1;
02:
03: import java.io.InputStream;
04: import java.io.IOException;
05:
06: public class ASN1ObjectParser {
07: private int _baseTag;
08: private int _tagNumber;
09:
10: private ASN1StreamParser _aIn;
11:
12: protected ASN1ObjectParser(int baseTag, int tagNumber,
13: InputStream contentStream) {
14: _baseTag = baseTag;
15: _tagNumber = tagNumber;
16: _aIn = new ASN1StreamParser(contentStream);
17: }
18:
19: /**
20: * Return the tag number for this object.
21: *
22: * @return the tag number.
23: */
24: int getTagNumber() {
25: return _tagNumber;
26: }
27:
28: int getBaseTag() {
29: return _baseTag;
30: }
31:
32: DEREncodable readObject() throws IOException {
33: return _aIn.readObject();
34: }
35:
36: ASN1EncodableVector readVector() throws IllegalStateException {
37: ASN1EncodableVector v = new ASN1EncodableVector();
38: DEREncodable obj;
39:
40: try {
41: while ((obj = readObject()) != null) {
42: v.add(obj.getDERObject());
43: }
44: } catch (IOException e) {
45: throw new IllegalStateException(e.getMessage());
46: }
47:
48: return v;
49: }
50: }
|