1 19 20 package com.maverick.crypto.asn1; 21 22 import java.io.ByteArrayOutputStream ; 23 import java.io.IOException ; 24 import java.util.Enumeration ; 25 26 29 public class DERSet 30 extends ASN1Set 31 { 32 35 public DERSet() 36 { 37 } 38 39 42 public DERSet( 43 DEREncodable obj) 44 { 45 this.addObject(obj); 46 } 47 48 51 public DERSet( 52 DEREncodableVector v) 53 { 54 for (int i = 0; i != v.size(); i++) 55 { 56 this.addObject(v.get(i)); 57 } 58 } 59 60 68 void encode( 69 DEROutputStream out) 70 throws IOException 71 { 72 ByteArrayOutputStream bOut = new ByteArrayOutputStream (); 73 DEROutputStream dOut = new DEROutputStream(bOut); 74 Enumeration e = this.getObjects(); 75 76 while (e.hasMoreElements()) 77 { 78 Object obj = e.nextElement(); 79 80 dOut.writeObject(obj); 81 } 82 83 dOut.close(); 84 85 byte[] bytes = bOut.toByteArray(); 86 87 out.writeEncoded(SET | CONSTRUCTED, bytes); 88 } 89 } 90 | Popular Tags |