Class SSLSocketChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,ReadableByteChannel,WritableByteChannel,ISSLChannel,WrappedByteChannel
It makes use of the JSSE framework, and specifically the SSLEngine logic, which is
described by Oracle as "an advanced API, not appropriate for casual use", since it requires the
user to implement much of the communication establishment procedure himself. More information
about it can be found here: http://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#SSLEngine
SSLSocketChannel implements the handshake protocol, required to establish a connection
between two peers, which is common for both client and server and provides the abstract read(ByteBuffer) and write(ByteBuffer) (String)}
methods, that need to be implemented by the specific SSL/TLS peer that is going to extend this
class.
- Author:
- Alex Karnezis
Modified by marci4 to allow the usage as a ByteChannel
Permission for usage received at May 25, 2017 by Alex Karnezis
-
Constructor Summary
ConstructorsConstructorDescriptionSSLSocketChannel(SocketChannel inputSocketChannel, SSLEngine inputEngine, ExecutorService inputExecutor, SelectionKey key) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Get the ssl engine used for the de- and encryption of the communication.booleanThis function returns the blocking state of the channelbooleanreturns whether readMore should be called to fetch data which has been decoded but not yet been returned.booleanreturns whether writeMore should be called write additional data.booleanisOpen()intread(ByteBuffer dst) intreadMore(ByteBuffer dst) This function does not read data from the underlying channel at all.intwrite(ByteBuffer output) voidGets called whenWrappedByteChannel.isNeedWrite()()} requires a additional rite
-
Constructor Details
-
SSLSocketChannel
public SSLSocketChannel(SocketChannel inputSocketChannel, SSLEngine inputEngine, ExecutorService inputExecutor, SelectionKey key) throws IOException - Throws:
IOException
-
-
Method Details
-
read
- Specified by:
readin interfaceReadableByteChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
isNeedWrite
public boolean isNeedWrite()Description copied from interface:WrappedByteChannelreturns whether writeMore should be called write additional data.- Specified by:
isNeedWritein interfaceWrappedByteChannel- Returns:
- is a additional write needed
-
writeMore
Description copied from interface:WrappedByteChannelGets called whenWrappedByteChannel.isNeedWrite()()} requires a additional rite- Specified by:
writeMorein interfaceWrappedByteChannel- Throws:
IOException- may be thrown due to an error while writing
-
isNeedRead
public boolean isNeedRead()Description copied from interface:WrappedByteChannelreturns whether readMore should be called to fetch data which has been decoded but not yet been returned.- Specified by:
isNeedReadin interfaceWrappedByteChannel- Returns:
- is a additional read needed
- See Also:
-
readMore
Description copied from interface:WrappedByteChannelThis function does not read data from the underlying channel at all. It is just a way to fetch data which has already be received or decoded but was but was not yet returned to the user. This could be the case when the decoded data did not fit into the buffer the user passed toReadableByteChannel.read(ByteBuffer).- Specified by:
readMorein interfaceWrappedByteChannel- Parameters:
dst- the destiny of the read- Returns:
- the amount of remaining data
- Throws:
IOException- when a error occurred during unwrapping
-
isBlocking
public boolean isBlocking()Description copied from interface:WrappedByteChannelThis function returns the blocking state of the channel- Specified by:
isBlockingin interfaceWrappedByteChannel- Returns:
- is the channel blocking
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getSSLEngine
Description copied from interface:ISSLChannelGet the ssl engine used for the de- and encryption of the communication.- Specified by:
getSSLEnginein interfaceISSLChannel- Returns:
- the ssl engine of this channel
-