APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.net.http

pack-priv abstract Class AbstractAsyncSSLConnection

extends HttpConnection
Class Inheritance
Known Direct Subclasses
jdk.internal.net.http.AsyncSSLConnection, jdk.internal.net.http.AsyncSSLTunnelConnection
Imports
java.net.InetSocketAddress, java.net.http.HttpClient, java.util.Arrays, .ArrayDeque, .List, java.util.concurrent.CompletableFuture, javax.net.ssl.SNIHostName, .SNIServerName, .SSLContext, .SSLEngine, .SSLParameters, jdk.internal.net.http.common.Alpns, .SSLTube, .Log, .Utils, sun.net.util.IPAddressUtil

Asynchronous version of SSLConnection. There are two concrete implementations of this class: AsyncSSLConnection and AsyncSSLTunnelConnection. This abstraction is useful when downgrading from HTTP/2 to HTTP/1.1 over an SSL connection. See ExchangeImpl::get in the case where an ALPNException is thrown.

Note

An AsyncSSLConnection wraps a PlainHttpConnection, while an AsyncSSLTunnelConnection wraps a PlainTunnelingConnection. If both these wrapped classes where made to inherit from a common abstraction then it might be possible to merge AsyncSSLConnection and AsyncSSLTunnelConnection back into a single class - and simply use different factory methods to create different wrappees, but this is left up for further cleanup.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private static final boolean
protected final SSLEngine
private final List<SNIServerName>
protected final SSLParameters
Inherited from jdk.internal.net.http.HttpConnection:
addressCOMPARE_BY_IDdbgTagdebugDEBUG_LOGGER

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static boolean
contains(String[] rr, String target)

private static SSLEngine
createEngine(SSLContext context, String peerHost, int port, SSLParameters sslParameters)

private static SSLParameters

Returns:

the SSLParameters to be set on the SSLEngine used by this connection.
createSSLParameters
(HttpClientImpl
the HttpClient
client
,
List<SNIServerName>
the SNIServerName(s)
sniServerNames
,
String[]
the application layer protocols
alpn
)

Returns the SSLParameters to be used by the SSLEngine for this connection.

private static List<SNIServerName>

Returns:

a list of SNIServerNames to be used by the SSLEngine of this connection.
formSNIServerNames
(final AbstractAsyncSSLConnection.ServerName
the ServerName, typically computed based on the request URI
serverName
,
final HttpClientImpl
the HttpClient
client
)

Returns a list of SNIServerNames that are expected to be used to configure the SSLEngine used by this connection.

pack-priv final CompletableFuture<String>
pack-priv abstract SSLTube
getConnectionFlow()

Implements abstract jdk.internal.net.http.HttpConnection.getConnectionFlow.

Returns the underlying connection flow, if applicable.

pack-priv final SSLEngine
private static AbstractAsyncSSLConnection.ServerName
getServerName(final Origin originServer)

Analyse the given origin server and determine if the origin server's host is a literal or not, returning the server's address in String form.

public final List<SNIServerName>
getSNIServerNames()

Overrides jdk.internal.net.http.HttpConnection.getSNIServerNames.

Returns an unmodifiable list of SNIServerNames that were used during TLS handshake of this connection.

pack-priv final boolean
isSecure()

Implements abstract jdk.internal.net.http.HttpConnection.isSecure.

Tells whether, or not, this connection is secure ( over SSL )

Inherited from jdk.internal.net.http.HttpConnection:
addressaddTrailingOperationcacheKeychannelcheckOpenclientcloseclosecloseOrReturnToCacheconnectAsyncconnectedcontextRestricteddbgStringfinishConnectgetConnectiongetOriginServerheaderFilterisFlowFinishedisOpenisProxiedisTunnellabelnewConnectionIdproxypublishertoString

Field Detail

disableHostnameVerificationback to summary
private static final boolean disableHostnameVerification
engineback to summary
protected final SSLEngine engine
sniServerNamesback to summary
private final List<SNIServerName> sniServerNames
sslParametersback to summary
protected final SSLParameters sslParameters

Constructor Detail

AbstractAsyncSSLConnectionback to summary
pack-priv AbstractAsyncSSLConnection(Origin originServer, InetSocketAddress addr, HttpClientImpl client, String[] alpn, String label)

Method Detail

containsback to summary
private static boolean contains(String[] rr, String target)
createEngineback to summary
private static SSLEngine createEngine(SSLContext context, String peerHost, int port, SSLParameters sslParameters)
createSSLParametersback to summary
private static SSLParameters createSSLParameters(HttpClientImpl client, List<SNIServerName> sniServerNames, String[] alpn)

Returns the SSLParameters to be used by the SSLEngine for this connection.

The returned SSLParameters will have its SNIServerNames set to the given sniServerNames. If alpn is non-null then the returned SSLParameters will have its application layer protocols set to this value. All other parameters in the returned SSLParameters will be copied over from HttpClient#sslParameters() of the given client.

Parameters
client:HttpClientImpl

the HttpClient

sniServerNames:List<SNIServerName>

the SNIServerName(s)

alpn:String[]

the application layer protocols

Returns:SSLParameters

the SSLParameters to be set on the SSLEngine used by this connection.

formSNIServerNamesback to summary
private static List<SNIServerName> formSNIServerNames(final AbstractAsyncSSLConnection.ServerName serverName, final HttpClientImpl client)

Returns a list of SNIServerNames that are expected to be used to configure the SSLEngine used by this connection.

The given serverName is given preference, and if it is not null and is not an IP address literal, then the returned list will contain only one SNIServerName formed out of the serverName. If serverName is null or is an IP address literal then the SNIServerName(s) configured through HttpClient#sslParameters() will be returned. If none have been configured, then an empty list is returned.

Parameters
serverName:AbstractAsyncSSLConnection.ServerName

the ServerName, typically computed based on the request URI

client:HttpClientImpl

the HttpClient

Returns:List<SNIServerName>

a list of SNIServerNames to be used by the SSLEngine of this connection.

getALPNback to summary
pack-priv final CompletableFuture<String> getALPN()
getConnectionFlowback to summary
pack-priv abstract SSLTube getConnectionFlow()

Implements abstract jdk.internal.net.http.HttpConnection.getConnectionFlow.

Doc from jdk.internal.net.http.HttpConnection.getConnectionFlow.

Returns the underlying connection flow, if applicable.

getEngineback to summary
pack-priv final SSLEngine getEngine()
getServerNameback to summary
private static AbstractAsyncSSLConnection.ServerName getServerName(final Origin originServer)

Analyse the given origin server and determine if the origin server's host is a literal or not, returning the server's address in String form.

getSNIServerNamesback to summary
public final List<SNIServerName> getSNIServerNames()

Overrides jdk.internal.net.http.HttpConnection.getSNIServerNames.

Doc from jdk.internal.net.http.HttpConnection.getSNIServerNames.

Returns an unmodifiable list of SNIServerNames that were used during TLS handshake of this connection. If this connection doesn't represent a TLS based connection or if no SNI server names were used during the handshake, then this method returns an empty list.

Annotations
@Override
isSecureback to summary
pack-priv final boolean isSecure()

Implements abstract jdk.internal.net.http.HttpConnection.isSecure.

Doc from jdk.internal.net.http.HttpConnection.isSecure.

Tells whether, or not, this connection is secure ( over SSL )

Annotations
@Override
jdk.internal.net.http back to summary

private final Record AbstractAsyncSSLConnection.ServerName

extends Record
Class Inheritance
Record Components
name:String 
isLiteral:boolean 

Field Summary

Modifier and TypeField and Description
private final boolean
isLiteral

Record Component accessed by isLiteral().

private final String
name

Record Component accessed by name().

Constructor Summary

AccessConstructor and Description
private
ServerName(String name, boolean isLiteral)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
isLiteral()

Record Component getter of isLiteral.

public String
name()

Record Component getter of name.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

isLiteralback to summary
private final boolean isLiteral

Record Component accessed by isLiteral().

nameback to summary
private final String name

Record Component accessed by name().

Constructor Detail

ServerNameback to summary
private ServerName(String name, boolean isLiteral)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

isLiteralback to summary
public boolean isLiteral()

Record Component getter of isLiteral.

nameback to summary
public String name()

Record Component getter of name.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.