Class TlsNioSocket
java.lang.Object
io.helidon.common.socket.NioSocket
io.helidon.common.socket.TlsNioSocket
- All Implemented Interfaces:
HelidonSocket, SocketContext, Supplier<byte[]>
TLS NIO helidon socket.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TlsNioSocketclient(SocketChannel delegate, SSLEngine sslEngine, String channelId) Create a client TLS NIO socket.voidclose()Close the underlying socket.byte[]get()voidComplete the initial TLS handshake.voididle()Sets the socket to idle mode.booleanCheck if socket is connected.booleanisSecure()Whether the request is secure.Local peer information.protocol()Protocol that was negotiated.booleanWhether a protocol was negotiated by the socket (such as ALPN when using TLS).Remote peer information.static TlsNioSocketserver(SocketChannel delegate, SSLEngine sslEngine, String channelId, String serverChannelId) Create a server TLS NIO socket.static TlsNioSocketserver(SocketChannel delegate, SSLEngine sslEngine, String channelId, String serverChannelId, ByteBuffer replayNetData) Create a server TLS NIO socket with already-read TLS network data to replay into the first unwrap.voidwrite(BufferData buffer) Write teh buffer to the underlying socket.Methods inherited from class NioSocket
childSocketId, client, read, readNonBlocking, server, socketId, writeModifier and TypeMethodDescriptionChild socket id.static NioSocketclient(SocketChannel delegate, String channelId) Create a new client socket.protected intread(ByteBuffer buffer) Read from the underlying socket/channel into the provided buffer.protected intreadNonBlocking(ByteBuffer buffer) Read from the underlying socket/channel in non-blocking mode.static NioSocketserver(SocketChannel delegate, String channelId, String serverChannelId) Create a new server socket.socketId()Main socket id.protected intwrite(ByteBuffer buffer) Write to the underlying socket/channel from the provided buffer.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SocketContext
log, logModifier and TypeMethodDescriptiondefault voidlog(System.Logger logger, System.Logger.Level level, String format, Object... variables) Log a message with the currentSocketContext.socketId()andSocketContext.childSocketId()to have consistent logs mappable to sockets.default voidlog(System.Logger logger, System.Logger.Level level, String format, Throwable t, Object... variables) Log a message with the currentSocketContext.socketId()andSocketContext.childSocketId()to have consistent logs mappable to sockets.
-
Method Details
-
server
public static TlsNioSocket server(SocketChannel delegate, SSLEngine sslEngine, String channelId, String serverChannelId) Create a server TLS NIO socket.- Parameters:
delegate- underlying socketsslEngine- SSL enginechannelId- connection channel idserverChannelId- listener channel id- Returns:
- a new TLS socket
-
server
public static TlsNioSocket server(SocketChannel delegate, SSLEngine sslEngine, String channelId, String serverChannelId, ByteBuffer replayNetData) Create a server TLS NIO socket with already-read TLS network data to replay into the first unwrap. This is intended for server implementations that need to inspect TLS records before creating the engine.- Parameters:
delegate- underlying socketsslEngine- SSL enginechannelId- connection channel idserverChannelId- listener channel idreplayNetData- already-read TLS network data- Returns:
- a new TLS socket
-
client
Create a client TLS NIO socket.- Parameters:
delegate- underlying socketsslEngine- SSL enginechannelId- channel id- Returns:
- a new TLS socket
-
remotePeer
Description copied from interface:SocketContextRemote peer information.- Specified by:
remotePeerin interfaceSocketContext- Overrides:
remotePeerin classNioSocket- Returns:
- peer info
-
localPeer
Description copied from interface:SocketContextLocal peer information.- Specified by:
localPeerin interfaceSocketContext- Overrides:
localPeerin classNioSocket- Returns:
- peer info
-
isSecure
public boolean isSecure()Description copied from interface:SocketContextWhether the request is secure.- Specified by:
isSecurein interfaceSocketContext- Overrides:
isSecurein classNioSocket- Returns:
- whether secure
-
protocolNegotiated
public boolean protocolNegotiated()Description copied from interface:HelidonSocketWhether a protocol was negotiated by the socket (such as ALPN when using TLS).- Returns:
- whether a protocol was negotiated
-
protocol
Description copied from interface:HelidonSocketProtocol that was negotiated.- Returns:
- protocol name
-
get
-
write
Description copied from interface:HelidonSocketWrite teh buffer to the underlying socket. This method blocks until all bytes are written.- Specified by:
writein interfaceHelidonSocket- Overrides:
writein classNioSocket- Parameters:
buffer- buffer to write
-
handshake
public void handshake()Complete the initial TLS handshake. -
close
public void close()Description copied from interface:HelidonSocketClose the underlying socket.- Specified by:
closein interfaceHelidonSocket- Overrides:
closein classNioSocket
-
idle
public void idle()Description copied from interface:HelidonSocketSets the socket to idle mode. Idle mode expects no bytes coming over the socket but keeps reading exactly one byte in case connection is severed. Idle mode should be used in case of client side connection caching.- Specified by:
idlein interfaceHelidonSocket- Overrides:
idlein classNioSocket
-
isConnected
public boolean isConnected()Description copied from interface:HelidonSocketCheck if socket is connected.- Specified by:
isConnectedin interfaceHelidonSocket- Overrides:
isConnectedin classNioSocket- Returns:
- true if connected
-