1 19 20 package com.maverick.crypto.asn1; 21 22 import java.io.ByteArrayInputStream ; 23 import java.io.ByteArrayOutputStream ; 24 import java.io.IOException ; 25 26 29 public class DERApplicationSpecific 30 extends DERObject 31 { 32 private int tag; 33 private byte[] octets; 34 35 public DERApplicationSpecific( 36 int tag, 37 byte[] octets) 38 { 39 this.tag = tag; 40 this.octets = octets; 41 } 42 43 public DERApplicationSpecific( 44 int tag, 45 DEREncodable object) 46 throws IOException 47 { 48 this.tag = tag | DERTags.CONSTRUCTED; 49 50 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 51 DEROutputStream dos = new DEROutputStream(baos); 52 53 dos.writeObject(object); 54 55 this.octets = baos.toByteArray(); 56 } 57 58 public boolean isConstructed() 59 { 60 return (tag & DERTags.CONSTRUCTED) != 0; 61 } 62 63 public byte[] getContents() 64 { 65 return octets; 66 } 67 68 public int getApplicationTag() 69 { 70 return tag & 0x1F; 71 } 72 73 public DERObject getObject() 74 throws IOException 75 { 76 return new ASN1InputStream(new ByteArrayInputStream (getContents())).readObject(); 77 } 78 79 82 void encode(DEROutputStream out) throws IOException 83 { 84 out.writeEncoded(DERTags.APPLICATION | tag, octets); 85 } 86 } 87 | Popular Tags |