1 package org.bouncycastle.asn1;
6 * DER TaggedObject - in ASN.1 nottation this is any object proceeded by
7 * a [n] where n is some number - these are assume to follow the construction
8 * rules (as with sequences).
10 public class DERTaggedObject
14 boolean empty = false;
15 boolean explicit = true;
16 DEREncodable obj = null;
19 * This creates an empty tagged object of tagNo (ie. zero length).
21 * @param tagNo the tag number for this object.
23 public DERTaggedObject(
32 * @param tagNo the tag number for this object.
33 * @param obj the tagged object.
35 public DERTaggedObject(
45 * @param explicit true if the object is explicitly tagged.
46 * @param tagNo the tag number for this object.
47 * @param obj the tagged object.
49 public DERTaggedObject(
54 this.explicit = explicit;
64 public boolean isExplicit()
69 public boolean isEmpty()
74 public DERObject getObject()
76 return obj.getDERObject();
85 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
86 DEROutputStream dOut = new DEROutputStream(bOut);
88 dOut.writeObject(obj);
91 byte[] bytes = bOut.toByteArray();
95 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, bOut.toByteArray());
100 // need to mark constructed types...
102 if ((bytes[0] & CONSTRUCTED) != 0)
104 bytes[0] = (byte)(CONSTRUCTED | TAGGED | tagNo);
108 bytes[0] = (byte)(TAGGED | tagNo);
116 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, new byte[0]);