net.rim.device.api.crypto
Class MACOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.rim.device.api.crypto.CryptoOutputStream
          extended by net.rim.device.api.crypto.MACOutputStream

public class MACOutputStream
extends CryptoOutputStream

The MACOutputStream class provides streaming functionality with a Message Authentication Code MAC by allowing for write calls to an underlying output stream and passing this information through the MAC as it is being written.

See Also:
MACInputStream
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  MAC _mac
          Stores that MAC for later use.
Category: Signed protected  boolean _on
          Determines whether or not information that is written to the output stream should be passed through the MAC beforehand.
 
Fields inherited from class net.rim.device.api.crypto.CryptoOutputStream
_out
 
Constructor Summary
Category: Signed MACOutputStream(MAC mac, OutputStream out)
          Creates a MACOutputStream object using a MAC that the user wants and an output stream that all data will be written to.
 
Method Summary
Category: Signed  String getAlgorithm()
          Returns the name of this algorithm, eg "HMAC".
Category: Signed  MAC getMAC()
          Returns a reference to the MAC object being used in this instance of the class.
Category: Signed  void on(boolean on)
          Allows the programmer to turn the MAC functionality of the stream on or off at will.
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

_mac

protected MAC _mac
Stores that MAC 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
Determines whether or not information that is written to the output stream should be passed through the MAC beforehand. 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

MACOutputStream

public MACOutputStream(MAC mac,
                       OutputStream out)
Creates a MACOutputStream object using a MAC that the user wants and an output stream that all data will be written to.

Parameters:
mac - The MAC object to use with this output stream.
out - The underlying output stream that all data. will be written to. If this is null, no output stream will be used, allowing just the MAC features to be used.
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 "HMAC".

Specified by:
getAlgorithm in 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.
Since:
BlackBerry API 3.6.0

on

public void on(boolean on)
Allows the programmer to turn the MAC functionality of the stream on or off at will. The "on" boolean will determine whether information that is written will be passed through the MAC before being written to the stream.

Note that _on is set to true by default.

Parameters:
on - A boolean stating whether the MAC is on (true) or off (false).
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

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.

Specified by:
write in 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.
Since:
BlackBerry API 3.6.0

getMAC

public MAC getMAC()
Returns a reference to the MAC object being used in this instance of the class.

Returns:
The current MAC object.
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.