CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.net.security
Class BlockCipherInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.tangosol.net.security.BlockCipherInputStream
All Implemented Interfaces:
Closeable

public class BlockCipherInputStream
extends FilterInputStream

InputStream which supports block ciphers, and data sizes which exceed the Cipher's block size.

Author:
mf 2006.08.08

Field Summary
static byte[] EMPTY_BYTE_ARRAY
          Initial value for m_abBlockClear
protected  byte[] m_abBlockClear
          The current block of unencrypted data
protected  byte[] m_abBlockEncrypted
          The current block of encrypted data
protected  Cipher m_cipher
          The Cipher to use to decrypt data
protected  boolean m_fEof
          Marker indicating if the end of the wrapped stream has been reached
protected  int m_nBlockIndex
          The index into the next unread byte of unencrypted data
protected  int m_nBlockSize
          The Cipher's block size
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
BlockCipherInputStream(InputStream stream, Cipher cipher)
          Construct a BlockCipherInputStream around the supplied stream and decrypt output data with the supplied cipher.
 
Method Summary
 int available()
          
protected  int ensureData()
          Ensure that there is some data available for read, blocking on the wrapped stream if necessary.
 boolean markSupported()
          
 int read()
          
 int read(byte[] abData)
          
 int read(byte[] abData, int nOffset, int nLength)
          
 long skip(long lBytes)
          
 
Methods inherited from class java.io.FilterInputStream
close, mark, reset
 

Field Detail

m_cipher

protected Cipher m_cipher
The Cipher to use to decrypt data


m_nBlockSize

protected int m_nBlockSize
The Cipher's block size


m_abBlockEncrypted

protected byte[] m_abBlockEncrypted
The current block of encrypted data


m_abBlockClear

protected byte[] m_abBlockClear
The current block of unencrypted data


m_nBlockIndex

protected int m_nBlockIndex
The index into the next unread byte of unencrypted data


m_fEof

protected boolean m_fEof
Marker indicating if the end of the wrapped stream has been reached


EMPTY_BYTE_ARRAY

public static final byte[] EMPTY_BYTE_ARRAY
Initial value for m_abBlockClear

Constructor Detail

BlockCipherInputStream

public BlockCipherInputStream(InputStream stream,
                              Cipher cipher)
Construct a BlockCipherInputStream around the supplied stream and decrypt output data with the supplied cipher.

Parameters:
stream - the stream to read encrypted data to
cipher - the cipher to use to decrypt data
Method Detail

read

public int read()
         throws IOException

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] abData)
         throws IOException

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] abData,
                int nOffset,
                int nLength)
         throws IOException

Overrides:
read in class FilterInputStream
Throws:
IOException

skip

public long skip(long lBytes)
          throws IOException

Overrides:
skip in class FilterInputStream
Throws:
IOException

available

public int available()
              throws IOException

Overrides:
available in class FilterInputStream
Throws:
IOException

markSupported

public boolean markSupported()

Overrides:
markSupported in class FilterInputStream

ensureData

protected int ensureData()
                  throws IOException
Ensure that there is some data available for read, blocking on the wrapped stream if necessary. As a side effect a call to this method may change m_abBlockClear and m_nBlockIndex.

Returns:
the number of bytes now available
Throws:
IOException

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation