public class DERDecoder extends Object implements ASN1Decoder
Constructor and Description |
---|
DERDecoder(byte[] buf)
Create a DER decoder that will decode values from the given byte array.
|
DERDecoder(byte[] buf,
int offset,
int length)
Create a DER decoder that will decode values from the given byte array.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decodeBitString()
Decode the next ASN.1 element as a bit string.
|
BigInteger |
decodeBitStringAsInteger()
Decode the next ASN.1 element as a bit string where the value is a ASN.1 INTEGER.
|
String |
decodeBitStringAsString()
Decode the next ASN.1 element as a bit string.
|
String |
decodeBMPString()
Decode the next ASN.1 element as an BMPString.
|
byte[] |
decodeBMPStringAsBytes()
Decode the next ASN.1 element as an BMPString.
|
boolean |
decodeBoolean()
Decode the next ASN.1 element as a boolean value.
|
String |
decodeIA5String()
Decode the next ASN.1 element as an IA5 string.
|
byte[] |
decodeIA5StringAsBytes()
Decode the next ASN.1 element as an IA5 string.
|
void |
decodeImplicit(int number)
Indicate that the next ASN.1 element has the given implicit, context-specific tag.
|
void |
decodeImplicit(int clazz,
int number)
Indicate that the next ASN.1 element has the given implicit tag.
|
BigInteger |
decodeInteger()
Decode the next ASN.1 element as an integer.
|
void |
decodeNull()
Decode the next ASN.1 element as a null element.
|
String |
decodeObjectIdentifier()
Decode the next ASN.1 element as an object identifier.
|
String |
decodeObjectIdentifierAsKeyAlgorithm()
Decodes an OID and resolve its corresponding key algorithm.
|
byte[] |
decodeOctetString()
Decode the next ASN.1 element as an octet string.
|
String |
decodeOctetStringAsString()
Decode the next ASN.1 element as an octet string.
|
String |
decodeOctetStringAsString(String charSet)
Decode the next ASN.1 element as an octet string.
|
String |
decodePrintableString()
Decode the next ASN.1 element as a PrintableString.
|
byte[] |
decodePrintableStringAsBytes()
Decode the next ASN.1 element as a PrintableString.
|
String |
decodeUniversalString()
Decode the next ASN.1 element as an UniversalString.
|
byte[] |
decodeUniversalStringAsBytes()
Decode the next ASN.1 element as an UniversalString.
|
String |
decodeUtf8String()
Decode the next ASN.1 element as an UTF8String.
|
byte[] |
decodeUtf8StringAsBytes()
Decode the next ASN.1 element as an UTF8String.
|
byte[] |
drain()
Drain all of the remaining bytes from the input stream.
|
byte[] |
drainElement()
Drain all of the bytes from the next ASN.1 element.
|
byte[] |
drainElementValue()
Drain the value bytes from the next ASN.1 element.
|
void |
endExplicit()
Advance to the end of an explicitly tagged element.
|
void |
endSequence()
Advance to the end of a sequence.
|
void |
endSet()
Advance to the end of a set.
|
void |
endSetOf()
Advance to the end of a "set of" element.
|
boolean |
hasNextElement()
Determine if there is at least one more ASN.1 element that can be read.
|
boolean |
isNextType(int clazz,
int number,
boolean isConstructed)
Determine if the type of the next ASN.1 element matches the given type without
actually decoding the next element.
|
int |
peekType()
Retrieve the type of the next ASN.1 element without actually decoding
the next element.
|
void |
skipElement()
Skip over the next ASN.1 element.
|
void |
startExplicit(int number)
Start decoding an ASN.1 explicitly tagged element.
|
void |
startExplicit(int clazz,
int number)
Start decoding an ASN.1 explicitly tagged element.
|
void |
startSequence()
Start decoding an ASN.1 sequence.
|
void |
startSet()
Start decoding an ASN.1 set.
|
void |
startSetOf()
Start decoding an ASN.1 "set of" element.
|
public DERDecoder(byte[] buf)
buf
- the byte array to decodepublic DERDecoder(byte[] buf, int offset, int length)
buf
- the byte array to decodeoffset
- the offset in the byte array of the first byte to readlength
- the maximum number of bytes to read from the byte arraypublic void startSequence() throws ASN1Exception
ASN1Decoder
ASN1Decoder.endSequence()
is called.startSequence
in interface ASN1Decoder
ASN1Exception
- if the next element is not a sequencepublic void endSequence() throws ASN1Exception
ASN1Decoder
endSequence
in interface ASN1Decoder
ASN1Exception
- if an error occurs while advancing to the end of the sequencepublic void startSet() throws ASN1Exception
ASN1Decoder
ASN1Decoder.endSet()
is called.startSet
in interface ASN1Decoder
ASN1Exception
- if the next element is not a setpublic void endSet() throws ASN1Exception
ASN1Decoder
endSet
in interface ASN1Decoder
ASN1Exception
- if an error occurs while advancing to the end of the setpublic void startSetOf() throws ASN1Exception
ASN1Decoder
ASN1Decoder.endSetOf()
is called.startSetOf
in interface ASN1Decoder
ASN1Exception
- if the next element is not a setpublic void endSetOf() throws ASN1Exception
ASN1Decoder
endSetOf
in interface ASN1Decoder
ASN1Exception
- if an error occurs while advancing to the end of the setpublic void startExplicit(int number) throws ASN1Exception
ASN1Decoder
ASN1Decoder.endExplicit()
is called.startExplicit
in interface ASN1Decoder
number
- the tag number for the explicit, context-specific tagASN1Exception
- if the next element's type does not match the given typepublic void startExplicit(int clazz, int number) throws ASN1Exception
ASN1Decoder
ASN1Decoder.endExplicit()
is called.startExplicit
in interface ASN1Decoder
clazz
- the class for the explicit tagnumber
- the tag number for the explicit tagASN1Exception
- if the next element's type does not match the given typepublic void endExplicit() throws ASN1Exception
ASN1Decoder
endExplicit
in interface ASN1Decoder
ASN1Exception
- if an error occurs while advancing to the end of the explicitly
tagged elementpublic byte[] decodeOctetString() throws ASN1Exception
ASN1Decoder
decodeOctetString
in interface ASN1Decoder
ASN1Exception
- if the next element is not an octet stringpublic String decodeOctetStringAsString() throws ASN1Exception
ASN1Decoder
decodeOctetStringAsString
in interface ASN1Decoder
ASN1Exception
- if the next element is not an octet stringpublic String decodeOctetStringAsString(String charSet) throws ASN1Exception
ASN1Decoder
decodeOctetStringAsString
in interface ASN1Decoder
charSet
- the character set to use when decodingASN1Exception
- if the next element is not an octet stringpublic String decodeIA5String() throws ASN1Exception
ASN1Decoder
decodeIA5String
in interface ASN1Decoder
ASN1Exception
- if the next element is not an IA5 stringpublic byte[] decodeIA5StringAsBytes() throws ASN1Exception
ASN1Decoder
decodeIA5StringAsBytes
in interface ASN1Decoder
ASN1Exception
- if the next element is not an IA5 stringpublic byte[] decodeBitString() throws ASN1Exception
ASN1Decoder
decodeBitString
in interface ASN1Decoder
ASN1Exception
- if the next element is not a bit stringpublic BigInteger decodeBitStringAsInteger()
ASN1Decoder
decodeBitStringAsInteger
in interface ASN1Decoder
BigInteger
decoded from the bit stringpublic String decodeBitStringAsString() throws ASN1Exception
ASN1Decoder
decodeBitStringAsString
in interface ASN1Decoder
ASN1Exception
- if the next element is not a bit stringpublic String decodePrintableString() throws ASN1Exception
ASN1Decoder
decodePrintableString
in interface ASN1Decoder
ASN1Exception
- if the next element is not a PrintableStringpublic byte[] decodePrintableStringAsBytes() throws ASN1Exception
ASN1Decoder
decodePrintableStringAsBytes
in interface ASN1Decoder
ASN1Exception
- if the next element is not a PrintableStringpublic String decodeUniversalString() throws ASN1Exception
ASN1Decoder
decodeUniversalString
in interface ASN1Decoder
ASN1Exception
- if the next element is not a UniversalStringpublic byte[] decodeUniversalStringAsBytes() throws ASN1Exception
ASN1Decoder
decodeUniversalStringAsBytes
in interface ASN1Decoder
ASN1Exception
- if the next element is not a UniversalStringpublic String decodeUtf8String() throws ASN1Exception
ASN1Decoder
decodeUtf8String
in interface ASN1Decoder
ASN1Exception
- if the next element is not a UTF8Stringpublic byte[] decodeUtf8StringAsBytes() throws ASN1Exception
ASN1Decoder
decodeUtf8StringAsBytes
in interface ASN1Decoder
ASN1Exception
- if the next element is not a UTF8Stringpublic String decodeBMPString() throws ASN1Exception
ASN1Decoder
decodeBMPString
in interface ASN1Decoder
ASN1Exception
- if the next element is not a BMPStringpublic byte[] decodeBMPStringAsBytes() throws ASN1Exception
ASN1Decoder
decodeBMPStringAsBytes
in interface ASN1Decoder
ASN1Exception
- if the next element is not a BMPStringpublic String decodeObjectIdentifier() throws ASN1Exception
ASN1Decoder
decodeObjectIdentifier
in interface ASN1Decoder
ASN1Exception
- if the next element is not a bit stringpublic BigInteger decodeInteger() throws ASN1Exception
ASN1Decoder
decodeInteger
in interface ASN1Decoder
ASN1Exception
- if the next element is not an integerpublic void decodeNull() throws ASN1Exception
ASN1Decoder
decodeNull
in interface ASN1Decoder
ASN1Exception
- if the next element is not nullpublic void decodeImplicit(int number)
ASN1Decoder
decodeImplicit
in interface ASN1Decoder
number
- the tag number for the implicit tagpublic void decodeImplicit(int clazz, int number)
ASN1Decoder
decodeImplicit
in interface ASN1Decoder
clazz
- the class for the implicit tagnumber
- the tag number for the implicit tagpublic boolean decodeBoolean() throws ASN1Exception
ASN1Decoder
decodeBoolean
in interface ASN1Decoder
ASN1Exception
- if the next element is not a boolean valuepublic boolean isNextType(int clazz, int number, boolean isConstructed)
ASN1Decoder
isNextType
in interface ASN1Decoder
clazz
- the tag class to match againstnumber
- the tag number to match againstisConstructed
- whether or not the next element should be constructedtrue
if the type of the next ASN.1 element matches the given type
and false
otherwisepublic int peekType() throws ASN1Exception
ASN1Decoder
peekType
in interface ASN1Decoder
ASN1Exception
- if an error occurs while determining the type of the next elementpublic void skipElement() throws ASN1Exception
ASN1Decoder
skipElement
in interface ASN1Decoder
ASN1Exception
- if the next element cannot be skippedpublic boolean hasNextElement()
ASN1Decoder
hasNextElement
in interface ASN1Decoder
true
if there is at least one more ASN.1 element that can be read and false
otherwisepublic byte[] drainElementValue() throws ASN1Exception
ASN1Decoder
drainElementValue
in interface ASN1Decoder
ASN1Exception
- if the value bytes from the next ASN.1 element cannot be obtainedpublic byte[] drainElement() throws ASN1Exception
ASN1Decoder
drainElement
in interface ASN1Decoder
ASN1Exception
- if the bytes from the next ASN.1 element cannot be obtainedpublic byte[] drain()
ASN1Decoder
drain
in interface ASN1Decoder
public String decodeObjectIdentifierAsKeyAlgorithm()
Copyright © 2021 JBoss by Red Hat. All rights reserved.