Class SslFilter


  • class SslFilter
    extends Filter<java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer>
    • Field Detail

      • emptyBuffer

        private static final java.nio.ByteBuffer emptyBuffer
      • applicationInputBuffer

        private final java.nio.ByteBuffer applicationInputBuffer
      • networkOutputBuffer

        private final java.nio.ByteBuffer networkOutputBuffer
      • sslEngine

        private final javax.net.ssl.SSLEngine sslEngine
      • customHostnameVerifier

        private final javax.net.ssl.HostnameVerifier customHostnameVerifier
      • serverHost

        private final java.lang.String serverHost
      • pendingApplicationWrite

        private java.lang.Runnable pendingApplicationWrite
    • Constructor Detail

      • SslFilter

        SslFilter​(Filter<java.nio.ByteBuffer,​java.nio.ByteBuffer,​?,​?> downstreamFilter,
                  javax.net.ssl.SSLContext sslContext,
                  java.lang.String serverHost,
                  javax.net.ssl.HostnameVerifier customHostnameVerifier)
        SSL Filter constructor, takes upstream filter as a parameter.
        Parameters:
        downstreamFilter - a filter that is positioned under the SSL filter.
        sslContext - configuration of SSL engine.
        serverHost - 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.
        customHostnameVerifier - hostname verifier that will be used instead of the default one.
    • Method Detail

      • write

        void write​(java.nio.ByteBuffer applicationData,
                   CompletionHandler<java.nio.ByteBuffer> completionHandler)
        Description copied from class: Filter
        Perform write operation for this filter and invokes write method on the next filter in the filter chain.
        Overrides:
        write in class Filter<java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer>
        Parameters:
        applicationData - on which write operation is performed.
        completionHandler - will be invoked when the write operation is completed or has failed.
      • handleWrite

        private void handleWrite​(java.nio.ByteBuffer applicationData,
                                 CompletionHandler<java.nio.ByteBuffer> completionHandler)
      • handlePostWrite

        private void handlePostWrite​(java.nio.ByteBuffer applicationData,
                                     CompletionHandler<java.nio.ByteBuffer> completionHandler)
      • storePendingApplicationWrite

        private void storePendingApplicationWrite​(java.nio.ByteBuffer applicationData,
                                                  CompletionHandler<java.nio.ByteBuffer> completionHandler)
      • close

        void close()
        Description copied from class: Filter
        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.

        Overrides:
        close in class Filter<java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer>
      • processRead

        boolean processRead​(java.nio.ByteBuffer networkData)
        Description copied from class: Filter
        Overrides:
        processRead in class Filter<java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer>
        Parameters:
        networkData - read data.
        Returns:
        true if the data should be sent to processing to upper filter in the chain, false otherwise.
      • handleRead

        private boolean handleRead​(java.nio.ByteBuffer networkData)
      • doHandshakeStep

        private boolean doHandshakeStep​(java.nio.ByteBuffer networkData)
      • handleHandshakeFinished

        private void handleHandshakeFinished()
      • handleSslError

        private void handleSslError​(java.lang.Throwable t)
      • startSsl

        void startSsl()
        Description copied from class: Filter
        Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.
        Overrides:
        startSsl in class Filter<java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer,​java.nio.ByteBuffer>
      • rehandshake

        void rehandshake()
        Only for test.
      • getDebugState

        private java.lang.String getDebugState()
        Returns a printed current state of the SslFilter that could be helpful for troubleshooting.