Top Description Inners Fields Constructors Methods
org.glassfish.tyrus.container.jdk.client

pack-priv Class SslFilter

extends Filter
Class Inheritance
Imports
java.nio.Buffer, .ByteBuffer, java.util.LinkedList, .Queue, javax.net.ssl.HostnameVerifier, .SSLContext, .SSLEngine, .SSLEngineResult, .SSLException, .SSLParameters, org.glassfish.tyrus.client.SslEngineConfigurator, org.glassfish.tyrus.core.Utils, org.glassfish.tyrus.spi.CompletionHandler

A filter that adds SSL support to the transport.

write(java.nio.ByteBuffer, org.glassfish.tyrus.spi.CompletionHandler) and onRead(java.nio.ByteBuffer) calls are passed through until startSsl() method is called, after which SSL handshake is started. When SSL handshake is in progress, no data passed in write(java.nio.ByteBuffer, org.glassfish.tyrus.spi.CompletionHandler) are permitted until SSL handshake completes. After SSL handshake has completed, all data passed in write method will be encrypted and data passed in onRead(java.nio.ByteBuffer) method will be decrypted.

Author
Petr Janouch

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
private final HostnameVerifier
private static final ByteBuffer
private final ByteBuffer
private Runnable
private final String
private final SSLEngine
private volatile SslFilter.State
private static final String
private volatile boolean
private final SslFilter.WriteQueue
Inherited from org.glassfish.tyrus.container.jdk.client.Filter:
downstreamFilterupstreamFilter

Constructor Summary

AccessConstructor and Description
pack-priv
SslFilter(Filter
a filter that is positioned under the SSL filter.
downstreamFilter
,
SslEngineConfigurator
configuration of SSL engine.
sslEngineConfigurator
,
String
server host (hostname or IP address), which will be used to verify authenticity of the server (the provided host will be compared against the host in the certificate provided by the server). IP address and hostname cannot be used interchangeably - if a certificate contains hostname and an IP address of the server is provided here, the verification will fail.
serverHost
)

SSL Filter constructor, takes upstream filter as a parameter.

pack-priv
SslFilter(Filter
a filter that is positioned under the SSL filter.
downstreamFilter
,
SSLContext
an SSLContent, usually from @code{ClientEndpointConfig#getSSLContext}
sslContext
,
String
server host (hostname or IP address), which will be used to verify authenticity of the server (the provided host will be compared against the host in the certificate provided by the server). IP address and hostname cannot be used interchangeably - if a certificate contains hostname and an IP address of the server is provided here, the verification will fail.
serverHost
)

SSL Filter constructor, takes upstream filter as a parameter.

pack-priv
SslFilter(Filter
a filter that is positioned under the SSL filter.
downstreamFilter
,
SslEngineConfigurator sslEngineConfigurator)

SSL Filter constructor, takes upstream filter as a parameter.

Method Summary

Modifier and TypeMethod and Description
pack-priv synchronized void
close()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.close.

Close the filter, invokes close operation on the next filter in the filter chain.

private boolean
private String
getDebugState()

Returns a printed current state of the SslFilter that could be helpful for troubleshooting.

private void
private synchronized void
handlePostWrite(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler)

private boolean
handleRead(ByteBuffer networkData)

private void
private void
handleWrite(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler)

private boolean
pack-priv boolean
pack-priv void
rehandshake()

Only for test.

private void
pack-priv void
startSsl()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.startSsl.

Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.

private void
storePendingApplicationWrite(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler)

pack-priv synchronized void
write(final ByteBuffer
on which write operation is performed.
applicationData
,
final CompletionHandler<ByteBuffer>
will be invoked when the write operation is completed or has failed.
completionHandler
)

Overrides org.glassfish.tyrus.container.jdk.client.Filter.write.

Perform write operation for this filter and invokes write method on the next filter in the filter chain.

Inherited from org.glassfish.tyrus.container.jdk.client.Filter:
connecthandleConnectonConnectonConnectionClosedonErroronReadonSslHandshakeCompletedprocessConnectprocessConnectionClosedprocessErrorprocessSslHandshakeCompleted

Field Detail

applicationInputBufferback to summary
private final ByteBuffer applicationInputBuffer
customHostnameVerifierback to summary
private final HostnameVerifier customHostnameVerifier
emptyBufferback to summary
private static final ByteBuffer emptyBuffer
networkOutputBufferback to summary
private final ByteBuffer networkOutputBuffer
pendingApplicationWriteback to summary
private Runnable pendingApplicationWrite
serverHostback to summary
private final String serverHost
sslEngineback to summary
private final SSLEngine sslEngine
stateback to summary
private volatile SslFilter.State state
TLSV13back to summary
private static final String TLSV13
tlsv13back to summary
private volatile boolean tlsv13
writeQueueback to summary
private final SslFilter.WriteQueue writeQueue

Constructor Detail

SslFilterback to summary
pack-priv SslFilter(Filter downstreamFilter, SslEngineConfigurator sslEngineConfigurator, String serverHost)

SSL Filter constructor, takes upstream filter as a parameter.

Parameters
downstreamFilter:Filter

a filter that is positioned under the SSL filter.

sslEngineConfigurator:SslEngineConfigurator

configuration of SSL engine.

serverHost:String

server host (hostname or IP address), which will be used to verify authenticity of the server (the provided host will be compared against the host in the certificate provided by the server). IP address and hostname cannot be used interchangeably - if a certificate contains hostname and an IP address of the server is provided here, the verification will fail.

SslFilterback to summary
pack-priv SslFilter(Filter downstreamFilter, SSLContext sslContext, String serverHost)

SSL Filter constructor, takes upstream filter as a parameter.

Parameters
downstreamFilter:Filter

a filter that is positioned under the SSL filter.

sslContext:SSLContext

an SSLContent, usually from @code{ClientEndpointConfig#getSSLContext}

serverHost:String

server host (hostname or IP address), which will be used to verify authenticity of the server (the provided host will be compared against the host in the certificate provided by the server). IP address and hostname cannot be used interchangeably - if a certificate contains hostname and an IP address of the server is provided here, the verification will fail.

SslFilterback to summary
pack-priv SslFilter(Filter downstreamFilter, SslEngineConfigurator sslEngineConfigurator)

SSL Filter constructor, takes upstream filter as a parameter.

Parameters
downstreamFilter:Filter

a filter that is positioned under the SSL filter.

Method Detail

closeback to summary
pack-priv synchronized void close()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.close.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.close.

Close the filter, invokes close operation on the next filter in the filter chain.

The filter is expected to clean up any allocated resources and pass the invocation to downstream filter.

Annotations
@Override
doHandshakeStepback to summary
private boolean doHandshakeStep(ByteBuffer networkData)
getDebugStateback to summary
private String getDebugState()

Returns a printed current state of the SslFilter that could be helpful for troubleshooting.

handleHandshakeFinishedback to summary
private void handleHandshakeFinished()
handlePostWriteback to summary
private synchronized void handlePostWrite(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler)
handleReadback to summary
private boolean handleRead(ByteBuffer networkData)
handleSslErrorback to summary
private void handleSslError(Throwable t)
handleWriteback to summary
private void handleWrite(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler)
isHandshakingback to summary
private boolean isHandshaking(SSLEngineResult.HandshakeStatus hs)
processReadback to summary
pack-priv boolean processRead(ByteBuffer networkData)

Overrides org.glassfish.tyrus.container.jdk.client.Filter.processRead.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.processRead.

Process onRead(ByteBuffer).

Parameters
networkData:ByteBuffer

read data.

Returns:boolean

true if the data should be sent to processing to upper filter in the chain, false otherwise.

Annotations
@Override
rehandshakeback to summary
pack-priv void rehandshake()

Only for test.

setStateback to summary
private void setState(SslFilter.State state)
startSslback to summary
pack-priv void startSsl()

Overrides org.glassfish.tyrus.container.jdk.client.Filter.startSsl.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.startSsl.

Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.

Annotations
@Override
storePendingApplicationWriteback to summary
private void storePendingApplicationWrite(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler)
writeback to summary
pack-priv synchronized void write(final ByteBuffer applicationData, final CompletionHandler<ByteBuffer> completionHandler)

Overrides org.glassfish.tyrus.container.jdk.client.Filter.write.

Doc from org.glassfish.tyrus.container.jdk.client.Filter.write.

Perform write operation for this filter and invokes write method on the next filter in the filter chain.

Parameters
applicationData:ByteBuffer

on which write operation is performed.

completionHandler:CompletionHandler<ByteBuffer>

will be invoked when the write operation is completed or has failed.

Annotations
@Override
org.glassfish.tyrus.container.jdk.client back to summary

private Class SslFilter.LazyBuffer

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.tyrus.container.jdk.client.SslFilter.LazyBuffer

Field Summary

Modifier and TypeField and Description
private ByteBuffer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv ByteBuffer
get()

pack-priv boolean
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private ByteBuffer buffer

Constructor Detail

LazyBufferback to summary
private LazyBuffer()

Method Detail

appendback to summary
pack-priv void append(ByteBuffer b)
getback to summary
pack-priv ByteBuffer get()
isAllocatedback to summary
pack-priv boolean isAllocated()
resizeback to summary
pack-priv void resize()
org.glassfish.tyrus.container.jdk.client back to summary

private final Enum SslFilter.State

extends Enum<SslFilter.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final SslFilter.State
public static final SslFilter.State
public static final SslFilter.State
public static final SslFilter.State
public static final SslFilter.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SslFilter.State
public static SslFilter.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLOSEDback to summary
public static final SslFilter.State CLOSED
DATAback to summary
public static final SslFilter.State DATA
HANDSHAKINGback to summary
public static final SslFilter.State HANDSHAKING
NOT_STARTEDback to summary
public static final SslFilter.State NOT_STARTED
REHANDSHAKINGback to summary
public static final SslFilter.State REHANDSHAKING

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static SslFilter.State valueOf(String name)
valuesback to summary
public static SslFilter.State[] values()
org.glassfish.tyrus.container.jdk.client back to summary

private Class SslFilter.WriteQueue

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.tyrus.container.jdk.client.SslFilter.WriteQueue

Field Summary

Modifier and TypeField and Description
private final Queue<Runnable>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv void
write(final ByteBuffer data, final CompletionHandler<ByteBuffer> completionHandler)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

pendingWritesback to summary
private final Queue<Runnable> pendingWrites

Constructor Detail

WriteQueueback to summary
private WriteQueue()

Method Detail

onWriteCompletedback to summary
private void onWriteCompleted()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
writeback to summary
pack-priv void write(final ByteBuffer data, final CompletionHandler<ByteBuffer> completionHandler)