Package org.apache.jcp.xml.dsig.internal
Class DigesterOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.jcp.xml.dsig.internal.DigesterOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class DigesterOutputStream extends java.io.OutputStream
This class has been modified slightly to use java.security.MessageDigest objects as input, rather than org.apache.xml.security.algorithms.MessageDigestAlgorithm objects. It also optionally caches the input bytes.
-
-
Field Summary
Fields Modifier and Type Field Description private UnsyncByteArrayOutputStream
bos
private boolean
buffer
private static org.slf4j.Logger
LOG
private java.security.MessageDigest
md
-
Constructor Summary
Constructors Constructor Description DigesterOutputStream(java.security.MessageDigest md)
Creates a DigesterOutputStream.DigesterOutputStream(java.security.MessageDigest md, boolean buffer)
Creates a DigesterOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
byte[]
getDigestValue()
java.io.InputStream
getInputStream()
void
write(byte[] input, int offset, int len)
void
write(int input)
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
buffer
private final boolean buffer
-
bos
private UnsyncByteArrayOutputStream bos
-
md
private final java.security.MessageDigest md
-
-
Constructor Detail
-
DigesterOutputStream
public DigesterOutputStream(java.security.MessageDigest md)
Creates a DigesterOutputStream.- Parameters:
md
- the MessageDigest
-
DigesterOutputStream
public DigesterOutputStream(java.security.MessageDigest md, boolean buffer)
Creates a DigesterOutputStream.- Parameters:
md
- the MessageDigestbuffer
- if true, caches the input bytes
-
-
Method Detail
-
write
public void write(int input)
- Specified by:
write
in classjava.io.OutputStream
-
write
public void write(byte[] input, int offset, int len)
- Overrides:
write
in classjava.io.OutputStream
-
getDigestValue
public byte[] getDigestValue()
- Returns:
- the digest value
-
getInputStream
public java.io.InputStream getInputStream()
- Returns:
- an input stream containing the cached bytes, or null if not cached
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-