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