1 package com.lowagie.bc.asn1; 2 3 import java.io.ByteArrayOutputStream; 4 import java.io.IOException; 5 6 11 public class DERTaggedObject 12 extends ASN1TaggedObject 13 { 14 18 public DERTaggedObject( 19 int tagNo, 20 DEREncodable obj) 21 { 22 super(tagNo, obj); 23 } 24 25 30 public DERTaggedObject( 31 boolean explicit, 32 int tagNo, 33 DEREncodable obj) 34 { 35 super(explicit, tagNo, obj); 36 } 37 38 42 public DERTaggedObject( 43 int tagNo) 44 { 45 super(false, tagNo, new DERSequence()); 46 } 47 48 void encode( 49 DEROutputStream out) 50 throws IOException 51 { 52 if (!empty) 53 { 54 ByteArrayOutputStream bOut = new ByteArrayOutputStream(); 55 DEROutputStream dOut = new DEROutputStream(bOut); 56 57 dOut.writeObject(obj); 58 dOut.close(); 59 60 byte[] bytes = bOut.toByteArray(); 61 62 if (explicit) 63 { 64 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, bytes); 65 } 66 else 67 { 68 if ((bytes[0] & CONSTRUCTED) != 0) 72 { 73 bytes[0] = (byte)(CONSTRUCTED | TAGGED | tagNo); 74 } 75 else 76 { 77 bytes[0] = (byte)(TAGGED | tagNo); 78 } 79 80 out.write(bytes); 81 } 82 } 83 else 84 { 85 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, new byte[0]); 86 } 87 } 88 } 89 | Popular Tags |