Rice Pastry API

rice.p2p.util
Class EncryptedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by rice.p2p.util.EncryptedInputStream
All Implemented Interfaces:
java.io.Closeable

public class EncryptedInputStream
extends java.io.InputStream

Version:
$Id: EncryptedInputStream.java 3524 2007-01-09 14:09:27Z jeffh $
Author:
Alan Mislove

Field Summary
protected  byte[] buffer
           
protected  int bufferLength
           
protected  byte[] key
           
protected  java.security.PrivateKey privateKey
           
protected  java.io.DataInputStream stream
           
 
Constructor Summary
EncryptedInputStream(java.security.PrivateKey privateKey, java.io.InputStream stream)
          Builds an encrypted inputstream given a private key to decrypt thing under
 
Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
 void close()
          Closes this input stream and releases any system resources associated with the stream.
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the input stream into an array of bytes.
protected  void readBuffer()
          Internal method which reads in the next chunk of buffered data
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

privateKey

protected java.security.PrivateKey privateKey

key

protected byte[] key

stream

protected java.io.DataInputStream stream

buffer

protected byte[] buffer

bufferLength

protected int bufferLength
Constructor Detail

EncryptedInputStream

public EncryptedInputStream(java.security.PrivateKey privateKey,
                            java.io.InputStream stream)
                     throws java.io.IOException
Builds an encrypted inputstream given a private key to decrypt thing under

Parameters:
key - The key
stream - The underlying stream
Throws:
java.io.IOException
Method Detail

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream. T

Specified by:
read in class java.io.InputStream
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,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer.

Overrides:
read in class java.io.InputStream
Parameters:
b - the buffer into which the data is read.
off - the start offset in array b at which the data is written.
len - the maximum number of bytes to 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

readBuffer

protected void readBuffer()
                   throws java.io.IOException
Internal method which reads in the next chunk of buffered data

Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or or another thread.

Overrides:
available in class java.io.InputStream
Returns:
the number of bytes that can be read from this input stream without blocking.
Throws:
java.io.IOException - if an I/O error occurs.

close

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

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - if an I/O error occurs.

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection