public class ArchiveInputStream
extends java.io.FilterInputStream
ArchiveCreator class. The Entrust Archive format is a legacy
format, and this class is provided for the purposes of extracting data contained
within such files.
There are some important limitations to note about this class:
This class generally behaves like a generic InputStream. The data
returned is the original data that the given Archive protects. One important
thing to note is that it does not throw exceptions if the signature fails to
verify or the file protector's certificates are not valid. Once the close()
method is called, it is important to examine the results of processing the
Archive. These results are available by calling getArchiveResults()
| Constructor and Description |
|---|
ArchiveInputStream(KeyAndCertificateSource keyAndCertificateSource,
java.io.InputStream is)
Constructor for ArchiveInputStream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns
1 if at least one byte can be read from this input
stream without blocking. |
void |
close()
Close the input stream.
|
ArchiveResults |
getArchiveResults()
Returns the results of processing an Entrust Archive.
|
PemOptions |
getFileProtectionOptions()
Returns the options used when protecting the Archive.
|
java.lang.String |
getIncludedFileName()
Returns a String containing the name of the file that is protected
by the Archive.
|
void |
mark(int readlimit)
This stream class does not support mark/reset, this method does nothing
|
boolean |
markSupported()
This method is inherited from FilterInputStream and always returns false.
|
int |
read()
Reads and unprotects a byte from the underlying stream.
|
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from this input stream
into an array of bytes. |
void |
reset()
reset() is not supported. |
long |
skip(long n)
Does nothing.
|
public ArchiveInputStream(KeyAndCertificateSource keyAndCertificateSource, java.io.InputStream is)
InputStream from which the Archive is read.
If the Archive was encrypted, the keyAndCertificateSource
must contain a private key for which the Archive was encrypted.
keyAndCertificateSource - The source of decryption keys to unprotect the Archive, and a
CertVerifier to validate certificates.is - The InputStream from which the Archive is read.
This stream will be closed once the Archive has been read from it.public java.lang.String getIncludedFileName()
throws java.io.IOException,
ArchiveException
If the reading of the Archive has not yet begun, this causes the Archive's header information to be read, which may result in an IOException.
ArchiveException - if the header read from the Stream is not a valid header for an
Entrust Archive.java.io.IOException - if an error occurs reading the Archive header from the stream.public PemOptions getFileProtectionOptions() throws java.io.IOException, ArchiveException
If the reading of the Archive has not yet begun, this causes the Archive's header information to be read, which may result in an IOException.
ArchiveException - if the header read from the Stream is not a valid header for an
Entrust Archive.java.io.IOException - if an error occurs reading the Archive header from the streampublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes of data from this input stream
into an array of bytes. This method blocks until some input is
available.read in class java.io.FilterInputStreamb - the buffer into which the data is read.off - the start offset of the data.len - the maximum number of bytes read.-1 if there is no more data because the end of the stream
has been reached.ArchiveException - if the Archive header is corrupt, or
if the end of stream is reached before all of the data is read from the
Archive.java.io.IOException - if an I/O error occurs.public int read()
throws java.io.IOException
read in class java.io.FilterInputStream-1 if
there is no more data because the end of the stream has been reached.ArchiveException - if the Archive header is corrupt, or
if the end of stream is reached before all of the data is read from the
Archive.java.io.IOException - if an I/O error occurs.public void close()
throws java.io.IOException
Note that the signature validation is performed on the bytes that have been read from the stream so far, so if not all the bytes have been read the signature validation will fail.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterInputStreamjava.io.IOException - if an I/O error occurs closing the stream.public void mark(int readlimit)
mark in class java.io.FilterInputStreamreadlimit - ignoredpublic void reset()
throws java.io.IOException
reset() is not supported. This method always throws an
IOException.reset in class java.io.FilterInputStreamjava.io.IOException - alwayspublic boolean markSupported()
markSupported in class java.io.FilterInputStreamfalsepublic int available()
throws java.io.IOException
1 if at least one byte can be read from this input
stream without blocking.
available in class java.io.FilterInputStream1 if at least one byte can be read from this input
stream without blocking. Returns 0 otherwise.java.io.IOException - if an I/O error occurspublic long skip(long n)
skip in class java.io.FilterInputStreamn - ignored.0public ArchiveResults getArchiveResults() throws ArchiveException
This method should only be called after close() has been called,
calling before will cause an exception to be thrown.
ArchiveException - if close() has not yet been called.