01: package org.bouncycastle.asn1;
02:
03: import java.io.ByteArrayOutputStream;
04: import java.io.IOException;
05: import java.util.Enumeration;
06:
07: /**
08: * @deprecated use DERSequence.
09: */
10: public class DERConstructedSequence extends ASN1Sequence {
11: public void addObject(DEREncodable obj) {
12: super .addObject(obj);
13: }
14:
15: public int getSize() {
16: return size();
17: }
18:
19: /*
20: * A note on the implementation:
21: * <p>
22: * As DER requires the constructed, definite-length model to
23: * be used for structured types, this varies slightly from the
24: * ASN.1 descriptions given. Rather than just outputing SEQUENCE,
25: * we also have to specify CONSTRUCTED, and the objects length.
26: */
27: void encode(DEROutputStream out) throws IOException {
28: ByteArrayOutputStream bOut = new ByteArrayOutputStream();
29: DEROutputStream dOut = new DEROutputStream(bOut);
30: Enumeration e = this .getObjects();
31:
32: while (e.hasMoreElements()) {
33: Object obj = e.nextElement();
34:
35: dOut.writeObject(obj);
36: }
37:
38: dOut.close();
39:
40: byte[] bytes = bOut.toByteArray();
41:
42: out.writeEncoded(SEQUENCE | CONSTRUCTED, bytes);
43: }
44: }
|