001 package org.apache.commons.ssl.asn1; 002 003 import java.io.IOException; 004 import java.io.InputStream; 005 006 public class ASN1ObjectParser { 007 private int _baseTag; 008 private int _tagNumber; 009 010 private ASN1StreamParser _aIn; 011 012 protected ASN1ObjectParser( 013 int baseTag, 014 int tagNumber, 015 InputStream contentStream) { 016 _baseTag = baseTag; 017 _tagNumber = tagNumber; 018 _aIn = new ASN1StreamParser(contentStream); 019 } 020 021 /** 022 * Return the tag number for this object. 023 * 024 * @return the tag number. 025 */ 026 int getTagNumber() { 027 return _tagNumber; 028 } 029 030 int getBaseTag() { 031 return _baseTag; 032 } 033 034 DEREncodable readObject() 035 throws IOException { 036 return _aIn.readObject(); 037 } 038 039 ASN1EncodableVector readVector() 040 throws IllegalStateException { 041 ASN1EncodableVector v = new ASN1EncodableVector(); 042 DEREncodable obj; 043 044 try { 045 while ((obj = readObject()) != null) { 046 v.add(obj.getDERObject()); 047 } 048 } 049 catch (IOException e) { 050 throw new IllegalStateException(e.getMessage()); 051 } 052 053 return v; 054 } 055 }