public class SignatureInputStream
extends java.io.FilterInputStream
java.security.DigestInputStream
.Signature
,
DigestInputStream
Modifier and Type | Field and Description |
---|---|
protected int |
bytesProcessed_
The number of bytes that have been signed by this stream.
|
protected boolean |
isAtEOF_
True, if EOF of this stream has been reached.
|
protected boolean |
isClosed_
True, if this stream has been closed.
|
protected boolean |
on_
Indicates if passed through data is signed or just passed through.
|
protected boolean |
passThroughClose_
True, if we should pass through a call to close.
|
protected java.security.Signature |
signatureEngine_
The signature engine that is used for signature creation and verification.
|
Constructor and Description |
---|
SignatureInputStream(java.io.InputStream data,
java.security.Signature signatureEngine,
boolean passThroughClose)
Creates a streaming signature engine that reads its data from the provided stream.
|
Modifier and Type | Method and Description |
---|---|
int |
clearBytesProcessed()
Set the number of bytes that have been read so far to zero.
|
void |
close()
Close this stream and also the underlying stream if this has been specified at stream
construction.
|
int |
getBytesProcessed()
Return the number of bytes that have been read so far.
|
java.security.Signature |
getSignature()
Get the signature engine used by this stream.
|
boolean |
isOn()
Check if the signing/verification functionality is on or off.
|
boolean |
isStreamAtEOF()
Check, if this input stream has been read until EOF.
|
boolean |
isStreamClosed()
Check, if this stream has been closed; i.e.
|
int |
read()
Reads a byte from the underlying input stream and updates the signature engine, if the signing
function is on.
|
int |
read(byte[] buffer)
Reads some bytes from the underlying input stream into the given buffer and updates the
signature engine, if the signing function is on.
|
int |
read(byte[] buffer,
int offset,
int length)
Reads some bytes from the underlying input stream into the given buffer and updates the
signature engine, if the signing function is on.
|
boolean |
setOn(boolean on)
Switch the signing/verification functionality on or off.
|
void |
setSignature(java.security.Signature signatureEngine)
Set the signature engine used by this stream.
|
java.lang.String |
toString()
Get a string representation of this object for debugging.
|
protected boolean on_
protected java.security.Signature signatureEngine_
protected boolean isClosed_
protected boolean isAtEOF_
protected int bytesProcessed_
protected boolean passThroughClose_
public SignatureInputStream(java.io.InputStream data, java.security.Signature signatureEngine, boolean passThroughClose)
data
- The input stream proving the data.signatureEngine
- The signature object used to create and verify signatures.passThroughClose
- If true, a call to close will ba passed through.public java.security.Signature getSignature()
setSignature(java.security.Signature)
public void setSignature(java.security.Signature signatureEngine)
signatureEngine
- The signature engine used by this stream.getSignature()
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- if reading from the underlying stream fails or if updating the signature fails.Signature.update(byte)
public int read(byte[] buffer, int offset, int length) throws java.io.IOException
read
in class java.io.FilterInputStream
buffer
- The data buffer to put the read byte to.offset
- The offset where to start putting bytes into the buffer.length
- The maximum number of bytes to read.java.io.IOException
- if reading from the underlying stream fails or if updating the signature fails.Signature.update(byte[], int, int)
public int read(byte[] buffer) throws java.io.IOException
read
in class java.io.FilterInputStream
buffer
- The data buffer to put the read byte to.java.io.IOException
- if reading from the underlying stream fails or if updating the signature fails.Signature.update(byte[], int, int)
public boolean isOn()
public boolean setOn(boolean on)
on
- True, to switch the signing/verification functionality on, false, to switch it off.public boolean isStreamAtEOF()
public int getBytesProcessed()
public int clearBytesProcessed()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterInputStream
java.io.IOException
- If closing the underlying stream fails.SignatureInputStream(InputStream, Signature, boolean)
,
InputStream.close()
public boolean isStreamClosed()
public java.lang.String toString()
toString
in class java.lang.Object
IAIK JavaSecurity Website https://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. Version 1.9.4