Inpublic class In extends InputStream This class is a subclass of InputStream and obtains its input bytes
from an SSL connection.
|
Fields Summary |
---|
private boolean | isClosedIndicates the input stream is closed. | private Record | recUnderlying SSL record layer from which bytes are read. | private int | startStart of plain text in data buffer. | private int | cntCount of unread bytes left in data buffer. | private SSLStreamConnection | sscHandle for current SSL stream connection. | private boolean | endOfStreamSignals end of stream. |
Methods Summary |
---|
public int | available()Returns the number of bytes that can be read (or skipped over) from
this input stream without blocking by the next caller of a method for
this input stream. The next caller might be the same thread or
another thread.
if (isClosed) {
throw new InterruptedIOException("Stream closed");
}
synchronized(rec) {
if (cnt == 0) {
// The record buffer is empty, try to refill it without blocking.
refill(false);
}
return cnt;
}
| public synchronized void | close()Close the stream connection.
if (isClosed) {
return;
}
isClosed = true;
if (ssc != null) {
ssc.inputStreamState = SSLStreamConnection.CLOSED;
rec.closeInputStream();
ssc.cleanupIfNeeded();
}
| public int | read()Reads a byte from this input stream. The method blocks if no
input is available.
int val;
if (isClosed) {
throw new InterruptedIOException("Stream closed");
}
synchronized(rec) {
if (cnt == 0) {
refill(true);
if (cnt == 0) {
return -1; // end of stream
}
}
val = rec.inputData[start++] & 0xff;
cnt--;
}
return val;
| public int | read(byte[] b)Reads up to b.length bytes of data from this
input stream into the byte array b . Blocks until
some input is available. This is equivalent to
read(b, 0, b.length) .
return read(b, 0, b.length);
| public int | read(byte[] b, int off, int len)Reads up to len bytes of data from this input stream
into b starting at offset off .
int i = 0;
int numBytes;
if (isClosed) {
throw new InterruptedIOException("Stream closed");
}
synchronized(rec) {
if (cnt == 0) {
// Record buffer empty, block until it is refilled.
refill(true);
if (cnt == 0) {
return -1; // end of stream
}
}
if (len > cnt) {
numBytes = cnt;
} else {
numBytes = len;
}
System.arraycopy(rec.inputData, start, b, off, numBytes);
start += numBytes;
cnt -= numBytes;
}
return numBytes;
| private void | refill(boolean block)Refills the internal store of decrypted bytes. Called when
the byte count in the store reaches zero.
if (endOfStream) {
return;
}
for (; ;) {
rec.rdRec(block, Record.APP);
if (rec.plainTextLength == -1) {
endOfStream = true;
return;
}
// Do not unblock on a zero byte record unless asked
if (!block || rec.plainTextLength > 0) {
break;
}
}
cnt = rec.plainTextLength;
start = 0;
|
|