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

public abstract Class ChunkedCipherOutputStream

extends FilterOutputStream
Class Inheritance
Known Direct Subclasses
org.apache.poi.poifs.crypt.agile.AgileEncryptor.AgileCipherOutputStream, org.apache.poi.poifs.crypt.binaryrc4.BinaryRC4Encryptor.BinaryRC4CipherOutputStream, org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptor.CryptoAPICipherOutputStream, org.apache.poi.poifs.crypt.xor.XOREncryptor.XORCipherOutputStream
Annotations
@Internal
Static Imports
org.apache.poi.poifs.crypt.Decryptor.DEFAULT_POIFS_ENTRY

Field Summary

Modifier and TypeField and Description
private final byte[]
private final int
private final int
private Cipher
private final DirectoryNode
private final File
private boolean
private static final Logger
private final SparseBitSet
private long
private static final int
private long
private long
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public
public
ChunkedCipherOutputStream(OutputStream stream, int chunkSize)

Method Summary

Modifier and TypeMethod and Description
protected abstract void
calculateChecksum(File fileOut, int oleStreamSize)

public void
close()

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with the stream.

protected abstract void
protected byte[]
protected int
protected SparseBitSet
protected long
protected long
public final Cipher
initCipherForBlock(int block, boolean lastChunk)

protected abstract Cipher
initCipherForBlock(Cipher existing, int block, boolean lastChunk)

protected Cipher
initCipherForBlockNoFlush(Cipher existing, int block, boolean lastChunk)

protected int
invokeCipher(int posInChunk, boolean doFinal)

Helper function for overriding the cipher invocation, i.e. XOR doesn't use a cipher and uses its own implementation

private void
public void
setNextRecordSize(int
the size of the next record
recordSize
,
boolean
true if the record is unencrypted
isPlain
)

Some ciphers (actually just XOR) are based on the record size, which needs to be set before encryption

public void
write(int
the byte.
b
)

Overrides java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[]
the data to be written.
b
)

Overrides java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.

public void
write(byte[]
the data.
b
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

protected void
write(byte[] b, int off, int len, boolean writePlain)

protected void
writeChunk(boolean continued)

public void
writePlain(byte[] b, int off, int len)

Inherited from java.io.FilterOutputStream:
flush

Field Detail

chunkback to summary
private final byte[] chunk
chunkBitsback to summary
private final int chunkBits
chunkSizeback to summary
private final int chunkSize
cipherback to summary
private Cipher cipher
dirback to summary
private final DirectoryNode dir
fileOutback to summary
private final File fileOut
isClosedback to summary
private boolean isClosed
LOGback to summary
private static final Logger LOG
plainByteFlagsback to summary
private final SparseBitSet plainByteFlags
posback to summary
private long pos
STREAMINGback to summary
private static final int STREAMING
totalPosback to summary
private long totalPos
writtenback to summary
private long written

Constructor Detail

ChunkedCipherOutputStreamback to summary
public ChunkedCipherOutputStream(DirectoryNode dir, int chunkSize) throws IOException, GeneralSecurityException
ChunkedCipherOutputStreamback to summary
public ChunkedCipherOutputStream(OutputStream stream, int chunkSize) throws IOException, GeneralSecurityException

Method Detail

calculateChecksumback to summary
protected abstract void calculateChecksum(File fileOut, int oleStreamSize) throws GeneralSecurityException, IOException
closeback to summary
public void close() throws IOException

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterOutputStream.close.

Closes this output stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
createEncryptionInfoEntryback to summary
protected abstract void createEncryptionInfoEntry(DirectoryNode dir, File tmpFile) throws IOException, GeneralSecurityException
getChunkback to summary
protected byte[] getChunk()
getChunkMaskback to summary
protected int getChunkMask()
getPlainByteFlagsback to summary
protected SparseBitSet getPlainByteFlags()
getPosback to summary
protected long getPos()
getTotalPosback to summary
protected long getTotalPos()
initCipherForBlockback to summary
public final Cipher initCipherForBlock(int block, boolean lastChunk) throws IOException, GeneralSecurityException
initCipherForBlockback to summary
protected abstract Cipher initCipherForBlock(Cipher existing, int block, boolean lastChunk) throws IOException, GeneralSecurityException
initCipherForBlockNoFlushback to summary
protected Cipher initCipherForBlockNoFlush(Cipher existing, int block, boolean lastChunk) throws IOException, GeneralSecurityException
Annotations
@Internal
invokeCipherback to summary
protected int invokeCipher(int posInChunk, boolean doFinal) throws GeneralSecurityException, IOException

Helper function for overriding the cipher invocation, i.e. XOR doesn't use a cipher and uses its own implementation

processPOIFSWriterEventback to summary
private void processPOIFSWriterEvent(POIFSWriterEvent event)
setNextRecordSizeback to summary
public void setNextRecordSize(int recordSize, boolean isPlain)

Some ciphers (actually just XOR) are based on the record size, which needs to be set before encryption

Parameters
recordSize:int

the size of the next record

isPlain:boolean

true if the record is unencrypted

writeback to summary
public void write(int b) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).

Implements the abstract write method of OutputStream.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] b) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.

Parameters
b:byte[]

the data to be written.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
protected void write(byte[] b, int off, int len, boolean writePlain) throws IOException
writeChunkback to summary
protected void writeChunk(boolean continued) throws IOException
writePlainback to summary
public void writePlain(byte[] b, int off, int len) throws IOException