01: package org.bouncycastle.sasn1;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05:
06: /**
07: * @deprecated use corresponsding classes in org.bouncycastle.asn1.
08: */
09: public class Asn1TaggedObject extends Asn1Object {
10: protected Asn1TaggedObject(int baseTag, int tagNumber,
11: InputStream contentStream) {
12: super (baseTag, tagNumber, contentStream);
13: }
14:
15: public Asn1Object getObject(int tag, boolean isExplicit)
16: throws IOException {
17: if (isExplicit) {
18: return new Asn1InputStream(this .getRawContentStream())
19: .readObject();
20: } else {
21: switch (tag) {
22: case BerTag.SET:
23: if (this .getRawContentStream() instanceof IndefiniteLengthInputStream) {
24: return new BerSet(BerTag.CONSTRUCTED, this
25: .getRawContentStream());
26: } else {
27: return new DerSet(BerTag.CONSTRUCTED,
28: ((DefiniteLengthInputStream) this
29: .getRawContentStream())
30: .toByteArray());
31: }
32: case BerTag.SEQUENCE:
33: if (this .getRawContentStream() instanceof IndefiniteLengthInputStream) {
34: return new BerSequence(BerTag.CONSTRUCTED, this
35: .getRawContentStream());
36: } else {
37: return new DerSequence(BerTag.CONSTRUCTED,
38: ((DefiniteLengthInputStream) this
39: .getRawContentStream())
40: .toByteArray());
41: }
42: case BerTag.OCTET_STRING:
43: if (this .getRawContentStream() instanceof IndefiniteLengthInputStream) {
44: return new BerOctetString(BerTag.CONSTRUCTED, this
45: .getRawContentStream());
46: } else {
47: if (this .isConstructed()) {
48: return new DerOctetString(BerTag.CONSTRUCTED,
49: ((DefiniteLengthInputStream) this
50: .getRawContentStream())
51: .toByteArray());
52: } else {
53: return new DerOctetString(
54: BerTagClass.UNIVERSAL,
55: ((DefiniteLengthInputStream) this
56: .getRawContentStream())
57: .toByteArray());
58: }
59: }
60: }
61: }
62:
63: throw new RuntimeException("implicit tagging not implemented");
64: }
65: }
|