net.rim.device.api.crypto
Class DigestInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by net.rim.device.api.crypto.CryptoInputStream
          extended by net.rim.device.api.crypto.DigestInputStream

public class DigestInputStream
extends CryptoInputStream

Allows for a user to open an input stream and run a digest on all information that passes through that input stream.

This is incredibly useful when a hash is required on a data stream from another program or even another class.

See Also:
DigestOutputStream
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

Field Summary
Category: Signed protected  Digest _digest
          A protected variable used to store the digest used with this instance of the class for later use.
Category: Signed protected  boolean _on
          A boolean that enables the user to turn the digest part of the input stream on or off at their will.
 
Fields inherited from class net.rim.device.api.crypto.CryptoInputStream
_inputStream
 
Constructor Summary
Category: Signed DigestInputStream(Digest digest, InputStream inputStream)
          Creates a DigestInputStream object from a digest and an underlying input stream.
 
Method Summary
Category: Signed  String getAlgorithm()
          Returns the name of this algorithm, eg "SHA1".
Category: Signed  Digest getDigest()
          Returns a reference to the digest being used with this digest input stream.
Category: Signed  void on(boolean on)
          Enables the user to turn on whether or not they want the data being read to go through the digest function as well.
Category: Signed  int read(byte[] buffer, int offset, int length)
          Reads up to the specified number of bytes from this input stream into an array of bytes.
 
Methods inherited from class net.rim.device.api.crypto.CryptoInputStream
available, close, getInputStream, markSupported, read, read
 
Methods inherited from class java.io.InputStream
mark, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

_digest

protected Digest _digest
A protected variable used to store the digest used with this instance of the class for later use.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

_on

protected boolean _on
A boolean that enables the user to turn the digest part of the input stream on or off at their will.

By default, _on is set to true.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


Constructor Detail

DigestInputStream

public DigestInputStream(Digest digest,
                         InputStream inputStream)
Creates a DigestInputStream object from a digest and an underlying input stream.

Parameters:
digest - The digest that will be used for hashing all of the data read from the stream.
inputStream - The input stream that will be used to read the data from.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


Method Detail

getAlgorithm

public String getAlgorithm()
Returns the name of this algorithm, eg "SHA1".

Specified by:
getAlgorithm in class CryptoInputStream
Returns:
A String representing the name of the algorithm.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

on

public void on(boolean on)
Enables the user to turn on whether or not they want the data being read to go through the digest function as well.

Note that _on is true by default.

Parameters:
on - When true, tells the program to pass the data read through the digest as well. If false, then this data is not passed through the digest but simply returned to the user.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException
Description copied from class: CryptoInputStream
Reads up to the specified number of bytes from this input stream into an array of bytes. This method blocks until some input is available.

Specified by:
read in class CryptoInputStream
Parameters:
buffer - The buffer into which the data is read.
offset - The starting offset within the buffer, to store the data.
length - 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:
IOException - Thrown if an I/O error occurs.
See Also:
InputStream.read()
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

getDigest

public Digest getDigest()
Returns a reference to the digest being used with this digest input stream.

Returns:
The digest.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.