1 package org.bouncycastle.asn1;
6 public class DERConstructedSet
9 private Vector set = new Vector();
11 public DERConstructedSet()
15 public void addObject(
21 public Enumeration getObjects()
23 return set.elements();
27 * return the object at the set postion indicated by index.
29 * @param the set number (starting at zero) of the object
30 * @return the object at the set postion indicated by index.
32 public Object getObjectAt(
35 return set.elementAt(index);
39 * return the number of objects in this set.
41 * @return the number of objects in this set.
49 * A note on the implementation:
51 * As DER requires the constructed, definite-length model to
52 * be used for structured types, this varies slightly from the
53 * ASN.1 descriptions given. Rather than just outputing SET,
54 * we also have to specify CONSTRUCTED, and the objects length.
60 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
61 DEROutputStream dOut = new DEROutputStream(bOut);
62 Enumeration e = getObjects();
64 while (e.hasMoreElements())
66 Object obj = e.nextElement();
68 dOut.writeObject(obj);
73 byte[] bytes = bOut.toByteArray();
75 out.writeEncoded(SET | CONSTRUCTED, bytes);