Class TLSWrapper


  • public class TLSWrapper
    extends Object
    Creates and initializes the SSLContext instance to use to encrypt the plain connection. This class is also responsible for encoding and decoding the encrypted data and place it into the corresponding the ByteBuffer.
    Author:
    Artur Hefczyc, Hao Chen
    • Method Detail

      • getNetBuffSize

        public int getNetBuffSize()
      • getAppBuffSize

        public int getAppBuffSize()
      • isEngineClosed

        public boolean isEngineClosed()
        Returns whether unwrap(ByteBuffer, ByteBuffer) will accept any more inbound data messages and whether wrap(ByteBuffer, ByteBuffer) will produce any more outbound data messages.
        Returns:
        true if the TLSHandler will not consume anymore network data and will not produce any anymore network data.
      • enableLogging

        public void enableLogging​(boolean logging)
      • unwrap

        public ByteBuffer unwrap​(ByteBuffer net,
                                 ByteBuffer app)
                          throws SSLException
        Attempts to decode TLS network data into a subsequence of plaintext application data buffers. Depending on the state of the TLSWrapper, this method may consume network data without producing any application data (for example, it may consume handshake data.) If this TLSWrapper has not yet started its initial handshake, this method will automatically start the handshake.
        Parameters:
        net - a ByteBuffer containing inbound network data
        app - a ByteBuffer to hold inbound application data
        Returns:
        a ByteBuffer containing inbound application data
        Throws:
        SSLException - A problem was encountered while processing the data that caused the TLSHandler to abort.
      • wrap

        public void wrap​(ByteBuffer app,
                         ByteBuffer net)
                  throws SSLException
        Attempts to encode a buffer of plaintext application data into TLS network data. Depending on the state of the TLSWrapper, this method may produce network data without consuming any application data (for example, it may generate handshake data). If this TLSWrapper has not yet started its initial handshake, this method will automatically start the handshake.
        Parameters:
        app - a ByteBuffer containing outbound application data
        net - a ByteBuffer to hold outbound network data
        Throws:
        SSLException - A problem was encountered while processing the data that caused the TLSWrapper to abort.
      • close

        public void close()
                   throws SSLException
        Signals that no more outbound application data will be sent on this TLSHandler.
        Throws:
        SSLException - never
      • getStatus

        public TLSStatus getStatus()
        Returns the current status for this TLSHandler.
        Returns:
        the current TLSStatus
      • getTlsEngine

        protected SSLEngine getTlsEngine()