public class SSLServerSocketChannel
extends java.nio.channels.ServerSocketChannel
A wrapper around a real ServerSocketChannel
that produces SSLSocketChannel
on accept()
. The real ServerSocketChannel must be
bound externally (to this class) before calling the accept method.
SSLSocketChannel
Modifier and Type | Field and Description |
---|---|
boolean |
blockingMode
Should the SSLSocketChannels created from the accept method be put in blocking mode.
|
java.util.List<java.lang.String> |
excludedCipherSuites
A list of ciphers to explicitly exclude for the SSL exchange.
|
java.util.List<java.lang.String> |
excludedProtocols
A list of SSL protocols (SSLv2, SSLv3, etc.) to explicitly exclude for the SSL exchange.
|
java.util.List<java.lang.String> |
includedCipherSuites
The list of ciphers allowed for the SSL exchange.
|
java.util.List<java.lang.String> |
includedProtocols
The list of SSL protocols (TLSv1, TLSv1.1, etc.) supported for the SSL exchange.
|
boolean |
needClientAuthentication
Should the SSL server require client certificate authentication? Default is
false . |
boolean |
wantClientAuthentication
Should the SS server ask for client certificate authentication? Default is
false . |
Constructor and Description |
---|
SSLServerSocketChannel(java.nio.channels.ServerSocketChannel serverSocketChannel,
javax.net.ssl.SSLContext sslContext,
java.util.concurrent.ExecutorService threadPool,
NioSslLogger logger) |
Modifier and Type | Method and Description |
---|---|
java.nio.channels.SocketChannel |
accept()
Accepts a connection made to this channel's socket.
|
SSLSocketChannel |
acceptOverSSL()
Convenience call to keep from having to cast
SocketChannel into SSLSocketChannel when calling accept() . |
java.nio.channels.ServerSocketChannel |
bind(java.net.SocketAddress local,
int backlog) |
java.net.SocketAddress |
getLocalAddress() |
<T> T |
getOption(java.net.SocketOption<T> name) |
protected void |
implCloseSelectableChannel() |
protected void |
implConfigureBlocking(boolean b) |
<T> java.nio.channels.ServerSocketChannel |
setOption(java.net.SocketOption<T> name,
T value) |
java.net.ServerSocket |
socket() |
java.util.Set<java.net.SocketOption<?>> |
supportedOptions() |
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
begin, close, end, isOpen
public boolean blockingMode
false
.public boolean wantClientAuthentication
false
.public boolean needClientAuthentication
false
.public java.util.List<java.lang.String> includedProtocols
public java.util.List<java.lang.String> excludedProtocols
public java.util.List<java.lang.String> includedCipherSuites
public java.util.List<java.lang.String> excludedCipherSuites
public SSLServerSocketChannel(java.nio.channels.ServerSocketChannel serverSocketChannel, javax.net.ssl.SSLContext sslContext, java.util.concurrent.ExecutorService threadPool, NioSslLogger logger)
serverSocketChannel
- The real server socket channel that accepts network requests.sslContext
- The SSL context used to create the SSLEngine
for incoming requests.threadPool
- The thread pool passed to SSLSocketChannel used to execute long running, blocking SSL operations such as certificate validation with a CA (NEED_TASK)logger
- The logger for debug and error messages. A null logger will result in no log operations.public SSLSocketChannel acceptOverSSL() throws java.io.IOException
SocketChannel
into SSLSocketChannel
when calling accept()
.null
if this channel is in non-blocking mode and no connection is available to be accepted.java.io.IOException
accept()
public java.nio.channels.SocketChannel accept() throws java.io.IOException
Accepts a connection made to this channel's socket.
If this channel is in non-blocking mode then this method will immediately return null if there are no pending connections. Otherwise it will block indefinitely until a new connection is available or an I/O error occurs.
The socket channel returned by this method, if any, will be in blocking mode regardless of the blocking mode of this channel.
This method performs exactly the same security checks as the accept method of the ServerSocket class. That is, if a security manager has been installed then for each new connection this method verifies that the address and port number of the connection's remote endpoint are permitted by the security manager's checkAccept method.
accept
in class java.nio.channels.ServerSocketChannel
null
if this channel is in non-blocking mode and no connection is available to be accepted.java.nio.channels.NotYetConnectedException
- If this channel is not yet connectedjava.nio.channels.ClosedChannelException
- If this channel is closedjava.nio.channels.AsynchronousCloseException
- If another thread closes this channel while the read operation is in progressjava.nio.channels.ClosedByInterruptException
- If another thread interrupts the current thread while the read operation is in progress, thereby closing the channel and setting the current thread's interrupt statusjava.io.IOException
- If some other I/O error occurspublic java.nio.channels.ServerSocketChannel bind(java.net.SocketAddress local, int backlog) throws java.io.IOException
bind
in class java.nio.channels.ServerSocketChannel
java.io.IOException
public java.net.SocketAddress getLocalAddress() throws java.io.IOException
java.io.IOException
public <T> java.nio.channels.ServerSocketChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException
setOption
in interface java.nio.channels.NetworkChannel
setOption
in class java.nio.channels.ServerSocketChannel
java.io.IOException
public <T> T getOption(java.net.SocketOption<T> name) throws java.io.IOException
java.io.IOException
public java.util.Set<java.net.SocketOption<?>> supportedOptions()
public java.net.ServerSocket socket()
socket
in class java.nio.channels.ServerSocketChannel
protected void implCloseSelectableChannel() throws java.io.IOException
implCloseSelectableChannel
in class java.nio.channels.spi.AbstractSelectableChannel
java.io.IOException
protected void implConfigureBlocking(boolean b) throws java.io.IOException
implConfigureBlocking
in class java.nio.channels.spi.AbstractSelectableChannel
java.io.IOException