Top Description Inners Fields Constructors Methods
io.undertow.protocols.ssl

public Class SslConduit

extends Object
implements StreamSourceConduit, StreamSinkConduit
Class Inheritance
All Implemented Interfaces
org.xnio.conduits.StreamSinkConduit, org.xnio.conduits.SinkConduit, org.xnio.conduits.Conduit, org.xnio.conduits.StreamSourceConduit, org.xnio.conduits.SourceConduit
Imports
java.io.IOException, .InterruptedIOException, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, .FileChannel, java.util.ArrayList, .List, java.util.concurrent.Executor, .RejectedExecutionException, .TimeUnit, javax.net.ssl.SSLEngine, .SSLEngineResult, .SSLException, .SSLSession, io.undertow.UndertowLogger, io.undertow.connector.ByteBufferPool, .PooledByteBuffer, io.undertow.server.DefaultByteBufferPool, org.xnio.Buffers, .ChannelListener, .ChannelListeners, .IoUtils, .StreamConnection, .XnioIoThread, .XnioWorker, org.xnio.channels.StreamSinkChannel, .StreamSourceChannel, org.xnio.conduits.ConduitReadableByteChannel, .ConduitStreamSinkChannel, .ConduitStreamSourceChannel, .ConduitWritableByteChannel, .Conduits, .ReadReadyHandler, .StreamSinkConduit, .StreamSourceConduit, .WriteReadyHandler

Conduit for SSL connections.
Authors
Stuart Douglas, Flavia Rainone

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
SslConduit.DelegatedTaskRejectedClosedChannelException

A specialized ClosedChannelException which does not provide a stack trace.

private class
SslConduit.SslReadReadyHandler

Read ready handler that deals with read-requires-write semantics

private class
SslConduit.SslWriteReadyHandler

write read handler that deals with write-requires-read semantics

Field Summary

Modifier and TypeField and Description
private final ByteBufferPool
private final UndertowSslConnection
private volatile PooledByteBuffer
dataToUnwrap

Data that has been read from the underlying channel, and needs to be unwrapped.

private final StreamConnection
private final Executor
public static final ByteBuffer
private SSLEngine
private static volatile ByteBufferPool
expandedBufferPool

Buffer pool created and used only when large fragments handling is enabled in the underlying SSL Engine.

private static final int
private static final int
FLAG_DATA_TO_UNWRAP

If there is data in the dataToUnwrap buffer, and the last unwrap attempt did not result in a buffer underflow

private static final int
private static final int
private static final int
FLAG_ENGINE_INBOUND_SHUTDOWN

If the engine has been shut down

private static final int
FLAG_ENGINE_OUTBOUND_SHUTDOWN

If the engine has been shut down

private static final int
private static final int
private static final int
FLAG_READ_REQUIRES_WRITE

If this is set we are in the middle of a handshake, and we cannot read any more data until we have written out our wrap result

private static final int
FLAG_READ_SHUTDOWN

If the user has shutdown reads

private static final int
FLAG_READS_RESUMED

If reads are resumed.

private static final int
private static final int
FLAG_WRITE_REQUIRES_READ

If this is set we are in the process of handshaking and we cannot write any more data until we have read unwrapped data from the remote peer

private static final int
FLAG_WRITE_SHUTDOWN

If the user has shutdown writes

private static final int
FLAG_WRITES_RESUMED

If writes are resumed, the underlying delegate may not be resumed if a read is required

private final Runnable
private boolean
public static final int
private volatile int
private int
private SslConduit.SslReadReadyHandler
private final Runnable
private final Runnable
private final StreamSinkConduit
private final StreamSourceConduit
private volatile int
private volatile PooledByteBuffer
unwrappedData

Unwrapped data, ready to be delivered to the application.

private volatile PooledByteBuffer
wrappedData

Data that has been wrapped and is ready to be sent to the underlying channel.

private SslConduit.SslWriteReadyHandler

Constructor Summary

AccessConstructor and Description
pack-priv
SslConduit(UndertowSslConnection connection, StreamConnection delegate, SSLEngine engine, Executor delegatedTaskExecutor, ByteBufferPool bufferPool, Runnable handshakeCallback)

Method Summary

Modifier and TypeMethod and Description
public void
awaitReadable()

Implements org.xnio.conduits.SourceConduit.awaitReadable.

Block until this channel becomes readable again.

public void
awaitReadable(long
the time to wait
time
,
TimeUnit
the time unit
timeUnit
)

Implements org.xnio.conduits.SourceConduit.awaitReadable.

Block until this conduit becomes readable again, or until the timeout expires.

public void
awaitWritable()

Implements org.xnio.conduits.SinkConduit.awaitWritable.

Block until this channel becomes writable again.

public void
awaitWritable(long
the time to wait
time
,
TimeUnit
the time unit
timeUnit
)

Implements org.xnio.conduits.SinkConduit.awaitWritable.

Block until this conduit becomes writable again, or until the timeout expires.

private void
private void
public void
close()

forcibly closes the connection

private void
private void
doHandshake()

Force the handshake to continue

private synchronized long

Returns:

true if the unwrap operation made progress, false otherwise
doUnwrap
(ByteBuffer[] userBuffers, int off, int len)

Unwrap channel data into the user buffers.

private synchronized long

Returns:

The amount of data consumed
doWrap
(ByteBuffer[]
The buffers
userBuffers
,
int
The offset
off
,
int
The length
len
)

Wraps the user data and attempts to send it to the remote client.

private SSLEngineResult

Returns:

The last engine result
engineUnwrap
(ByteBuffer
The src wrapped data to unwrap.
src
,
ByteBuffer[]
The destinations buffers to unwrap the data to
dsts
,
int
Offset buffer
off
,
int
len buffer
len
,
SslConduit.AccumulativeOrBoolean
Accumulative or boolean for the bytes produced
bytesProduced
)

Perform unwraps while it is needed and there is data in src buffer.

public boolean
flush()

Implements org.xnio.conduits.SinkConduit.flush.

Flush out any unwritten, buffered output.

private Executor
public XnioIoThread
getReadThread()

Implements org.xnio.conduits.SourceConduit.getReadThread.

Get the XNIO read thread.

public SSLEngine
public SSLSession
public XnioWorker
getWorker()

Implements org.xnio.conduits.Conduit.getWorker.

Get the XNIO worker associated with this conduit.

public XnioIoThread
getWriteThread()

Implements org.xnio.conduits.SinkConduit.getWriteThread.

Get the write thread for this conduit.

private boolean
public boolean
isReadResumed()

Implements org.xnio.conduits.SourceConduit.isReadResumed.

Determine whether read notifications are currently enabled.

public boolean
isReadShutdown()

Implements org.xnio.conduits.SourceConduit.isReadShutdown.

Determine whether reads have been shut down on this conduit.

public boolean
isWriteResumed()

Implements org.xnio.conduits.SinkConduit.isWriteResumed.

Determine whether write notifications are currently enabled.

public boolean
isWriteShutdown()

Implements org.xnio.conduits.SinkConduit.isWriteShutdown.

Determine whether writes have been fully shut down on this conduit.

pack-priv void
pack-priv void
public int
read(ByteBuffer
the buffer to fill with data from the conduit
dst
)

Implements org.xnio.conduits.StreamSourceConduit.read.

Read a sequence of bytes from this conduit to the given buffer.

public long
read(ByteBuffer[]
the buffers to fill with data from the conduit
dsts
,
int
the offset into the buffer array
offs
,
int
the number of buffers to fill
len
)

Implements org.xnio.conduits.StreamSourceConduit.read.

Read a sequence of bytes from this conduit to the given buffers.

public void
resumeReads()

Implements org.xnio.conduits.SourceConduit.resumeReads.

Indicate that the conduit's ReadReadyHandler should be invoked as soon as data can be read without blocking.

private void
resumeReads(boolean wakeup)

public void
resumeWrites()

Implements org.xnio.conduits.SinkConduit.resumeWrites.

Indicate that the conduit's WriteReadyHandler should be invoked as soon as data can be written without blocking.

private void
runReadListener(final boolean resumeInListener)

private void
runTasks()

Execute all the delegated tasks on an executor which allows blocking, the worker executor by default.

private void
public void
setReadReadyHandler(ReadReadyHandler
the filter to receive readiness notifications
handler
)

Implements org.xnio.conduits.SourceConduit.setReadReadyHandler.

Set the handler which should receive readiness notifications.

public void
public void
setWriteReadyHandler(WriteReadyHandler
the filter to receive readiness notifications
handler
)

Implements org.xnio.conduits.SinkConduit.setWriteReadyHandler.

Set the handler which should receive readiness notifications.

public void
public void
suspendReads()

Implements org.xnio.conduits.SourceConduit.suspendReads.

Indicate that calling the conduit's ReadReadyHandler should be suspended.

public void
suspendWrites()

Implements org.xnio.conduits.SinkConduit.suspendWrites.

Indicate that calling the conduit's WriteReadyHandler should be suspended.

public void
terminateReads()

Implements org.xnio.conduits.SourceConduit.terminateReads.

Indicate that no more data will be read from this conduit.

public void
terminateWrites()

Implements org.xnio.conduits.SinkConduit.terminateWrites.

Signal that no more write data is forthcoming.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public long
transferFrom(FileChannel
the file to read from
src
,
long
the position within the file from which the transfer is to begin
position
,
long
the number of bytes to be transferred
count
)

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfer bytes into this conduit from the given file.

public long
transferFrom(StreamSourceChannel
the source to read from
source
,
long
the number of bytes to be transferred
count
,
ByteBuffer
the buffer to copy through.
throughBuffer
)

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfers bytes from the given channel source.

public long
transferTo(long
the position within the file from which the transfer is to begin
position
,
long
the number of bytes to be transferred
count
,
FileChannel
the file to write to
target
)

Implements org.xnio.conduits.StreamSourceConduit.transferTo.

Transfers bytes into the given file from this channel.

public long
transferTo(long
the number of bytes to be transferred
count
,
ByteBuffer
the buffer to copy through.
throughBuffer
,
StreamSinkChannel
the destination to write to
target
)

Implements org.xnio.conduits.StreamSourceConduit.transferTo.

Transfers bytes into the given channel target.

public void
truncateWrites()

Implements org.xnio.conduits.SinkConduit.truncateWrites.

Terminate writes and discard any outstanding write data.

public void
wakeupReads()

Implements org.xnio.conduits.SourceConduit.wakeupReads.

Indicate that the conduit's ReadReadyHandler should be invoked immediately, and then again as soon as data can be read without blocking.

public void
wakeupWrites()

Implements org.xnio.conduits.SinkConduit.wakeupWrites.

Indicate that the conduit's WriteReadyHandler should be invoked immediately, and then again as soon as data can be written without blocking.

private SSLEngineResult
wrapAndFlip(ByteBuffer[] userBuffers, int off, int len)

public int
write(ByteBuffer
the buffer containing data to write
src
)

Implements org.xnio.conduits.StreamSinkConduit.write.

Writes a sequence of bytes to this conduit from the given buffer.

public long
write(ByteBuffer[]
the buffers containing data to write
srcs
,
int
the offset into the buffer array
offs
,
int
the number of buffers to write
len
)

Implements org.xnio.conduits.StreamSinkConduit.write.

Writes a sequence of bytes to this conduit from the given buffers.

public int
writeFinal(ByteBuffer
The data to write
src
)

Implements org.xnio.conduits.StreamSinkConduit.writeFinal.

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer).

public long
writeFinal(ByteBuffer[]
The buffers from which bytes are to be retrieved
srcs
,
int
The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length
offset
,
int
The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset
length
)

Implements org.xnio.conduits.StreamSinkConduit.writeFinal.

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer[], int, int).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait