public class DerInputStreamHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static byte |
MASK_CONSTRUCTED
Mask for constructed types.
|
static byte |
MASK_CONTEXT
Mask for explicit tagging.
|
static byte |
tag_BitString
Tag value indicating an ASN.1 "BIT STRING" value.
|
static byte |
tag_BMPString
Tag value indicating an ASN.1 "BMPString" value.
|
static byte |
tag_Boolean
Tag value indicating an ASN.1 "BOOLEAN" value.
|
static byte |
tag_Enumerated
Tag value including an ASN.1 "ENUMERATED" value
|
static byte |
tag_GeneralizedTime
Tag value indicating an ASN.1 "GeneralizedTime" value.
|
static byte |
tag_GeneralString
Tag value indicating an ASN.1 "GenerallString" value.
|
static byte |
tag_IA5String
Tag value including an ASCII string
|
static byte |
tag_Integer
Tag value indicating an ASN.1 "INTEGER" value.
|
static byte |
tag_Null
Tag value indicating an ASN.1 "NULL" value.
|
static byte |
tag_ObjectId
Tag value indicating an ASN.1 "OBJECT IDENTIFIER" value.
|
static byte |
tag_OctetString
Tag value indicating an ASN.1 "OCTET STRING" value.
|
static byte |
tag_PrintableString
Tag value including a "printable" string
|
static byte |
tag_Sequence
Tag value indicating an ASN.1 "SEQUENCE" (zero to N elements, order is significant).
|
static byte |
tag_SequenceOf
Tag value indicating an ASN.1 "SEQUENCE OF" (one to N elements, order is significant).
|
static byte |
tag_Set
Tag value indicating an ASN.1 "SET" (zero to N members, order does not matter).
|
static byte |
tag_SetOf
Tag value indicating an ASN.1 "SET OF" (one to N members, order does not matter).
|
static byte |
tag_T61String
Tag value including a "teletype" string
|
static byte |
tag_UniversalString
Tag value indicating an ASN.1 "UniversalString" value.
|
static byte |
tag_UtcTime
Tag value indicating an ASN.1 "UTCTime" value.
|
static byte |
tag_UTF8String
Tag value indicating an ASN.1 "UTF8String" value.
|
Constructor and Description |
---|
DerInputStreamHelper() |
Modifier and Type | Method and Description |
---|---|
static int |
expectTag(byte expectedTag,
java.io.InputStream stream)
Reads next byte from the InputStream and verifies if the tag matches the expected tag.
|
static byte[] |
readBitString(java.io.InputStream is)
Reads the next DER-encoded BitString value from the specified InputStream, and returns it as a byte[].
|
static boolean |
readBoolean(java.io.InputStream is)
Reads the next DER-encoded Boolean value from the specified InputStream, and returns it as an boolean.
|
static int |
readDERLength(java.io.InputStream in)
Reads a DER-encoded value length from an input stream.
|
static void |
readFully(java.io.InputStream in,
byte[] b,
int off,
int len)
See the general contract of the
readFully method of DataInput . |
static int |
readInteger(java.io.InputStream is)
Reads the next DER-encoded Integer value from the specified InputStream, and returns it as an integer.
|
static void |
readNull(java.io.InputStream is)
Reads the next DER-encoded NULL value from the specified InputStream, as a null value.
|
static java.lang.String |
readOIDString(java.io.InputStream is)
Reads the next DER-encoded ObjectID value from the specified InputStream, and returns it as a String
representation in hexadecimal format.
|
static java.lang.String |
readString(java.io.InputStream is)
Reads the next DER-encoded value from the specified InputStream, and returns it as a String.
|
static java.lang.String |
readUTF8String(java.io.InputStream is)
Reads the next DER-encoded UTF8String value from the specified InputStream, and returns it as a String.
|
public static final byte tag_Boolean
public static final byte tag_Integer
public static final byte tag_BitString
public static final byte tag_OctetString
public static final byte tag_Null
public static final byte tag_ObjectId
public static final byte tag_Enumerated
public static final byte tag_UTF8String
public static final byte tag_PrintableString
public static final byte tag_T61String
public static final byte tag_IA5String
public static final byte tag_UtcTime
public static final byte tag_GeneralizedTime
public static final byte tag_GeneralString
public static final byte tag_UniversalString
public static final byte tag_BMPString
public static final byte tag_Sequence
public static final byte tag_SequenceOf
public static final byte tag_Set
public static final byte tag_SetOf
public static final byte MASK_CONTEXT
public static final byte MASK_CONSTRUCTED
public static void readFully(java.io.InputStream in, byte[] b, int off, int len) throws java.io.IOException, java.io.EOFException
readFully
method of DataInput
.
Bytes for this operation are read from the contained input stream.
in
- input stream from which to read.b
- the buffer into which the data is read.off
- the start offset of the data.len
- the number of bytes to read.java.io.EOFException
- if this input stream reaches the end before reading all the bytes.java.io.IOException
- the stream has been closed and the contained input stream does not support reading after close, or
another I/O error occurs.public static int readInteger(java.io.InputStream is) throws DerFormatException, java.io.IOException
is
- the InputStream to parseDerFormatException
- if the value is not correctly formatted.java.io.IOException
- if an I/O error occurs.public static java.lang.String readUTF8String(java.io.InputStream is) throws java.io.IOException, DerFormatException
is
- the InputStream to parseDerFormatException
- if the value is not correctly formatted.java.io.IOException
- if an I/O error occurs.public static java.lang.String readString(java.io.InputStream is) throws java.io.IOException, DerFormatException
is
- the InputStream to parseDerFormatException
- if the value is not correctly formatted.java.io.IOException
- if an I/O error occurs.public static boolean readBoolean(java.io.InputStream is) throws DerFormatException, java.io.IOException
is
- the InputStream to parseDerFormatException
- if the value is not correctly formatted.java.io.IOException
- if an I/O error occurs.public static java.lang.String readOIDString(java.io.InputStream is) throws java.io.IOException, DerFormatException
This method does not check the encoding.
is
- the InputStream to parseDerFormatException
- if the value is not correctly formatted.java.io.IOException
- if an I/O error occurs.public static void readNull(java.io.InputStream is) throws java.io.IOException, DerFormatException
is
- the InputStream to parseDerFormatException
- if the value is not correctly formatted.java.io.IOException
- if an I/O error occurs.public static byte[] readBitString(java.io.InputStream is) throws java.io.IOException, DerFormatException
is
- the InputStream to parseDerFormatException
- if the value is not correctly formatted.java.io.IOException
- if an I/O error occurs.public static int expectTag(byte expectedTag, java.io.InputStream stream) throws java.io.IOException, DerFormatException
expectedTag
- tag expected according to the stream format.stream
- stream to be parsed.java.io.IOException
- if an I/O error occurs.DerFormatException
- if an error occurs while parsing.public static int readDERLength(java.io.InputStream in) throws java.io.IOException, DerFormatException
in
- the InputStream to read from.java.io.IOException
- if an I/O error occurs.DerFormatException
- if an error occurs while parsing.