1 17 18 package org.apache.geronimo.util.asn1; 19 20 import java.io.IOException ; 21 import java.util.Enumeration ; 22 23 28 public class BERTaggedObject 29 extends DERTaggedObject 30 { 31 35 public BERTaggedObject( 36 int tagNo, 37 DEREncodable obj) 38 { 39 super(tagNo, obj); 40 } 41 42 47 public BERTaggedObject( 48 boolean explicit, 49 int tagNo, 50 DEREncodable obj) 51 { 52 super(explicit, tagNo, obj); 53 } 54 55 59 public BERTaggedObject( 60 int tagNo) 61 { 62 super(false, tagNo, new BERSequence()); 63 } 64 65 void encode( 66 DEROutputStream out) 67 throws IOException 68 { 69 if (out instanceof ASN1OutputStream || out instanceof BEROutputStream) 70 { 71 out.write(CONSTRUCTED | TAGGED | tagNo); 72 out.write(0x80); 73 74 if (!empty) 75 { 76 if (!explicit) 77 { 78 if (obj instanceof ASN1OctetString) 79 { 80 Enumeration e; 81 82 if (obj instanceof BERConstructedOctetString) 83 { 84 e = ((BERConstructedOctetString)obj).getObjects(); 85 } 86 else 87 { 88 ASN1OctetString octs = (ASN1OctetString)obj; 89 BERConstructedOctetString berO = new BERConstructedOctetString(octs.getOctets()); 90 91 e = berO.getObjects(); 92 } 93 94 while (e.hasMoreElements()) 95 { 96 out.writeObject(e.nextElement()); 97 } 98 } 99 else if (obj instanceof ASN1Sequence) 100 { 101 Enumeration e = ((ASN1Sequence)obj).getObjects(); 102 103 while (e.hasMoreElements()) 104 { 105 out.writeObject(e.nextElement()); 106 } 107 } 108 else if (obj instanceof ASN1Set) 109 { 110 Enumeration e = ((ASN1Set)obj).getObjects(); 111 112 while (e.hasMoreElements()) 113 { 114 out.writeObject(e.nextElement()); 115 } 116 } 117 else 118 { 119 throw new RuntimeException ("not implemented: " + obj.getClass().getName()); 120 } 121 } 122 else 123 { 124 out.writeObject(obj); 125 } 126 } 127 128 out.write(0x00); 129 out.write(0x00); 130 } 131 else 132 { 133 super.encode(out); 134 } 135 } 136 } 137 | Popular Tags |