public final class ASN1StreamReader extends Object implements Closeable
ASN1Element objects if they are not
needed. If any method in this class throws an IOException, then the
caller must close this reader and must not attempt to use it any more.
ASN1StreamReader instances are not threadsafe and must not be
accessed concurrently by multiple threads.| 构造器和说明 |
|---|
ASN1StreamReader(InputStream inputStream)
Creates a new ASN.1 stream reader that will read data from the provided
input stream.
|
ASN1StreamReader(InputStream inputStream,
int maxElementSize)
Creates a new ASN.1 stream reader that will read data from the provided
input stream.
|
| 限定符和类型 | 方法和说明 |
|---|---|
ASN1StreamReaderSequence |
beginSequence()
Reads the beginning of an ASN.1 sequence from the input stream and
returns a value that can be used to determine when the end of the sequence
has been reached.
|
ASN1StreamReaderSet |
beginSet()
Reads the beginning of an ASN.1 set from the input stream and returns a
value that can be used to determine when the end of the set has been
reached.
|
void |
close()
Closes this ASN.1 stream reader and the underlying input stream.
|
boolean |
ignoreInitialSocketTimeoutException()
Indicates whether to ignore
java.net.SocketTimeoutException
exceptions that may be caught while trying to read the first byte of an
element. |
boolean |
ignoreSocketTimeoutException()
已过时。
Use the
ignoreInitialSocketTimeoutException() and
ignoreSubsequentSocketTimeoutException() methods
instead. |
boolean |
ignoreSubsequentSocketTimeoutException()
Indicates whether to ignore
java.net.SocketTimeoutException
exceptions that may be caught while trying to read subsequent bytes of an
element (after one or more bytes have already been read for that element). |
int |
peek()
Peeks at the next byte to be read from the input stream without actually
consuming it.
|
BigInteger |
readBigInteger()
Reads an ASN.1 integer element from the input stream and returns the value
as a
BigInteger. |
Boolean |
readBoolean()
Reads an ASN.1 Boolean element from the input stream and returns the value
as a
Boolean. |
byte[] |
readBytes()
Reads an ASN.1 octet string element from the input stream and returns the
value as a byte array.
|
ASN1Element |
readElement()
Reads a complete ASN.1 element from the input stream.
|
Integer |
readEnumerated()
Reads an ASN.1 enumerated element from the input stream and returns the
value as an
Integer. |
Date |
readGeneralizedTime()
Reads an ASN.1 generalized time element from the input stream and returns
the value as a
Date. |
Integer |
readInteger()
Reads an ASN.1 integer element from the input stream and returns the value
as an
Integer. |
Long |
readLong()
Reads an ASN.1 integer element from the input stream and returns the value
as a
Long. |
void |
readNull()
Reads an ASN.1 null element from the input stream.
|
String |
readString()
Reads an ASN.1 octet string element from the input stream and returns the
value as a
String using the UTF-8 encoding. |
Date |
readUTCTime()
Reads an ASN.1 UTC time element from the input stream and returns the value
as a
Date. |
void |
setIgnoreSocketTimeout(boolean ignoreSocketTimeout)
已过时。
Use the
setIgnoreSocketTimeout(boolean, boolean)
method instead. |
void |
setIgnoreSocketTimeout(boolean ignoreInitialSocketTimeout,
boolean ignoreSubsequentSocketTimeout)
Indicates whether to ignore
java.net.SocketTimeoutException
exceptions that may be caught during processing. |
public ASN1StreamReader(@NonNull InputStream inputStream)
inputStream - The input stream from which data should be read. If
the provided input stream does not support the use of
the mark and reset methods, then it
will be wrapped with a BufferedInputStream.public ASN1StreamReader(@NonNull InputStream inputStream, int maxElementSize)
Integer.MAX_VALUE.inputStream - The input stream from which data should be read.
If the provided input stream does not support the
use of the mark and reset methods,
then it will be wrapped with a
BufferedInputStream.maxElementSize - The maximum size in bytes of an ASN.1 element that
may be read. A value less than or equal to zero
will be interpreted as Integer.MAX_VALUE.public void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableIOException - If a problem occurs while closing the underlying
input stream.@Deprecated public boolean ignoreSocketTimeoutException()
ignoreInitialSocketTimeoutException() and
ignoreSubsequentSocketTimeoutException() methods
instead.java.net.SocketTimeoutException
exceptions that may be caught during processing.true if SocketTimeoutException exceptions should
be ignored, or false if they should not be ignored and
should be propagated to the caller.public boolean ignoreInitialSocketTimeoutException()
java.net.SocketTimeoutException
exceptions that may be caught while trying to read the first byte of an
element.true if SocketTimeoutException exceptions should
be ignored while trying to read the first byte of an element, or
false if they should not be ignored and should be
propagated to the caller.public boolean ignoreSubsequentSocketTimeoutException()
java.net.SocketTimeoutException
exceptions that may be caught while trying to read subsequent bytes of an
element (after one or more bytes have already been read for that element).true if SocketTimeoutException exceptions should
be ignored while trying to read subsequent bytes of an element, or
false if they should not be ignored and should be
propagated to the caller.@Deprecated public void setIgnoreSocketTimeout(boolean ignoreSocketTimeout)
setIgnoreSocketTimeout(boolean, boolean)
method instead.java.net.SocketTimeoutException
exceptions that may be caught during processing.ignoreSocketTimeout - Indicates whether to ignore
SocketTimeoutException exceptions that
may be caught during processing.public void setIgnoreSocketTimeout(boolean ignoreInitialSocketTimeout,
boolean ignoreSubsequentSocketTimeout)
java.net.SocketTimeoutException
exceptions that may be caught during processing.ignoreInitialSocketTimeout - Indicates whether to ignore
SocketTimeoutException
exceptions that may be caught while
trying to read the first byte of an
element.ignoreSubsequentSocketTimeout - Indicates whether to ignore
SocketTimeoutException
exceptions that may be caught while
reading beyond the first byte of an
element.public int peek()
throws IOException
IOException - If a problem occurs while reading from the input
stream.@Nullable public ASN1Element readElement() throws IOException
null if
the end of the input stream was reached before any data could be
read. If null is returned, then the input stream will
have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.@Nullable public Boolean readBoolean() throws IOException, ASN1Exception
Boolean.Boolean value of the ASN.1 Boolean element read, or
null if the end of the input stream was reached before any
data could be read. If null is returned, then the input
stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1
Boolean element.@Nullable public Integer readEnumerated() throws IOException, ASN1Exception
Integer.Integer value of the ASN.1 enumerated element read, or
null if the end of the input stream was reached before any
data could be read. If null is returned, then the input
stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1
enumerated element.@Nullable public Date readGeneralizedTime() throws IOException, ASN1Exception
Date.Date value of the ASN.1 generalized time element read,
or null if the end of the input stream was reached before
any data could be read. If null is returned, then the
input stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1
generalized time element.@Nullable public Integer readInteger() throws IOException, ASN1Exception
Integer.Integer value of the ASN.1 integer element read, or
null if the end of the input stream was reached before any
data could be read. If null is returned, then the input
stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1
integer element.@Nullable public Long readLong() throws IOException, ASN1Exception
Long.Long value of the ASN.1 integer element read, or
null if the end of the input stream was reached before any
data could be read. If null is returned, then the input
stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1
integer element.@Nullable public BigInteger readBigInteger() throws IOException, ASN1Exception
BigInteger.BigInteger value of the ASN.1 integer element read, or
null if the end of the input stream was reached before any
data could be read. If null is returned, then the input
stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1
integer element.public void readNull()
throws IOException,
ASN1Exception
IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1 null
element.@Nullable public byte[] readBytes() throws IOException
null if the end of the input stream was reached before any
data could be read. If null is returned, then the input
stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.@Nullable public String readString() throws IOException
String using the UTF-8 encoding.String value of the ASN.1 octet string element read,
or null if the end of the input stream was reached before
any data could be read. If null is returned, then the
input stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.@Nullable public Date readUTCTime() throws IOException, ASN1Exception
Date.Date value of the ASN.1 UTC time element read, or
null if the end of the input stream was reached before any
data could be read. If null is returned, then the input
stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.ASN1Exception - If the data read cannot be parsed as an ASN.1 UTC
time element.@Nullable public ASN1StreamReaderSequence beginSequence() throws IOException
ASN1StreamReaderSequence.hasMoreElements() method returns
false.null if the end of the input
stream was reached before any data could be read. If null
is returned, then the input stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.@Nullable public ASN1StreamReaderSet beginSet() throws IOException
ASN1StreamReaderSet.hasMoreElements() method
returns false.null if the end of the input stream
was reached before any data could be read. If null is
returned, then the input stream will have been closed.IOException - If a problem occurs while reading from the input
stream, if the end of the input stream is reached in
the middle of the element, or or if an attempt is
made to read an element larger than the maximum
allowed size.Copyright © 2022. All rights reserved.