|
Message Security Layer (MSL) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
com.netflix.msl.msg.MessageOutputStream
public class MessageOutputStream
A MSL message consists of a single MSL header followed by one or more payload chunks carrying application data. Each payload chunk is individually packaged but sequentially ordered. The end of the message is indicated by a payload with no data.
No payload chunks may be included in an error message.
Data is buffered until flush()
or close()
is called.
At that point a new payload chunk is created and written out. Closing a
MessageOutputStream
does not close the destination output stream in
case additional MSL messages will be written.
A copy of the payload chunks is kept in-memory and can be retrieved by a
a call to getPayloads()
until stopCaching()
is called. This
is used to facilitate automatic re-sending of messages.
Field Summary | |
---|---|
private boolean |
caching
True if caching data. |
private MessageCapabilities |
capabilities
Message output stream capabilities. |
private Charset |
charset
Output stream character set encoding. |
private boolean |
closed
Stream is closed. |
private boolean |
closeDestination
True if the destination output stream should be closed. |
private MslConstants.CompressionAlgorithm |
compressionAlgo
Paload chunk compression algorithm. |
private ICryptoContext |
cryptoContext
Payload crypto context. |
private ByteArrayOutputStream |
currentPayload
Current payload chunk data. |
private OutputStream |
destination
Destination output stream. |
private Header |
header
Header. |
private List<PayloadChunk> |
payloads
Ordered list of sent payloads. |
private long |
payloadSequenceNumber
Current payload sequence number. |
Constructor Summary | |
---|---|
MessageOutputStream(MslContext ctx,
OutputStream destination,
Charset charset,
ErrorHeader header)
Construct a new error message output stream. |
|
MessageOutputStream(MslContext ctx,
OutputStream destination,
Charset charset,
MessageHeader header,
ICryptoContext cryptoContext)
Construct a new message output stream. |
Method Summary | |
---|---|
void |
close()
|
void |
closeDestination(boolean close)
By default the destination output stream is not closed when this message output stream is closed. |
protected void |
finalize()
|
void |
flush()
Flush any buffered data out to the destination. |
ErrorHeader |
getErrorHeader()
|
MessageHeader |
getMessageHeader()
|
(package private) List<PayloadChunk> |
getPayloads()
Returns the payloads sent so far. |
boolean |
setCompressionAlgorithm(MslConstants.CompressionAlgorithm compressionAlgo)
Set the payload chunk compression algorithm that will be used for all future payload chunks. |
(package private) void |
stopCaching()
Turns off caching of any message data (e.g. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final OutputStream destination
private final Charset charset
private final MessageCapabilities capabilities
private final Header header
private final ICryptoContext cryptoContext
private MslConstants.CompressionAlgorithm compressionAlgo
private long payloadSequenceNumber
private ByteArrayOutputStream currentPayload
private boolean closed
private boolean closeDestination
private boolean caching
private final List<PayloadChunk> payloads
Constructor Detail |
---|
public MessageOutputStream(MslContext ctx, OutputStream destination, Charset charset, ErrorHeader header) throws IOException
#flush()
on the destination output
stream.
ctx
- the MSL context.destination
- MSL output stream.charset
- output stream character set encoding.header
- error header.
IOException
- if there is an error writing the header.public MessageOutputStream(MslContext ctx, OutputStream destination, Charset charset, MessageHeader header, ICryptoContext cryptoContext) throws IOException
#flush()
on the destination output
stream. The most preferred compression algorithm supported by the
local entity and message header will be used.
ctx
- the MSL context.destination
- MSL output stream.charset
- output stream character set encoding.header
- message header.cryptoContext
- payload data crypto context.
IOException
- if there is an error writing the header.Method Detail |
---|
protected void finalize() throws Throwable
finalize
in class Object
Throwable
public boolean setCompressionAlgorithm(MslConstants.CompressionAlgorithm compressionAlgo) throws IOException
compressionAlgo
- payload chunk compression algorithm. Null for no
compression.
IOException
- if buffered data could not be flushed. The
compression algorithm will be unchanged.
MslInternalException
- if writing an error message.flush()
public MessageHeader getMessageHeader()
public ErrorHeader getErrorHeader()
List<PayloadChunk> getPayloads()
void stopCaching()
public void closeDestination(boolean close)
close
- true if the destination output stream should be closed,
false if it should not.public void close() throws IOException
close
in interface Closeable
close
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
- if buffered data could not be flushed.
MslInternalException
- if writing an error message.OutputStream.flush()
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
|
Message Security Layer (MSL) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |