org.dmonix.cipher
Class DMCipherInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended byorg.dmonix.cipher.DMCipherInputStream
Direct Known Subclasses:
DMCipherInputStreamDES, DMCipherInputStreamPBE

public abstract class DMCipherInputStream
extends java.io.FilterInputStream

The base class for all ciphered input streams.

Copyright: Copyright (c) 2004

Company: dmonix.org

Version:
1.0
Author:
Peter Nerg

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
protected DMCipherInputStream(java.io.InputStream istream, java.lang.String cipherAlgorithm)
           
 
Method Summary
 java.lang.Object clone()
          THIS METHOD IS NOT SUPPORTED!
 void close()
          Closes this input stream and releases any system resources associated with the stream.
protected  void initCipher(java.security.Key key)
          Init the cipher.
protected  void initCipher(java.security.Key key, java.security.spec.AlgorithmParameterSpec param)
          Init the cipher.
 int read()
          Reads the next byte of data from this input stream.
 int read(byte[] b)
          Reads up to b.length bytes of data from this input stream into an array of bytes.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from this input stream into an array of bytes.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DMCipherInputStream

protected DMCipherInputStream(java.io.InputStream istream,
                              java.lang.String cipherAlgorithm)
                       throws java.security.NoSuchAlgorithmException,
                              javax.crypto.NoSuchPaddingException
Method Detail

clone

public final java.lang.Object clone()
                             throws java.lang.CloneNotSupportedException
THIS METHOD IS NOT SUPPORTED!
The method always throws java.lang.CloneNotSupportedException

Returns:
-
Throws:
java.lang.CloneNotSupportedException - The exception is always thrown

close

public void close()
           throws java.io.IOException
Closes this input stream and releases any system resources associated with the stream.

Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
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 method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Reads up to b.length bytes of data from this input stream into an array of bytes.
This method blocks until some input is available.
This method simply performs the call read(b, 0, b.length) and returns the result.

Parameters:
b - the buffer into which the data is read.
Returns:
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.
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from this input stream into an array of bytes.
This method blocks until some input is available.

Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
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.
Throws:
java.io.IOException

initCipher

protected void initCipher(java.security.Key key)
                   throws java.security.InvalidKeyException
Init the cipher.

Parameters:
key - The key for the cipher
Throws:
java.security.InvalidKeyException

initCipher

protected void initCipher(java.security.Key key,
                          java.security.spec.AlgorithmParameterSpec param)
                   throws java.security.InvalidKeyException,
                          java.security.InvalidAlgorithmParameterException
Init the cipher.

Parameters:
key - The key for the cipher
param - Cipher parameters
Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException


Copyright © 1998-2005 dmonix.org Peter Nerg, All Rights Reserved.