public class CryptoInputStream extends InputStream implements ReadableByteChannel
| ?????? | ????? |
|---|---|
static String |
STREAM_BUFFER_SIZE_KEY
The configuration key of the buffer size for stream.
|
| ??? | ?????? |
|---|---|
protected |
CryptoInputStream(Input input,
CryptoCipher cipher,
int bufferSize,
Key key,
AlgorithmParameterSpec params)
Constructs a
CryptoInputStream. |
protected |
CryptoInputStream(InputStream in,
CryptoCipher cipher,
int bufferSize,
Key key,
AlgorithmParameterSpec params)
Constructs a
CryptoInputStream. |
protected |
CryptoInputStream(ReadableByteChannel in,
CryptoCipher cipher,
int bufferSize,
Key key,
AlgorithmParameterSpec params)
Constructs a
CryptoInputStream. |
|
CryptoInputStream(String transformation,
Properties props,
InputStream in,
Key key,
AlgorithmParameterSpec params)
Constructs a
CryptoInputStream. |
|
CryptoInputStream(String transformation,
Properties props,
ReadableByteChannel in,
Key key,
AlgorithmParameterSpec params)
Constructs a
CryptoInputStream. |
| ?????? | ????? |
|---|---|
int |
available()
Overrides the
InputStream.available(). |
protected void |
checkStream()
Checks whether the stream is closed.
|
void |
close()
Overrides the
InputStream.close(). |
protected void |
decrypt()
Does the decryption using inBuffer as input and outBuffer as output.
|
protected void |
decryptFinal()
Does final of the cipher to end the decrypting stream.
|
protected int |
decryptMore()
Decrypts more data by reading the under layer stream.
|
protected void |
freeBuffers()
Forcibly free the direct buffers.
|
protected int |
getBufferSize()
Gets the buffer size.
|
protected CryptoCipher |
getCipher()
Gets the internal CryptoCipher.
|
protected Input |
getInput()
Gets the input.
|
protected Key |
getKey()
Gets the key.
|
protected AlgorithmParameterSpec |
getParams()
Gets the specification of cryptographic parameters.
|
protected void |
initCipher()
Initializes the cipher.
|
boolean |
isOpen()
Overrides the
Channel.isOpen(). |
void |
mark(int readlimit)
Overrides the
InputStream.mark(int). |
boolean |
markSupported()
Overrides the
InputStream.markSupported(). |
int |
read()
Overrides the
InputStream.read(). |
int |
read(byte[] b,
int off,
int len)
Overrides the
InputStream.read(byte[], int, int). |
int |
read(ByteBuffer dst)
Overrides the
ReadableByteChannel.read(ByteBuffer). |
void |
reset()
Overrides the
InputStream.reset(). |
long |
skip(long n)
Overrides the
InputStream.skip(long). |
readpublic CryptoInputStream(String transformation, Properties props, InputStream in, Key key, AlgorithmParameterSpec params) throws IOException
CryptoInputStream.transformation - the name of the transformation, e.g.,
AES/CBC/PKCS5Padding.
See the Java Cryptography Architecture Standard Algorithm Name Documentation
for information about standard transformation names.props - The Properties class represents a set of
properties.in - the input stream.key - crypto key for the cipher.params - the algorithm parameters.IOException - if an I/O error occurs.public CryptoInputStream(String transformation, Properties props, ReadableByteChannel in, Key key, AlgorithmParameterSpec params) throws IOException
CryptoInputStream.transformation - the name of the transformation, e.g.,
AES/CBC/PKCS5Padding.
See the Java Cryptography Architecture Standard Algorithm Name Documentation
for information about standard transformation names.props - The Properties class represents a set of
properties.in - the ReadableByteChannel object.key - crypto key for the cipher.params - the algorithm parameters.IOException - if an I/O error occurs.protected CryptoInputStream(InputStream in, CryptoCipher cipher, int bufferSize, Key key, AlgorithmParameterSpec params) throws IOException
CryptoInputStream.cipher - the cipher instance.in - the input stream.bufferSize - the bufferSize.key - crypto key for the cipher.params - the algorithm parameters.IOException - if an I/O error occurs.protected CryptoInputStream(ReadableByteChannel in, CryptoCipher cipher, int bufferSize, Key key, AlgorithmParameterSpec params) throws IOException
CryptoInputStream.in - the ReadableByteChannel instance.cipher - the cipher instance.bufferSize - the bufferSize.key - crypto key for the cipher.params - the algorithm parameters.IOException - if an I/O error occurs.protected CryptoInputStream(Input input, CryptoCipher cipher, int bufferSize, Key key, AlgorithmParameterSpec params) throws IOException
CryptoInputStream.input - the input data.cipher - the cipher instance.bufferSize - the bufferSize.key - crypto key for the cipher.params - the algorithm parameters.IOException - if an I/O error occurs.public int read()
throws IOException
InputStream.read(). Reads the next byte of
data from the input stream.read ??? InputStream-1 if the end of the
stream is reached.IOException - if an I/O error occurs.public int read(byte[] b,
int off,
int len)
throws IOException
InputStream.read(byte[], int, int).
Decryption is buffer based. If there is data in outBuffer, then
read it out of this buffer. If there is no data in outBuffer,
then read more from the underlying stream and do the decryption.read ??? InputStreamb - the buffer into which the decrypted data is read.off - the buffer offset.len - the maximum number of decrypted data bytes to read.IOException - if an I/O error occurs.public long skip(long n)
throws IOException
InputStream.skip(long). Skips over and
discards n bytes of data from this input stream.skip ??? InputStreamn - the number of bytes to be skipped.IOException - if an I/O error occurs.public int available()
throws IOException
InputStream.available(). Returns an estimate of the
number of bytes that can be read (or skipped over) from this input stream
without blocking by the next invocation of a method for this input
stream.available ??? InputStream0 when
it reaches the end of the input stream.IOException - if an I/O error occurs.public void close()
throws IOException
InputStream.close(). Closes this input stream and
releases any system resources associated with the stream.close ???? Closeableclose ???? AutoCloseableclose ???? Channelclose ??? InputStreamIOException - if an I/O error occurs.public void mark(int readlimit)
InputStream.mark(int). For
CryptoInputStream,we don't support the mark method.mark ??? InputStreamreadlimit - the maximum limit of bytes that can be read before the
mark position becomes invalid.public void reset()
throws IOException
InputStream.reset(). For CryptoInputStream
,we don't support the reset method.reset ??? InputStreamIOException - if an I/O error occurs.public boolean markSupported()
InputStream.markSupported().markSupported ??? InputStreamCtrCryptoInputStream don't support the mark
method.public boolean isOpen()
Channel.isOpen().public int read(ByteBuffer dst) throws IOException
ReadableByteChannel.read(ByteBuffer). Reads a
sequence of bytes from this channel into the given buffer.read ???? ReadableByteChanneldst - The buffer into which bytes are to be transferred.IOException - if an I/O error occurs.protected int getBufferSize()
protected Key getKey()
protected CryptoCipher getCipher()
protected AlgorithmParameterSpec getParams()
protected Input getInput()
protected void initCipher()
throws IOException
IOException - if an I/O error occurs.protected int decryptMore()
throws IOException
IOException - if an I/O error occurs.protected void decrypt()
throws IOException
IOException - if an I/O error occurs.protected void decryptFinal()
throws IOException
IOException - if an I/O error occurs.protected void checkStream()
throws IOException
IOException - if an I/O error occurs.protected void freeBuffers()
Copyright © 2016 The Apache Software Foundation. All rights reserved.