public class SSLSocketChannel extends Object implements WrappedByteChannel, ByteChannel, ISSLChannel
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.
Modified by marci4 to allow the usage as a ByteChannel
Permission for usage received at May 25, 2017 by Alex Karnezis
| Constructor and Description |
|---|
SSLSocketChannel(SocketChannel inputSocketChannel,
SSLEngine inputEngine,
ExecutorService inputExecutor,
SelectionKey key) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
SSLEngine |
getSSLEngine()
Get the ssl engine used for the de- and encryption of the communication.
|
boolean |
isBlocking()
This function returns the blocking state of the channel
|
boolean |
isNeedRead()
returns whether readMore should be called to fetch data which has been decoded but not yet been
returned.
|
boolean |
isNeedWrite()
returns whether writeMore should be called write additional data.
|
boolean |
isOpen() |
int |
read(ByteBuffer dst) |
int |
readMore(ByteBuffer dst)
This function does not read data from the underlying channel at all.
|
int |
write(ByteBuffer output) |
void |
writeMore()
Gets called when
WrappedByteChannel.isNeedWrite() ()} requires a additional rite |
public SSLSocketChannel(SocketChannel inputSocketChannel, SSLEngine inputEngine, ExecutorService inputExecutor, SelectionKey key) throws IOException
IOExceptionpublic int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelIOExceptionpublic int write(ByteBuffer output) throws IOException
write in interface WritableByteChannelIOExceptionpublic boolean isNeedWrite()
WrappedByteChannelisNeedWrite in interface WrappedByteChannelpublic void writeMore()
throws IOException
WrappedByteChannelWrappedByteChannel.isNeedWrite() ()} requires a additional ritewriteMore in interface WrappedByteChannelIOException - may be thrown due to an error while writingpublic boolean isNeedRead()
WrappedByteChannelisNeedRead in interface WrappedByteChannelReadableByteChannel.read(ByteBuffer),
WrappedByteChannel.readMore(ByteBuffer)public int readMore(ByteBuffer dst) throws IOException
WrappedByteChannelReadableByteChannel.read(ByteBuffer).readMore in interface WrappedByteChanneldst - the destiny of the readIOException - when a error occurred during unwrappingpublic boolean isBlocking()
WrappedByteChannelisBlocking in interface WrappedByteChannelpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOExceptionpublic SSLEngine getSSLEngine()
ISSLChannelgetSSLEngine in interface ISSLChannelCopyright © 2021. All rights reserved.