SHOW Signed
 

net.rim.device.api.crypto
Class DigestOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--net.rim.device.api.crypto.CryptoOutputStream
              |
              +--net.rim.device.api.crypto.DigestOutputStream

public class DigestOutputStream
extends CryptoOutputStream

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

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

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:
JDE 3.6.0
See Also:
DigestInputStream

Field Summary
 Category: Signed protected  Digest _digest
          Stores 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.CryptoOutputStream
_out
 
Constructor Summary
 Category: Signed DigestOutputStream(Digest digest, OutputStream out)
          Creates a DigestOutputStream object which takes as input a digest and an output 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 decide whether or not they want the data being written to go through the digest function as well.
 Category: Signed  void write(byte[] buffer, int offset, int length)
          Writes a specified length of bytes from the given byte array to this output stream.
 
Methods inherited from class net.rim.device.api.crypto.CryptoOutputStream
close, flush, getOutputStream, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_digest

protected Digest _digest
Stores the digest used with this instance of the class for later use.
Since:
JDE 3.6.0
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.

_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.

Since:
JDE 3.6.0
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.
Constructor Detail

DigestOutputStream

public DigestOutputStream(Digest digest,
                          OutputStream out)
Creates a DigestOutputStream object which takes as input a digest and an output stream.

Parameters:
digest - The digest that will be used for hashing all of the data output to the stream.
out - The underlying output stream where data is written. If this is null, no output stream is used, and only the digest is evaluated during calls to write().
Since:
JDE 3.6.0
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.
Method Detail

getAlgorithm

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

Overrides:
getAlgorithm in class CryptoOutputStream
Since:
JDE 3.6.0

Following copied from class: CryptoOutputStream
Returns:
A String that represents 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.

getDigest

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

Returns:
A reference to the digest.
Since:
JDE 3.6.0
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.

on

public void on(boolean on)
Enables the user to decide whether or not they want the data being written 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 written to the stream through the digest as well. If false, then this data is not passed through the digest but is simply written to the stream.
Since:
JDE 3.6.0
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.

write

public void write(byte[] buffer,
                  int offset,
                  int length)
           throws IOException
Description copied from class: CryptoOutputStream
Writes a specified length of bytes from the given byte array to this output stream.

Overrides:
write in class CryptoOutputStream
Since:
JDE 3.6.0

Following copied from class: CryptoOutputStream
Parameters:
buffer - The byte array containing the bytes that are going to be written to the output stream.
offset - The offset in the byte array where the method will start writing from.
length - The number of bytes that will be written to the output stream.

Throws:
IOException - Thrown if an I/O error occurs.
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.



Copyright 1999-2009 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.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.