Package org.apache.hadoop.security
Class SaslInputStream
java.lang.Object
java.io.InputStream
org.apache.hadoop.security.SaslInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,ReadableByteChannel
@LimitedPrivate({"HDFS","MapReduce"})
@Evolving
public class SaslInputStream
extends InputStream
implements ReadableByteChannel
A SaslInputStream is composed of an InputStream and a SaslServer (or
SaslClient) so that read() methods return data that are read in from the
underlying InputStream but have been additionally processed by the SaslServer
(or SaslClient) object. The SaslServer (or SaslClient) object must be fully
initialized before being used by a SaslInputStream.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSaslInputStream(InputStream inStream, SaslClient saslClient) Constructs a SASLInputStream from an InputStream and a SaslClient
Note: if the specified InputStream or SaslClient is null, a NullPointerException may be thrown later when they are used.SaslInputStream(InputStream inStream, SaslServer saslServer) Constructs a SASLInputStream from an InputStream and a SaslServer
Note: if the specified InputStream or SaslServer is null, a NullPointerException may be thrown later when they are used. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes that can be read from this input stream without blocking.voidclose()Closes this input stream and releases any system resources associated with the stream.booleanisOpen()booleanTests if this input stream supports themarkandresetmethods, which it does not.intread()Reads the next byte of data from this input stream.intread(byte[] b) Reads up tob.lengthbytes of data from this input stream into an array of bytes.intread(byte[] b, int off, int len) Reads up tolenbytes of data from this input stream into an array of bytes.intread(ByteBuffer dst) longskip(long n) Skipsnbytes of input from the bytes that can be read from this input stream without blocking.Methods inherited from class java.io.InputStream
mark, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
SaslInputStream
Constructs a SASLInputStream from an InputStream and a SaslServer
Note: if the specified InputStream or SaslServer is null, a NullPointerException may be thrown later when they are used.- Parameters:
inStream- the InputStream to be processedsaslServer- an initialized SaslServer object
-
SaslInputStream
Constructs a SASLInputStream from an InputStream and a SaslClient
Note: if the specified InputStream or SaslClient is null, a NullPointerException may be thrown later when they are used.- Parameters:
inStream- the InputStream to be processedsaslClient- an initialized SaslClient object
-
-
Method Details
-
read
Reads the next byte of data from this input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
readin classInputStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
IOException- if an I/O error occurs.
-
read
Reads up tob.lengthbytes of data from this input stream into an array of bytes.The
readmethod ofInputStreamcalls thereadmethod of three arguments with the argumentsb,0, andb.length.- Overrides:
readin classInputStream- Parameters:
b- the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer, or
-1is there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occurs.
-
read
Reads up tolenbytes of data from this input stream into an array of bytes. This method blocks until some input is available. If the first argument isnull,up tolenbytes are read and discarded.- Overrides:
readin classInputStream- Parameters:
b- the buffer into which the data is read.off- the start offset of the data.len- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occurs.
-
skip
Skipsnbytes of input from the bytes that can be read from this input stream without blocking.Fewer bytes than requested might be skipped. The actual number of bytes skipped is equal to
nor the result of a call toavailable(), whichever is smaller. Ifnis less than zero, no bytes are skipped.The actual number of bytes skipped is returned.
- Overrides:
skipin classInputStream- Parameters:
n- the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped.
- Throws:
IOException- if an I/O error occurs.
-
available
Returns the number of bytes that can be read from this input stream without blocking. Theavailablemethod ofInputStreamreturns0. This method should be overridden by subclasses.- Overrides:
availablein classInputStream- Returns:
- the number of bytes that can be read from this input stream without blocking.
- Throws:
IOException- if an I/O error occurs.
-
close
Closes this input stream and releases any system resources associated with the stream.The
closemethod ofSASLInputStreamcalls theclosemethod of its underlying input stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- if an I/O error occurs.
-
markSupported
public boolean markSupported()Tests if this input stream supports themarkandresetmethods, which it does not.- Overrides:
markSupportedin classInputStream- Returns:
false, since this class does not support themarkandresetmethods.
-
isOpen
public boolean isOpen() -
read
- Specified by:
readin interfaceReadableByteChannel- Throws:
IOException
-