1 17 18 package org.apache.geronimo.util.asn1; 19 20 import java.io.ByteArrayOutputStream ; 21 import java.io.IOException ; 22 import java.util.Enumeration ; 23 24 27 public class DERSet 28 extends ASN1Set 29 { 30 33 public DERSet() 34 { 35 } 36 37 40 public DERSet( 41 DEREncodable obj) 42 { 43 this.addObject(obj); 44 } 45 46 49 public DERSet( 50 DEREncodableVector v) 51 { 52 this(v, true); 53 } 54 55 58 public DERSet( 59 ASN1Encodable[] a) 60 { 61 for (int i = 0; i != a.length; i++) 62 { 63 this.addObject(a[i]); 64 } 65 66 this.sort(); 67 } 68 69 72 DERSet( 73 DEREncodableVector v, 74 boolean needsSorting) 75 { 76 for (int i = 0; i != v.size(); i++) 77 { 78 this.addObject(v.get(i)); 79 } 80 81 if (needsSorting) 82 { 83 this.sort(); 84 } 85 } 86 87 95 void encode( 96 DEROutputStream out) 97 throws IOException 98 { 99 ByteArrayOutputStream bOut = new ByteArrayOutputStream (); 100 DEROutputStream dOut = new DEROutputStream(bOut); 101 Enumeration e = this.getObjects(); 102 103 while (e.hasMoreElements()) 104 { 105 Object obj = e.nextElement(); 106 107 dOut.writeObject(obj); 108 } 109 110 dOut.close(); 111 112 byte[] bytes = bOut.toByteArray(); 113 114 out.writeEncoded(SET | CONSTRUCTED, bytes); 115 } 116 } 117 | Popular Tags |