01: package org.bouncycastle.crypto.tls;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05:
06: /**
07: * An InputStream for an TLS 1.0 connection.
08: */
09: public class TlsInputStream extends InputStream {
10: private byte[] buf = new byte[1];
11: private TlsProtocolHandler handler = null;
12:
13: TlsInputStream(TlsProtocolHandler handler) {
14: this .handler = handler;
15: }
16:
17: public int read(byte[] buf, int offset, int len) throws IOException {
18: return this .handler.readApplicationData(buf, offset, len);
19: }
20:
21: public int read() throws IOException {
22: if (this .read(buf) < 0) {
23: return -1;
24: }
25: return buf[0] & 0xff;
26: }
27:
28: public void close() throws IOException {
29: handler.close();
30: }
31: }
|