1
/* see bouncycastle_license.txt */
3
package com.lowagie.bc.asn1;
5
import java.io.ByteArrayOutputStream;
6
import java.io.IOException;
7
import java.util.Enumeration;
9
public class DERConstructedSet
12
public DERConstructedSet()
17
* @param obj - a single object that makes up the set.
19
public DERConstructedSet(
26
* @param v - a vector of objects making up the set.
28
public DERConstructedSet(
31
for (int i = 0; i != v.size(); i++)
33
this.addObject(v.get(i));
37
public void addObject(
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 = this.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);