diff options
author | David Hook <dgh@cryptoworkshop.com> | 2013-05-31 11:07:45 +0400 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2013-05-31 11:07:45 +0400 |
commit | 2b976f5364cfdbc37d3086019d93483c983eb80b (patch) | |
tree | cb846af3fd1d43f9c2562a1fb2d06b997ad8f229 /core/src/main/java/org/bouncycastle/asn1/BERTaggedObjectParser.java | |
parent | 5f714bd92fbd780d22406f4bc3681be005f6f04a (diff) |
initial reshuffle
Diffstat (limited to 'core/src/main/java/org/bouncycastle/asn1/BERTaggedObjectParser.java')
-rw-r--r-- | core/src/main/java/org/bouncycastle/asn1/BERTaggedObjectParser.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/core/src/main/java/org/bouncycastle/asn1/BERTaggedObjectParser.java b/core/src/main/java/org/bouncycastle/asn1/BERTaggedObjectParser.java new file mode 100644 index 00000000..7cd334a4 --- /dev/null +++ b/core/src/main/java/org/bouncycastle/asn1/BERTaggedObjectParser.java @@ -0,0 +1,66 @@ +package org.bouncycastle.asn1; + +import java.io.IOException; + +public class BERTaggedObjectParser + implements ASN1TaggedObjectParser +{ + private boolean _constructed; + private int _tagNumber; + private ASN1StreamParser _parser; + + BERTaggedObjectParser( + boolean constructed, + int tagNumber, + ASN1StreamParser parser) + { + _constructed = constructed; + _tagNumber = tagNumber; + _parser = parser; + } + + public boolean isConstructed() + { + return _constructed; + } + + public int getTagNo() + { + return _tagNumber; + } + + public ASN1Encodable getObjectParser( + int tag, + boolean isExplicit) + throws IOException + { + if (isExplicit) + { + if (!_constructed) + { + throw new IOException("Explicit tags must be constructed (see X.690 8.14.2)"); + } + return _parser.readObject(); + } + + return _parser.readImplicit(_constructed, tag); + } + + public ASN1Primitive getLoadedObject() + throws IOException + { + return _parser.readTaggedObject(_constructed, _tagNumber); + } + + public ASN1Primitive toASN1Primitive() + { + try + { + return this.getLoadedObject(); + } + catch (IOException e) + { + throw new ASN1ParsingException(e.getMessage()); + } + } +} |