APIdia Launch Partner
Top Description Fields Constructors Methods
org.jcp.xml.dsig.internal

public Class DigesterOutputStream

extends OutputStream
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, .OutputStream, java.security.MessageDigest, com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream

This class has been modified slightly to use java.security.MessageDigest objects as input, rather than com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithm objects. It also optionally caches the input bytes.

Field Summary

Modifier and TypeField and Description
private UnsyncByteArrayOutputStream
private final boolean
private static final Logger
private final MessageDigest

Constructor Summary

AccessConstructor and Description
public
DigesterOutputStream(MessageDigest
the MessageDigest
md
)

Creates a DigesterOutputStream.

public
DigesterOutputStream(MessageDigest
the MessageDigest
md
,
boolean
if true, caches the input bytes
buffer
)

Creates a DigesterOutputStream.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

public byte[]
getDigestValue()

Returns: the digest value

public InputStream
getInputStream()

Returns: an input stream containing the cached bytes, or null if not cached

public void
write(int input)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[] input, int offset, int len)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.OutputStream:
flushnullOutputStreamwrite

Field Detail

bosback to summary
private UnsyncByteArrayOutputStream bos
bufferback to summary
private final boolean buffer
LOGback to summary
private static final Logger LOG
mdback to summary
private final MessageDigest md

Constructor Detail

DigesterOutputStreamback to summary
public DigesterOutputStream(MessageDigest md)

Creates a DigesterOutputStream.

Parameters
md:MessageDigest

the MessageDigest

DigesterOutputStreamback to summary
public DigesterOutputStream(MessageDigest md, boolean buffer)

Creates a DigesterOutputStream.

Parameters
md:MessageDigest

the MessageDigest

buffer:boolean

if true, caches the input bytes

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
getDigestValueback to summary
public byte[] getDigestValue()
Returns:byte[]

the digest value

getInputStreamback to summary
public InputStream getInputStream()
Returns:InputStream

an input stream containing the cached bytes, or null if not cached

writeback to summary
public void write(int input)

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Annotations
@Override
writeback to summary
public void write(byte[] input, int offset, int len)

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Annotations
@Override