Package org.jenkinsci.remoting.engine
Class JnlpProtocol4Handler
java.lang.Object
org.jenkinsci.remoting.engine.JnlpProtocolHandler<Jnlp4ConnectionState>
org.jenkinsci.remoting.engine.JnlpProtocol4Handler
Implements the JNLP4-connect protocol. This protocol uses
SSLEngine
to perform a TLS upgrade of the plaintext
connection before any connection secrets are exchanged. The subsequent connection is then secured using TLS. The
implementation uses the IOHub
for non-blocking I/O wherever possible which removes the bottleneck of
the selector thread being used for linearization and I/O that creates a throughput limit with NioChannelHub
.- Since:
- 3.0
-
Constructor Summary
ConstructorDescriptionJnlpProtocol4Handler
(JnlpClientDatabase clientDatabase, ExecutorService threadPool, IOHub ioHub, SSLContext context, boolean needClientAuth, boolean preferNio) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionconnect
(Socket socket, Map<String, String> headers, List<? extends JnlpConnectionStateListener> listeners) Handles an outgoing connection to the server on the supplied socket.createConnectionState
(Socket socket, List<? extends JnlpConnectionStateListener> listeners) Creates theJnlpConnectionState
instance for thisJnlpProtocolHandler
.getName()
Get the name of the protocol.handle
(Socket socket, Map<String, String> headers, List<? extends JnlpConnectionStateListener> listeners) Handles an incoming client connection on the supplied socket.Methods inherited from class org.jenkinsci.remoting.engine.JnlpProtocolHandler
connect, getClientDatabase, handle, isEnabled, isPreferNio
-
Constructor Details
-
JnlpProtocol4Handler
public JnlpProtocol4Handler(@Nullable JnlpClientDatabase clientDatabase, @NonNull ExecutorService threadPool, @NonNull IOHub ioHub, @NonNull SSLContext context, boolean needClientAuth, boolean preferNio) Constructor.- Parameters:
clientDatabase
- the client database.threadPool
- the thread pool.ioHub
- theIOHub
.context
- theSSLContext
.needClientAuth
- to force all clients to have a client certificate in order to connect.preferNio
-true
means that the protocol should attempt to use NIO if possible.
-
-
Method Details
-
getName
Get the name of the protocol.- Specified by:
getName
in classJnlpProtocolHandler<Jnlp4ConnectionState>
-
createConnectionState
@NonNull public Jnlp4ConnectionState createConnectionState(@NonNull Socket socket, @NonNull List<? extends JnlpConnectionStateListener> listeners) Description copied from class:JnlpProtocolHandler
Creates theJnlpConnectionState
instance for thisJnlpProtocolHandler
.- Specified by:
createConnectionState
in classJnlpProtocolHandler<Jnlp4ConnectionState>
- Parameters:
socket
- theSocket
listeners
- the initialJnlpConnectionStateListener
instances.- Returns:
- the
JnlpConnectionState
for this connection.
-
handle
@NonNull public Future<Channel> handle(@NonNull Socket socket, @NonNull Map<String, String> headers, @NonNull List<? extends JnlpConnectionStateListener> listeners) throws IOExceptionHandles an incoming client connection on the supplied socket.- Specified by:
handle
in classJnlpProtocolHandler<Jnlp4ConnectionState>
- Parameters:
socket
- the socket.headers
- the headers to send to the client.listeners
- the listeners to process the connection.- Returns:
- a
Future
for theChannel
to the server. - Throws:
IOException
- if the protocol cannot be initiated.
-
connect
@NonNull public Future<Channel> connect(@NonNull Socket socket, @NonNull Map<String, String> headers, @NonNull List<? extends JnlpConnectionStateListener> listeners) throws IOExceptionHandles an outgoing connection to the server on the supplied socket.- Specified by:
connect
in classJnlpProtocolHandler<Jnlp4ConnectionState>
- Parameters:
socket
- the socket.headers
- the headers to send to the server.listeners
- the listeners to process the connection.- Returns:
- a
Future
for theChannel
to the server. - Throws:
IOException
- if the protocol cannot be initiated.
-