Class SSLEngineResult

java.lang.Object
javax.net.ssl.SSLEngineResult

public class SSLEngineResult extends Object
An encapsulation of the result state produced by SSLEngine I/O calls.

A SSLEngine provides a means for establishing secure communication sessions between two peers. SSLEngine operations typically consume bytes from an input buffer and produce bytes in an output buffer. This class provides operational result values describing the state of the SSLEngine, including indications of what operations are needed to finish an ongoing handshake. Lastly, it reports the number of bytes consumed and produced as a result of this operation.

Since:
1.5
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    An SSLEngineResult enum describing the current handshaking state of this SSLEngine.
    static enum 
    An SSLEngineResult enum describing the overall result of the SSLEngine operation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SSLEngineResult(SSLEngineResult.Status status, SSLEngineResult.HandshakeStatus handshakeStatus, int bytesConsumed, int bytesProduced)
    Initializes a new instance of this class.
    SSLEngineResult(SSLEngineResult.Status status, SSLEngineResult.HandshakeStatus handshakeStatus, int bytesConsumed, int bytesProduced, long sequenceNumber)
    Initializes a new instance of this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Returns the number of bytes consumed from the input buffer.
    final int
    Returns the number of bytes written to the output buffer.
    Gets the handshake status of this SSLEngine operation.
    Gets the return value of this SSLEngine operation.
    final long
    Returns the sequence number of the produced or consumed SSL/TLS/DTLS record (optional operation).
    Returns a String representation of this object.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
    boolean
    Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    int
    Answers an integer hash code for the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • Constructor Details

    • SSLEngineResult

      public SSLEngineResult(SSLEngineResult.Status status, SSLEngineResult.HandshakeStatus handshakeStatus, int bytesConsumed, int bytesProduced)
      Initializes a new instance of this class.
      Parameters:
      status - the return value of the operation.
      handshakeStatus - the current handshaking status.
      bytesConsumed - the number of bytes consumed from the source ByteBuffer
      bytesProduced - the number of bytes placed into the destination ByteBuffer
      Throws:
      IllegalArgumentException - if the status or handshakeStatus arguments are null, or if bytesConsumed or bytesProduced is negative.
    • SSLEngineResult

      public SSLEngineResult(SSLEngineResult.Status status, SSLEngineResult.HandshakeStatus handshakeStatus, int bytesConsumed, int bytesProduced, long sequenceNumber)
      Initializes a new instance of this class.
      Parameters:
      status - the return value of the operation.
      handshakeStatus - the current handshaking status.
      bytesConsumed - the number of bytes consumed from the source ByteBuffer
      bytesProduced - the number of bytes placed into the destination ByteBuffer
      sequenceNumber - the sequence number (unsigned long) of the produced or consumed SSL/TLS/DTLS record, or -1L if no record produced or consumed
      Throws:
      IllegalArgumentException - if the status or handshakeStatus arguments are null, or if bytesConsumed or bytesProduced is negative
      Since:
      9
  • Method Details

    • getStatus

      public final SSLEngineResult.Status getStatus()
      Gets the return value of this SSLEngine operation.
      Returns:
      the return value
    • getHandshakeStatus

      public final SSLEngineResult.HandshakeStatus getHandshakeStatus()
      Gets the handshake status of this SSLEngine operation.
      Returns:
      the handshake status
    • bytesConsumed

      public final int bytesConsumed()
      Returns the number of bytes consumed from the input buffer.
      Returns:
      the number of bytes consumed.
    • bytesProduced

      public final int bytesProduced()
      Returns the number of bytes written to the output buffer.
      Returns:
      the number of bytes produced
    • sequenceNumber

      public final long sequenceNumber()
      Returns the sequence number of the produced or consumed SSL/TLS/DTLS record (optional operation).
      API Note:
      Note that sequence number is an unsigned long and cannot exceed -1L. It is desired to use the unsigned long comparing mode for comparison of unsigned long values (see also Long.compareUnsigned()).

      For DTLS protocols, the first 16 bits of the sequence number is a counter value (epoch) that is incremented on every cipher state change. The remaining 48 bits on the right side of the sequence number represents the sequence of the record, which is maintained separately for each epoch.

      Implementation Note:
      It is recommended that providers should never allow the sequence number incremented to -1L. If the sequence number is close to wrapping, renegotiate should be requested, otherwise the connection should be closed immediately. This should be carried on automatically by the underlying implementation.
      Returns:
      the sequence number of the produced or consumed SSL/TLS/DTLS record; or -1L if no record is produced or consumed, or this operation is not supported by the underlying provider
      Since:
      9
      See Also:
    • toString

      public String toString()
      Returns a String representation of this object.
      Overrides:
      toString in class Object
      Returns:
      String a printable representation for the receiver.