Module bus.http

Class ConnectionSuite

java.lang.Object
org.miaixz.bus.http.accord.ConnectionSuite

public final class ConnectionSuite extends Object
Specifies the configuration for a socket connection over which HTTP is transported. For https: URLs, this includes the TLS versions and cipher suites to use when negotiating a secure connection.

Only TLS versions configured in the connection specification that are also enabled in the SSL socket will be used. For example, if TLS 1.3 is not enabled in the SSL socket, it will not be used even if it appears in the connection specification. The same policy applies to cipher suites.

Use ConnectionSuite.Builder.allEnabledTlsVersions() and ConnectionSuite.Builder.allEnabledCipherSuites() to defer all feature selection to the underlying SSL socket.

Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • CLEARTEXT

      public static final ConnectionSuite CLEARTEXT
      An unencrypted, unauthenticated connection for http: URLs.
    • MODERN_TLS

      public static final ConnectionSuite MODERN_TLS
      A TLS connection with extensions like SNI and ALPN available.
  • Method Details

    • isTls

      public boolean isTls()
      Returns true if this connection suite is for TLS connections.
      Returns:
      true if this is a TLS connection suite.
    • cipherSuites

      public List<CipherSuite> cipherSuites()
      Returns the cipher suites to use for the connection. If all enabled cipher suites of the SSL socket should be used, this returns null.
      Returns:
      A list of cipher suites, or null.
    • tlsVersions

      public List<org.miaixz.bus.core.net.tls.TlsVersion> tlsVersions()
      Returns the TLS versions to use when negotiating a connection. If all enabled TLS versions of the SSL socket should be used, this returns null.
      Returns:
      A list of TLS versions, or null.
    • supportsTlsExtensions

      public boolean supportsTlsExtensions()
      Returns true if TLS extensions like Server Name Indication (SNI) and Application-Layer Protocol Negotiation (ALPN) should be used.
      Returns:
      true if TLS extensions are supported.
    • apply

      public void apply(SSLSocket sslSocket, boolean isFallback)
      Applies this specification to the sslSocket.
      Parameters:
      sslSocket - The SSL socket to configure.
      isFallback - Whether this is a fallback connection.
    • isCompatible

      public boolean isCompatible(SSLSocket socket)
      Returns true if the currently configured socket supports this connection specification. For a socket to be compatible, the enabled cipher suites and protocols must intersect. For cipher suites, at least one of the required cipher suites must match an enabled cipher suite on the socket. If no cipher suites are required, the socket must have at least one enabled cipher suite. For protocols, at least one of the required protocols must match an enabled protocol on the socket.
      Parameters:
      socket - The SSL socket to check.
      Returns:
      true if the socket is compatible.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object