1 17 18 package org.apache.geronimo.util.asn1; 19 20 import java.io.ByteArrayOutputStream ; 21 import java.io.IOException ; 22 23 28 public class DERTaggedObject 29 extends ASN1TaggedObject 30 { 31 35 public DERTaggedObject( 36 int tagNo, 37 DEREncodable obj) 38 { 39 super(tagNo, obj); 40 } 41 42 47 public DERTaggedObject( 48 boolean explicit, 49 int tagNo, 50 DEREncodable obj) 51 { 52 super(explicit, tagNo, obj); 53 } 54 55 59 public DERTaggedObject( 60 int tagNo) 61 { 62 super(false, tagNo, new DERSequence()); 63 } 64 65 void encode( 66 DEROutputStream out) 67 throws IOException 68 { 69 if (!empty) 70 { 71 ByteArrayOutputStream bOut = new ByteArrayOutputStream (); 72 DEROutputStream dOut = new DEROutputStream(bOut); 73 74 dOut.writeObject(obj); 75 dOut.close(); 76 77 byte[] bytes = bOut.toByteArray(); 78 79 if (explicit) 80 { 81 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, bytes); 82 } 83 else 84 { 85 if ((bytes[0] & CONSTRUCTED) != 0) 89 { 90 bytes[0] = (byte)(CONSTRUCTED | TAGGED | tagNo); 91 } 92 else 93 { 94 bytes[0] = (byte)(TAGGED | tagNo); 95 } 96 97 out.write(bytes); 98 } 99 } 100 else 101 { 102 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, new byte[0]); 103 } 104 } 105 } 106 | Popular Tags |