Package net.handle.hdllib
Class SignedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- net.handle.hdllib.SignedInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class SignedInputStream extends java.io.FilterInputStream
Objects of this class can be used to verify the contents of a stream generated by a SignedOutputStream class. Note: This is not a part of the official handle protocol specification. This was introduced by CNRI solely for replication in the Handle.net software.
-
-
Field Summary
Fields Modifier and Type Field Description static int
STREAM_TYPE_PK
static int
STREAM_TYPE_TLS
static int
STREAM_TYPE_UNSIGNED
-
Constructor Summary
Constructors Constructor Description SignedInputStream(java.security.PublicKey sourceKey, java.io.InputStream in, java.net.Socket socket)
Create a stream that can verify the data read from the stream in blocks.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isSecure()
int
read()
Read a byte from the stream.int
read(byte[] b)
int
read(byte[] b, int off, int len)
boolean
verifyBlock()
Reads a signature from the stream and verifies the bytes read since the last verification based on that signature.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset, skip
-
-
-
-
Field Detail
-
STREAM_TYPE_PK
public static final int STREAM_TYPE_PK
- See Also:
- Constant Field Values
-
STREAM_TYPE_UNSIGNED
public static final int STREAM_TYPE_UNSIGNED
- See Also:
- Constant Field Values
-
STREAM_TYPE_TLS
public static final int STREAM_TYPE_TLS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SignedInputStream
public SignedInputStream(java.security.PublicKey sourceKey, java.io.InputStream in, java.net.Socket socket) throws java.lang.Exception
Create a stream that can verify the data read from the stream in blocks. The caller should call the verifyBlock method at the end of every block of data that needs to be verified. verifyBlock must be called at the same position in the stream that signBlock was called in the parallel SignedOutputStream object that generated the stream.- Throws:
java.lang.Exception
-
-
Method Detail
-
isSecure
public boolean isSecure()
-
read
public int read() throws java.io.IOException
Read a byte from the stream.- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
verifyBlock
public boolean verifyBlock() throws java.io.IOException, java.security.SignatureException
Reads a signature from the stream and verifies the bytes read since the last verification based on that signature. This should be called at the exact same point in the stream as the signBlock() in the SignedOutpuStream class.- Throws:
java.io.IOException
java.security.SignatureException
-
-