Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.io.InputStream
gnu.javax.crypto.sasl.SaslInputStream
public class SaslInputStream
extends InputStream
SaslClient
or a SaslServer
to process the data through these entities' security layer filter(s).
Constructor Summary | |
| |
|
Method Summary | |
int |
|
void |
|
int |
|
int |
|
Methods inherited from class java.io.InputStream | |
available , close , mark , markSupported , read , read , read , reset , skip |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public int available() throws IOException
This method returns the number of bytes that can be read from this stream before a read can block. A return of 0 indicates that blocking might (or might not) occur on the very next read attempt. This method always returns 0 in this class
- Overrides:
- available in interface InputStream
- Returns:
- The number of bytes that can be read before blocking could occur
- Throws:
IOException
- If an error occurs
public void close() throws IOException
This method closes the stream. Any futher attempts to read from the stream may generate anIOException
This method does nothing in this class, but subclasses may override this method in order to provide additional functionality.
- Specified by:
- close in interface Closeable
- close in interface AutoCloseable
- Overrides:
- close in interface InputStream
- Throws:
IOException
- If an error occurs, which can only happen in a subclass
public int read() throws IOException
Reads the next byte of data from the input stream. The value byte is returned as anint
in the range0
to255
. If no byte is available because the end of the stream has been reached, the value-1
is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. From a SASL mechanism provider's perspective, if a security layer has been negotiated, the underlying source is expected to contain SASL buffers, as defined in RFC 2222. Four octets in network byte order in the front of each buffer identify the length of the buffer. The provider is responsible for performing any integrity checking or other processing on the buffer before returning the data as a stream of octets. For example, the protocol driver's request for a single octet from the stream might; i.e. an invocation of this method, may result in an entire SASL buffer being read and processed before that single octet can be returned.
- Overrides:
- read in interface InputStream
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached.
- Throws:
IOException
- if an I/O error occurs.
public int read(byte[] b, int off, int len) throws IOException
Reads up tolen
bytes of data from the underlying source input stream into an array of bytes. An attempt is made to read as many aslen
bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown. Ifb
isnull
, aNullPointerException
is thrown. Ifoff
is negative, orlen
is negative, oroff+len
is greater than the length of the arrayb
, then anIndexOutOfBoundsException
is thrown. Iflen
is zero, then no bytes are read and0
is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value-1
is returned; otherwise, at least one byte is read and stored intob
. The first byte read is stored into elementb[off]
, the next one intob[off+1]
, and so on. The number of bytes read is, at most, equal tolen
. Letk
be the number of bytes actually read; these bytes will be stored in elementsb[off]
throughb[off+k-1]
, leaving elementsb[off+k]
throughb[off+len-1]
unaffected. In every case, elementsb[0]
throughb[off]
and elementsb[off+len]
throughb[b.length-1]
are unaffected. If the first byte cannot be read for any reason other than end of file, then anIOException
is thrown. In particular, anIOException
is thrown if the input stream has been closed. From the SASL mechanism provider's perspective, if a security layer has been negotiated, the underlying source is expected to contain SASL buffers, as defined in RFC 2222. Four octets in network byte order in the front of each buffer identify the length of the buffer. The provider is responsible for performing any integrity checking or other processing on the buffer before returning the data as a stream of octets. The protocol driver's request for a single octet from the stream might result in an entire SASL buffer being read and processed before that single octet can be returned.
- Overrides:
- read in interface InputStream
- Parameters:
b
- the buffer into which the data is read.off
- the start offset in arrayb
at which the data is wricodeen.len
- the maximum number of bytes to read.
- Returns:
- the total number of bytes read into the buffer, or
-1
if there is no more data because the end of the stream has been reached.
- Throws:
IOException
- if an I/O error occurs.