Top Description Inners Fields Constructors Methods
org.apache.tomcat.websocket

public Class AsyncChannelWrapperSecure

extends Object
implements AsyncChannelWrapper
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.websocket.AsyncChannelWrapper
Imports
java.io.EOFException, .IOException, java.net.SocketAddress, java.nio.ByteBuffer, java.nio.channels.AsynchronousSocketChannel, .CompletionHandler, java.util.concurrent.CountDownLatch, .ExecutionException, .ExecutorService, .Executors, .Future, .ThreadFactory, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, javax.net.ssl.SSLEngine, .SSLEngineResult, .SSLEngineResult.HandshakeStatus, .SSLEngineResult.Status, .SSLException, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.res.StringManager

Wraps the AsynchronousSocketChannel with SSL/TLS. This needs a lot more testing before it can be considered robust.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
private static class
private class
private static class
private class

Field Summary

Modifier and TypeField and Description
private static final ByteBuffer
private final ExecutorService
private final Log
private AtomicBoolean
private static final StringManager
private final AsynchronousSocketChannel
private final ByteBuffer
private final ByteBuffer
private final SSLEngine
private AtomicBoolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public SocketAddress
public Future<Void>
public Future<Integer>
public <B, A extends B> void
public Future<Integer>
public <B, A extends B> void
write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, B> handler)

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.write.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DUMMYback to summary
private static final ByteBuffer DUMMY
executorback to summary
private final ExecutorService executor
logback to summary
private final Log log
readingback to summary
private AtomicBoolean reading
smback to summary
private static final StringManager sm
socketChannelback to summary
private final AsynchronousSocketChannel socketChannel
socketReadBufferback to summary
private final ByteBuffer socketReadBuffer
socketWriteBufferback to summary
private final ByteBuffer socketWriteBuffer
sslEngineback to summary
private final SSLEngine sslEngine
writingback to summary
private AtomicBoolean writing

Constructor Detail

AsyncChannelWrapperSecureback to summary
public AsyncChannelWrapperSecure(AsynchronousSocketChannel socketChannel, SSLEngine sslEngine)

Method Detail

closeback to summary
public void close()

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.close.

Annotations
@Override
getLocalAddressback to summary
public SocketAddress getLocalAddress() throws IOException

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.getLocalAddress.

Annotations
@Override
handshakeback to summary
public Future<Void> handshake() throws SSLException

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.handshake.

Annotations
@Override
readback to summary
public Future<Integer> read(ByteBuffer dst)

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.read.

Annotations
@Override
readback to summary
public <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer, B> handler)

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.read.

Annotations
@Override
writeback to summary
public Future<Integer> write(ByteBuffer src)

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.write.

Annotations
@Override
writeback to summary
public <B, A extends B> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, B> handler)

Implements org.apache.tomcat.websocket.AsyncChannelWrapper.write.

Annotations
@Override
org.apache.tomcat.websocket back to summary

private final Class AsyncChannelWrapperSecure.LongToIntegerFuture

extends Object
implements Future<Integer>
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.websocket.AsyncChannelWrapperSecure.LongToIntegerFuture
All Implemented Interfaces
java.util.concurrent.Future

Field Summary

Modifier and TypeField and Description
private final Future<Long>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel(boolean
true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete
mayInterruptIfRunning
)

Implements java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.

public Integer
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

public Integer
get(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

public boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

wrappedback to summary
private final Future<Long> wrapped

Constructor Detail

LongToIntegerFutureback to summary
pack-priv LongToIntegerFuture(Future<Long> wrapped)

Method Detail

cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Doc from java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task. This method has no effect if the task is already completed or cancelled, or could not be cancelled for some other reason. Otherwise, if this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.

The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled.

Parameters
mayInterruptIfRunning:boolean

true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete

Returns:boolean

false if the task could not be cancelled, typically because it has already completed; true otherwise. If two or more threads cause a task to be cancelled, then at least one of them returns true. Implementations may provide stronger guarantees.

Annotations
@Override
getback to summary
public Integer get() throws InterruptedException, ExecutionException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Returns:Integer

the computed result

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
getback to summary
public Integer get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:Integer

the computed result

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
TimeoutException:
if the wait timed out
isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Returns:boolean

true if this task was cancelled before it completed

Annotations
@Override
isDoneback to summary
public boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Returns:boolean

true if this task completed

Annotations
@Override
org.apache.tomcat.websocket back to summary

private Class AsyncChannelWrapperSecure.ReadTask

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.websocket.AsyncChannelWrapperSecure.ReadTask
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
private final AsyncChannelWrapperSecure.WrapperFuture<Integer, ?>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

destback to summary
private final ByteBuffer dest
futureback to summary
private final AsyncChannelWrapperSecure.WrapperFuture<Integer, ?> future

Constructor Detail

ReadTaskback to summary
pack-priv ReadTask(ByteBuffer dest, AsyncChannelWrapperSecure.WrapperFuture<Integer, ?> future)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
org.apache.tomcat.websocket back to summary

private Class AsyncChannelWrapperSecure.SecureIOThreadFactory

extends Object
implements ThreadFactory
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.websocket.AsyncChannelWrapperSecure.SecureIOThreadFactory
All Implemented Interfaces
java.util.concurrent.ThreadFactory

Field Summary

Modifier and TypeField and Description
private AtomicInteger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Thread
newThread(Runnable
a runnable to be executed by new thread instance
r
)

Implements java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

countback to summary
private AtomicInteger count

Constructor Detail

SecureIOThreadFactoryback to summary
private SecureIOThreadFactory()

Method Detail

newThreadback to summary
public Thread newThread(Runnable r)

Implements java.util.concurrent.ThreadFactory.newThread.

Doc from java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Parameters
r:Runnable

a runnable to be executed by new thread instance

Returns:Thread

constructed thread, or null if the request to create a thread is rejected

Annotations
@Override
org.apache.tomcat.websocket back to summary

private Class AsyncChannelWrapperSecure.WebSocketSslHandshakeThread

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
private SSLEngineResult.HandshakeStatus
private final AsyncChannelWrapperSecure.WrapperFuture<Void, Void>
private SSLEngineResult.Status
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
checkResult(SSLEngineResult result, boolean wrap)

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

handshakeStatusback to summary
private SSLEngineResult.HandshakeStatus handshakeStatus
hFutureback to summary
private final AsyncChannelWrapperSecure.WrapperFuture<Void, Void> hFuture
resultStatusback to summary
private SSLEngineResult.Status resultStatus

Constructor Detail

WebSocketSslHandshakeThreadback to summary
pack-priv WebSocketSslHandshakeThread(AsyncChannelWrapperSecure.WrapperFuture<Void, Void> hFuture)

Method Detail

checkResultback to summary
private void checkResult(SSLEngineResult result, boolean wrap) throws SSLException
runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override
org.apache.tomcat.websocket back to summary

private Class AsyncChannelWrapperSecure.WrapperFuture<T, A>

extends Object
implements Future<T>
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.websocket.AsyncChannelWrapperSecure.WrapperFuture
All Implemented Interfaces
java.util.concurrent.Future

Field Summary

Modifier and TypeField and Description
private final A
private CountDownLatch
private final CompletionHandler<T, A>
private volatile T
private volatile Throwable

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
WrapperFuture(CompletionHandler<T, A> handler, A attachment)

Method Summary

Modifier and TypeMethod and Description
public final boolean
cancel(boolean
true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete
mayInterruptIfRunning
)

Implements java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.

public void
complete(T result)

public void
public T
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

public T
get(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

public final boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

public final boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attachmentback to summary
private final A attachment
completionLatchback to summary
private CountDownLatch completionLatch
handlerback to summary
private final CompletionHandler<T, A> handler
resultback to summary
private volatile T result
throwableback to summary
private volatile Throwable throwable

Constructor Detail

WrapperFutureback to summary
pack-priv WrapperFuture()
WrapperFutureback to summary
pack-priv WrapperFuture(CompletionHandler<T, A> handler, A attachment)

Method Detail

cancelback to summary
public final boolean cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Doc from java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task. This method has no effect if the task is already completed or cancelled, or could not be cancelled for some other reason. Otherwise, if this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.

The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled.

Parameters
mayInterruptIfRunning:boolean

true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete

Returns:boolean

false if the task could not be cancelled, typically because it has already completed; true otherwise. If two or more threads cause a task to be cancelled, then at least one of them returns true. Implementations may provide stronger guarantees.

Annotations
@Override
completeback to summary
public void complete(T result)
failback to summary
public void fail(Throwable t)
getback to summary
public T get() throws InterruptedException, ExecutionException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Returns:T

the computed result

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
getback to summary
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:T

the computed result

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
TimeoutException:
if the wait timed out
isCancelledback to summary
public final boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Returns:boolean

true if this task was cancelled before it completed

Annotations
@Override
isDoneback to summary
public final boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Returns:boolean

true if this task completed

Annotations
@Override
org.apache.tomcat.websocket back to summary

private Class AsyncChannelWrapperSecure.WriteTask

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.websocket.AsyncChannelWrapperSecure.WriteTask
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final AsyncChannelWrapperSecure.WrapperFuture<Long, ?>
private final int
private final int
private final ByteBuffer[]

Constructor Summary

AccessConstructor and Description
pack-priv
WriteTask(ByteBuffer[] srcs, int offset, int length, AsyncChannelWrapperSecure.WrapperFuture<Long, ?> future)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

futureback to summary
private final AsyncChannelWrapperSecure.WrapperFuture<Long, ?> future
lengthback to summary
private final int length
offsetback to summary
private final int offset
srcsback to summary
private final ByteBuffer[] srcs

Constructor Detail

WriteTaskback to summary
pack-priv WriteTask(ByteBuffer[] srcs, int offset, int length, AsyncChannelWrapperSecure.WrapperFuture<Long, ?> future)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override