• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.bouncycastle.asn1;
2 
3 import java.io.IOException;
4 
5 /**
6  * A parser for indefinite-length application specific objects.
7  */
8 public class BERApplicationSpecificParser
9     implements ASN1ApplicationSpecificParser
10 {
11     private final int tag;
12     private final ASN1StreamParser parser;
13 
BERApplicationSpecificParser(int tag, ASN1StreamParser parser)14     BERApplicationSpecificParser(int tag, ASN1StreamParser parser)
15     {
16         this.tag = tag;
17         this.parser = parser;
18     }
19 
20     /**
21      * Return the object contained in this application specific object,
22      * @return the contained object.
23      * @throws IOException if the underlying stream cannot be read, or does not contain an ASN.1 encoding.
24      */
readObject()25     public ASN1Encodable readObject()
26         throws IOException
27     {
28         return parser.readObject();
29     }
30 
31     /**
32      * Return an in-memory, encodable, representation of the application specific object.
33      *
34      * @return a BERApplicationSpecific.
35      * @throws IOException if there is an issue loading the data.
36      */
getLoadedObject()37     public ASN1Primitive getLoadedObject()
38         throws IOException
39     {
40          return new BERApplicationSpecific(tag, parser.readVector());
41     }
42 
43     /**
44      * Return a BERApplicationSpecific representing this parser and its contents.
45      *
46      * @return a BERApplicationSpecific
47      */
toASN1Primitive()48     public ASN1Primitive toASN1Primitive()
49     {
50         try
51         {
52             return getLoadedObject();
53         }
54         catch (IOException e)
55         {
56             throw new ASN1ParsingException(e.getMessage(), e);
57         }
58     }
59 }
60