Cryptix OpenPGP

cryptix.message.stream
Interface MessageOutputStreamSpi

All Known Subinterfaces:
EncryptedMessageOutputStreamSpi, LiteralMessageOutputStreamSpi, SignedMessageOutputStreamSpi

public interface MessageOutputStreamSpi

Service provider interface for MessageOutputStream

Version:
$Revision: 1.1 $
Author:
Edwin Woudt

Method Summary
 void engineClose()
          Close the stream Sends all data through the underlying stream and then calls the close() method of the underlying stream.
 void engineFlush()
          Flush the stream What flushing does is format specific.
 void engineInit(java.io.OutputStream out, java.security.SecureRandom sr)
          Initializes this outputstream with the given outputstream as underlying stream and the given SecureRandom object.
 void engineSetAttribute(java.lang.String name, java.lang.Object attr)
          Set a format specific attribute.
 void engineWrite(byte[] b)
          Write a complete bytearray to the stream
 void engineWrite(byte[] b, int off, int len)
          Write the specified part of a bytearray to the stream.
 void engineWrite(int b)
          Write a single byte to the stream
 

Method Detail

engineInit

public void engineInit(java.io.OutputStream out,
                       java.security.SecureRandom sr)
                throws java.lang.IllegalStateException,
                       java.io.IOException,
                       MessageStreamException
Initializes this outputstream with the given outputstream as underlying stream and the given SecureRandom object.

Parameters:
out - The underlying outputstream this stream will write results to.
sr - A SecureRandom object used for any randomness needed.
Throws:
java.lang.IllegalStateException - if this message has been initialized before.
java.io.IOException - on a general IOException that is not format specific.
MessageStreamException - on a variety of format specific problems.

engineSetAttribute

public void engineSetAttribute(java.lang.String name,
                               java.lang.Object attr)
                        throws java.lang.IllegalStateException,
                               java.lang.IllegalArgumentException,
                               MessageStreamException
Set a format specific attribute.

Parameters:
name - a name identifying the attribute
attr - the attribute itself
Throws:
java.lang.IllegalStateException - if this message has not been initialized before.
java.lang.IllegalArgumentException - if the attribute is not supported or the given object does not have the right type.
MessageStreamException - on a variety of format specific problems.

engineWrite

public void engineWrite(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException,
                        MessageStreamException
Write the specified part of a bytearray to the stream.

Parameters:
b - the data
off - the starting point of the write operation
len - how many bytes to write
Throws:
java.io.IOException - on a general IOException that is not format specific.
MessageStreamException - on a variety of format specific problems.

engineWrite

public void engineWrite(byte[] b)
                 throws java.io.IOException,
                        MessageStreamException
Write a complete bytearray to the stream

Parameters:
b - the data
Throws:
java.io.IOException - on a general IOException that is not format specific.
MessageStreamException - on a variety of format specific problems.

engineWrite

public void engineWrite(int b)
                 throws java.io.IOException,
                        MessageStreamException
Write a single byte to the stream

Parameters:
b - the byte to write
Throws:
java.io.IOException - on a general IOException that is not format specific.
MessageStreamException - on a variety of format specific problems.

engineFlush

public void engineFlush()
                 throws java.io.IOException,
                        MessageStreamException
Flush the stream

What flushing does is format specific. The general contract is that as much bytes as possible are written to the underlying datastream, but no guarantees are given about any buffers left. The reason for this is because cryptographic protocols usually work on specific blocksizes and there usually are only handlers (padding) for incomplete blocks at the end of the stream.

This method should call the flush() method of the underlying outputstream after it is done.

Throws:
java.io.IOException - on a general IOException that is not format specific.
MessageStreamException - on a variety of format specific problems.

engineClose

public void engineClose()
                 throws java.io.IOException,
                        MessageStreamException
Close the stream

Sends all data through the underlying stream and then calls the close() method of the underlying stream.

Throws:
java.io.IOException - on a general IOException that is not format specific.
MessageStreamException - on a variety of format specific problems.

Cryptix OpenPGP

Copyright (C) 1999-2003 The Cryptix Foundation Ltd.