org.littleshoot.util
Class DecryptingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.littleshoot.util.DecryptingInputStream
All Implemented Interfaces:
Closeable

public class DecryptingInputStream
extends InputStream

InputStream that decodes incoming data that's encrypted with the given key and that includes a SHA-256 MAC.


Constructor Summary
DecryptingInputStream(byte[] readKey, InputStream inputStream)
          Creates a new stream that decrypts data from the encapsulated stream.
 
Method Summary
 int available()
          Return the minimum number of bytes that can be read without blocking.
 void close()
           
 int read()
           
 int read(byte[] buf)
           
 int read(byte[] buf, int off, int len)
          Read up to "len" bytes into this buffer, starting at "off".
 String toString()
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DecryptingInputStream

public DecryptingInputStream(byte[] readKey,
                             InputStream inputStream)
Creates a new stream that decrypts data from the encapsulated stream.

Parameters:
readKey - The key to decrypt with.
inputStream - The wrapped InputStream.
Method Detail

available

public int available()
              throws IOException
Return the minimum number of bytes that can be read without blocking. Currently not synchronized.

Overrides:
available in class InputStream
Throws:
IOException

read

public int read(byte[] buf)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Read up to "len" bytes into this buffer, starting at "off". If the layer above needs more data, it asks for more, so we are responsible only for blocking to fill at most one buffer, and returning "-1" on non-fault EOF status.

Overrides:
read in class InputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011-2013 LittleShoot. All Rights Reserved.