Top Description Fields Constructors Methods
org.apache.poi.poifs.crypt.cryptoapi

pack-priv Class CryptoAPIDocumentInputStream

extends ByteArrayInputStream
Class Inheritance
Annotations
@Internal
Imports
java.io.ByteArrayInputStream, java.security.GeneralSecurityException, javax.crypto.Cipher, .ShortBufferException, org.apache.poi.EncryptedDocumentException, org.apache.poi.util.Internal

A seekable InputStream, which is used to decrypt/extract the document entries within the encrypted stream

Field Summary

Modifier and TypeField and Description
private Cipher
private final CryptoAPIDecryptor
private byte[]
Inherited from java.io.ByteArrayInputStream:
bufcountmarkpos

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized int
read()

Overrides java.io.ByteArrayInputStream.read.

Reads the next byte of data from this input stream.

public synchronized int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.ByteArrayInputStream.read.

Reads up to len bytes of data into an array of bytes from this input stream.

public void
seek(int newpos)

public void
setBlock(int block)

Inherited from java.io.ByteArrayInputStream:
availableclosemarkmarkSupportedreadAllBytesreadNBytesresetskiptransferTo

Field Detail

cipherback to summary
private Cipher cipher
decryptorback to summary
private final CryptoAPIDecryptor decryptor
oneByteback to summary
private byte[] oneByte

Constructor Detail

CryptoAPIDocumentInputStreamback to summary
public CryptoAPIDocumentInputStream(CryptoAPIDecryptor decryptor, byte[] buf) throws GeneralSecurityException

Method Detail

readback to summary
public synchronized int read()

Overrides java.io.ByteArrayInputStream.read.

Doc from java.io.ByteArrayInputStream.read.

Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

This read method cannot block.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
readback to summary
public synchronized int read(byte[] b, int off, int len)

Overrides java.io.ByteArrayInputStream.read.

Doc from java.io.ByteArrayInputStream.read.

Reads up to len bytes of data into an array of bytes from this input stream. If pos equals count, then -1 is returned to indicate end of file. Otherwise, the number k of bytes read is equal to the smaller of len and count-pos. If k is positive, then bytes buf[pos] through buf[pos+k-1] are copied into b[off] through b[off+k-1] in the manner performed by System.arraycopy. The value k is added into pos and k is returned.

Unlike the overridden method of InputStream, this method returns -1 instead of zero if the end of the stream has been reached and len == 0.

This read method cannot block.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
seekback to summary
public void seek(int newpos)
setBlockback to summary
public void setBlock(int block) throws GeneralSecurityException