Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/net/ssl/SSLSocket.java
38918 views
/*1* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/242526package javax.net.ssl;2728import java.io.IOException;29import java.net.*;30import java.util.List;31import java.util.function.BiFunction;3233/**34* This class extends <code>Socket</code>s and provides secure35* socket using protocols such as the "Secure36* Sockets Layer" (SSL) or IETF "Transport Layer Security" (TLS) protocols.37* <P>38* Such sockets are normal stream sockets, but they39* add a layer of security protections over the underlying network transport40* protocol, such as TCP. Those protections include: <UL>41*42* <LI> <em>Integrity Protection</em>. SSL protects against43* modification of messages by an active wiretapper.44*45* <LI> <em>Authentication</em>. In most modes, SSL provides46* peer authentication. Servers are usually authenticated,47* and clients may be authenticated as requested by servers.48*49* <LI> <em>Confidentiality (Privacy Protection)</em>. In most50* modes, SSL encrypts data being sent between client and server.51* This protects the confidentiality of data, so that passive52* wiretappers won't see sensitive data such as financial53* information or personal information of many kinds.54*55* </UL>56*57* <P>These kinds of protection are specified by a "cipher suite", which58* is a combination of cryptographic algorithms used by a given SSL connection.59* During the negotiation process, the two endpoints must agree on60* a ciphersuite that is available in both environments.61* If there is no such suite in common, no SSL connection can62* be established, and no data can be exchanged.63*64* <P> The cipher suite used is established by a negotiation process65* called "handshaking". The goal of this66* process is to create or rejoin a "session", which may protect many67* connections over time. After handshaking has completed, you can access68* session attributes by using the <em>getSession</em> method.69* The initial handshake on this connection can be initiated in70* one of three ways: <UL>71*72* <LI> calling <code>startHandshake</code> which explicitly73* begins handshakes, or74* <LI> any attempt to read or write application data on75* this socket causes an implicit handshake, or76* <LI> a call to <code>getSession</code> tries to set up a session77* if there is no currently valid session, and78* an implicit handshake is done.79* </UL>80*81* <P>If handshaking fails for any reason, the <code>SSLSocket</code>82* is closed, and no further communications can be done.83*84* <P>There are two groups of cipher suites which you will need to know85* about when managing cipher suites: <UL>86*87* <LI> <em>Supported</em> cipher suites: all the suites which are88* supported by the SSL implementation. This list is reported89* using <em>getSupportedCipherSuites</em>.90*91* <LI> <em>Enabled</em> cipher suites, which may be fewer92* than the full set of supported suites. This group is93* set using the <em>setEnabledCipherSuites</em> method, and94* queried using the <em>getEnabledCipherSuites</em> method.95* Initially, a default set of cipher suites will be enabled on96* a new socket that represents the minimum suggested configuration.97*98* </UL>99*100* <P> Implementation defaults require that only cipher101* suites which authenticate servers and provide confidentiality102* be enabled by default.103* Only if both sides explicitly agree to unauthenticated and/or104* non-private (unencrypted) communications will such a ciphersuite be105* selected.106*107* <P>When <code>SSLSocket</code>s are first created, no handshaking108* is done so that applications may first set their communication109* preferences: what cipher suites to use, whether the socket should be110* in client or server mode, etc.111* However, security is always provided by the time that application data112* is sent over the connection.113*114* <P> You may register to receive event notification of handshake115* completion. This involves116* the use of two additional classes. <em>HandshakeCompletedEvent</em>117* objects are passed to <em>HandshakeCompletedListener</em> instances,118* which are registered by users of this API.119*120* <code>SSLSocket</code>s are created by <code>SSLSocketFactory</code>s,121* or by <code>accept</code>ing a connection from a122* <code>SSLServerSocket</code>.123*124* <P>A SSL socket must choose to operate in the client or server mode.125* This will determine who begins the handshaking process, as well126* as which messages should be sent by each party. Each127* connection must have one client and one server, or handshaking128* will not progress properly. Once the initial handshaking has started, a129* socket can not switch between client and server modes, even when130* performing renegotiations.131*132* @see java.net.Socket133* @see SSLServerSocket134* @see SSLSocketFactory135*136* @since 1.4137* @author David Brownell138*/139public abstract class SSLSocket extends Socket140{141/**142* Used only by subclasses.143* Constructs an uninitialized, unconnected TCP socket.144*/145protected SSLSocket()146{ super(); }147148149/**150* Used only by subclasses.151* Constructs a TCP connection to a named host at a specified port.152* This acts as the SSL client.153* <p>154* If there is a security manager, its <code>checkConnect</code>155* method is called with the host address and <code>port</code>156* as its arguments. This could result in a SecurityException.157*158* @param host name of the host with which to connect, or159* <code>null</code> for the loopback address.160* @param port number of the server's port161* @throws IOException if an I/O error occurs when creating the socket162* @throws SecurityException if a security manager exists and its163* <code>checkConnect</code> method doesn't allow the operation.164* @throws UnknownHostException if the host is not known165* @throws IllegalArgumentException if the port parameter is outside the166* specified range of valid port values, which is between 0 and167* 65535, inclusive.168* @see SecurityManager#checkConnect169*/170protected SSLSocket(String host, int port)171throws IOException, UnknownHostException172{ super(host, port); }173174175/**176* Used only by subclasses.177* Constructs a TCP connection to a server at a specified address178* and port. This acts as the SSL client.179* <p>180* If there is a security manager, its <code>checkConnect</code>181* method is called with the host address and <code>port</code>182* as its arguments. This could result in a SecurityException.183*184* @param address the server's host185* @param port its port186* @throws IOException if an I/O error occurs when creating the socket187* @throws SecurityException if a security manager exists and its188* <code>checkConnect</code> method doesn't allow the operation.189* @throws IllegalArgumentException if the port parameter is outside the190* specified range of valid port values, which is between 0 and191* 65535, inclusive.192* @throws NullPointerException if <code>address</code> is null.193* @see SecurityManager#checkConnect194*/195protected SSLSocket(InetAddress address, int port)196throws IOException197{ super(address, port); }198199200/**201* Used only by subclasses.202* Constructs an SSL connection to a named host at a specified port,203* binding the client side of the connection a given address and port.204* This acts as the SSL client.205* <p>206* If there is a security manager, its <code>checkConnect</code>207* method is called with the host address and <code>port</code>208* as its arguments. This could result in a SecurityException.209*210* @param host name of the host with which to connect, or211* <code>null</code> for the loopback address.212* @param port number of the server's port213* @param clientAddress the client's address the socket is bound to, or214* <code>null</code> for the <code>anyLocal</code> address.215* @param clientPort the client's port the socket is bound to, or216* <code>zero</code> for a system selected free port.217* @throws IOException if an I/O error occurs when creating the socket218* @throws SecurityException if a security manager exists and its219* <code>checkConnect</code> method doesn't allow the operation.220* @throws UnknownHostException if the host is not known221* @throws IllegalArgumentException if the port parameter or clientPort222* parameter is outside the specified range of valid port values,223* which is between 0 and 65535, inclusive.224* @see SecurityManager#checkConnect225*/226protected SSLSocket(String host, int port,227InetAddress clientAddress, int clientPort)228throws IOException, UnknownHostException229{ super(host, port, clientAddress, clientPort); }230231232/**233* Used only by subclasses.234* Constructs an SSL connection to a server at a specified address235* and TCP port, binding the client side of the connection a given236* address and port. This acts as the SSL client.237* <p>238* If there is a security manager, its <code>checkConnect</code>239* method is called with the host address and <code>port</code>240* as its arguments. This could result in a SecurityException.241*242* @param address the server's host243* @param port its port244* @param clientAddress the client's address the socket is bound to, or245* <code>null</code> for the <code>anyLocal</code> address.246* @param clientPort the client's port the socket is bound to, or247* <code>zero</code> for a system selected free port.248* @throws IOException if an I/O error occurs when creating the socket249* @throws SecurityException if a security manager exists and its250* <code>checkConnect</code> method doesn't allow the operation.251* @throws IllegalArgumentException if the port parameter or clientPort252* parameter is outside the specified range of valid port values,253* which is between 0 and 65535, inclusive.254* @throws NullPointerException if <code>address</code> is null.255* @see SecurityManager#checkConnect256*/257protected SSLSocket(InetAddress address, int port,258InetAddress clientAddress, int clientPort)259throws IOException260{ super(address, port, clientAddress, clientPort); }261262263/**264* Returns the names of the cipher suites which could be enabled for use265* on this connection. Normally, only a subset of these will actually266* be enabled by default, since this list may include cipher suites which267* do not meet quality of service requirements for those defaults. Such268* cipher suites might be useful in specialized applications.269*270* @return an array of cipher suite names271* @see #getEnabledCipherSuites()272* @see #setEnabledCipherSuites(String [])273*/274public abstract String [] getSupportedCipherSuites();275276277/**278* Returns the names of the SSL cipher suites which are currently279* enabled for use on this connection. When an SSLSocket is first280* created, all enabled cipher suites support a minimum quality of281* service. Thus, in some environments this value might be empty.282* <P>283* Even if a suite has been enabled, it might never be used. (For284* example, the peer does not support it, the requisite certificates285* (and private keys) for the suite are not available, or an286* anonymous suite is enabled but authentication is required.287*288* @return an array of cipher suite names289* @see #getSupportedCipherSuites()290* @see #setEnabledCipherSuites(String [])291*/292public abstract String [] getEnabledCipherSuites();293294295/**296* Sets the cipher suites enabled for use on this connection.297* <P>298* Each cipher suite in the <code>suites</code> parameter must have299* been listed by getSupportedCipherSuites(), or the method will300* fail. Following a successful call to this method, only suites301* listed in the <code>suites</code> parameter are enabled for use.302* <P>303* See {@link #getEnabledCipherSuites()} for more information304* on why a specific ciphersuite may never be used on a connection.305*306* @param suites Names of all the cipher suites to enable307* @throws IllegalArgumentException when one or more of the ciphers308* named by the parameter is not supported, or when the309* parameter is null.310* @see #getSupportedCipherSuites()311* @see #getEnabledCipherSuites()312*/313public abstract void setEnabledCipherSuites(String suites []);314315316/**317* Returns the names of the protocols which could be enabled for use318* on an SSL connection.319*320* @return an array of protocols supported321*/322public abstract String [] getSupportedProtocols();323324325/**326* Returns the names of the protocol versions which are currently327* enabled for use on this connection.328* @see #setEnabledProtocols(String [])329* @return an array of protocols330*/331public abstract String [] getEnabledProtocols();332333334/**335* Sets the protocol versions enabled for use on this connection.336* <P>337* The protocols must have been listed by338* <code>getSupportedProtocols()</code> as being supported.339* Following a successful call to this method, only protocols listed340* in the <code>protocols</code> parameter are enabled for use.341*342* @param protocols Names of all the protocols to enable.343* @throws IllegalArgumentException when one or more of344* the protocols named by the parameter is not supported or345* when the protocols parameter is null.346* @see #getEnabledProtocols()347*/348public abstract void setEnabledProtocols(String protocols[]);349350351/**352* Returns the SSL Session in use by this connection. These can353* be long lived, and frequently correspond to an entire login session354* for some user. The session specifies a particular cipher suite355* which is being actively used by all connections in that session,356* as well as the identities of the session's client and server.357* <P>358* This method will initiate the initial handshake if359* necessary and then block until the handshake has been360* established.361* <P>362* If an error occurs during the initial handshake, this method363* returns an invalid session object which reports an invalid364* cipher suite of "SSL_NULL_WITH_NULL_NULL".365*366* @return the <code>SSLSession</code>367*/368public abstract SSLSession getSession();369370371/**372* Returns the {@code SSLSession} being constructed during a SSL/TLS373* handshake.374* <p>375* TLS protocols may negotiate parameters that are needed when using376* an instance of this class, but before the {@code SSLSession} has377* been completely initialized and made available via {@code getSession}.378* For example, the list of valid signature algorithms may restrict379* the type of certificates that can used during TrustManager380* decisions, or the maximum TLS fragment packet sizes can be381* resized to better support the network environment.382* <p>383* This method provides early access to the {@code SSLSession} being384* constructed. Depending on how far the handshake has progressed,385* some data may not yet be available for use. For example, if a386* remote server will be sending a Certificate chain, but that chain387* has yet not been processed, the {@code getPeerCertificates}388* method of {@code SSLSession} will throw a389* SSLPeerUnverifiedException. Once that chain has been processed,390* {@code getPeerCertificates} will return the proper value.391* <p>392* Unlike {@link #getSession()}, this method does not initiate the393* initial handshake and does not block until handshaking is394* complete.395*396* @see SSLEngine397* @see SSLSession398* @see ExtendedSSLSession399* @see X509ExtendedKeyManager400* @see X509ExtendedTrustManager401*402* @return null if this instance is not currently handshaking, or403* if the current handshake has not progressed far enough to404* create a basic SSLSession. Otherwise, this method returns the405* {@code SSLSession} currently being negotiated.406* @throws UnsupportedOperationException if the underlying provider407* does not implement the operation.408*409* @since 1.7410*/411public SSLSession getHandshakeSession() {412throw new UnsupportedOperationException();413}414415416/**417* Registers an event listener to receive notifications that an418* SSL handshake has completed on this connection.419*420* @param listener the HandShake Completed event listener421* @see #startHandshake()422* @see #removeHandshakeCompletedListener(HandshakeCompletedListener)423* @throws IllegalArgumentException if the argument is null.424*/425public abstract void addHandshakeCompletedListener(426HandshakeCompletedListener listener);427428429/**430* Removes a previously registered handshake completion listener.431*432* @param listener the HandShake Completed event listener433* @throws IllegalArgumentException if the listener is not registered,434* or the argument is null.435* @see #addHandshakeCompletedListener(HandshakeCompletedListener)436*/437public abstract void removeHandshakeCompletedListener(438HandshakeCompletedListener listener);439440441/**442* Starts an SSL handshake on this connection. Common reasons include443* a need to use new encryption keys, to change cipher suites, or to444* initiate a new session. To force complete reauthentication, the445* current session could be invalidated before starting this handshake.446*447* <P> If data has already been sent on the connection, it continues448* to flow during this handshake. When the handshake completes, this449* will be signaled with an event.450*451* This method is synchronous for the initial handshake on a connection452* and returns when the negotiated handshake is complete. Some453* protocols may not support multiple handshakes on an existing socket454* and may throw an IOException.455*456* @throws IOException on a network level error457* @see #addHandshakeCompletedListener(HandshakeCompletedListener)458*/459public abstract void startHandshake() throws IOException;460461462/**463* Configures the socket to use client (or server) mode when464* handshaking.465* <P>466* This method must be called before any handshaking occurs.467* Once handshaking has begun, the mode can not be reset for the468* life of this socket.469* <P>470* Servers normally authenticate themselves, and clients471* are not required to do so.472*473* @param mode true if the socket should start its handshaking474* in "client" mode475* @throws IllegalArgumentException if a mode change is attempted476* after the initial handshake has begun.477* @see #getUseClientMode()478*/479public abstract void setUseClientMode(boolean mode);480481482/**483* Returns true if the socket is set to use client mode when484* handshaking.485*486* @return true if the socket should do handshaking487* in "client" mode488* @see #setUseClientMode(boolean)489*/490public abstract boolean getUseClientMode();491492493/**494* Configures the socket to <i>require</i> client authentication. This495* option is only useful for sockets in the server mode.496* <P>497* A socket's client authentication setting is one of the following:498* <ul>499* <li> client authentication required500* <li> client authentication requested501* <li> no client authentication desired502* </ul>503* <P>504* Unlike {@link #setWantClientAuth(boolean)}, if this option is set and505* the client chooses not to provide authentication information506* about itself, <i>the negotiations will stop and the connection507* will be dropped</i>.508* <P>509* Calling this method overrides any previous setting made by510* this method or {@link #setWantClientAuth(boolean)}.511*512* @param need set to true if client authentication is required,513* or false if no client authentication is desired.514* @see #getNeedClientAuth()515* @see #setWantClientAuth(boolean)516* @see #getWantClientAuth()517* @see #setUseClientMode(boolean)518*/519public abstract void setNeedClientAuth(boolean need);520521522/**523* Returns true if the socket will <i>require</i> client authentication.524* This option is only useful to sockets in the server mode.525*526* @return true if client authentication is required,527* or false if no client authentication is desired.528* @see #setNeedClientAuth(boolean)529* @see #setWantClientAuth(boolean)530* @see #getWantClientAuth()531* @see #setUseClientMode(boolean)532*/533public abstract boolean getNeedClientAuth();534535536/**537* Configures the socket to <i>request</i> client authentication.538* This option is only useful for sockets in the server mode.539* <P>540* A socket's client authentication setting is one of the following:541* <ul>542* <li> client authentication required543* <li> client authentication requested544* <li> no client authentication desired545* </ul>546* <P>547* Unlike {@link #setNeedClientAuth(boolean)}, if this option is set and548* the client chooses not to provide authentication information549* about itself, <i>the negotiations will continue</i>.550* <P>551* Calling this method overrides any previous setting made by552* this method or {@link #setNeedClientAuth(boolean)}.553*554* @param want set to true if client authentication is requested,555* or false if no client authentication is desired.556* @see #getWantClientAuth()557* @see #setNeedClientAuth(boolean)558* @see #getNeedClientAuth()559* @see #setUseClientMode(boolean)560*/561public abstract void setWantClientAuth(boolean want);562563564/**565* Returns true if the socket will <i>request</i> client authentication.566* This option is only useful for sockets in the server mode.567*568* @return true if client authentication is requested,569* or false if no client authentication is desired.570* @see #setNeedClientAuth(boolean)571* @see #getNeedClientAuth()572* @see #setWantClientAuth(boolean)573* @see #setUseClientMode(boolean)574*/575public abstract boolean getWantClientAuth();576577578/**579* Controls whether new SSL sessions may be established by this socket.580* If session creations are not allowed, and there are no581* existing sessions to resume, there will be no successful582* handshaking.583*584* @param flag true indicates that sessions may be created; this585* is the default. false indicates that an existing session586* must be resumed587* @see #getEnableSessionCreation()588*/589public abstract void setEnableSessionCreation(boolean flag);590591592/**593* Returns true if new SSL sessions may be established by this socket.594*595* @return true indicates that sessions may be created; this596* is the default. false indicates that an existing session597* must be resumed598* @see #setEnableSessionCreation(boolean)599*/600public abstract boolean getEnableSessionCreation();601602/**603* Returns the SSLParameters in effect for this SSLSocket.604* The ciphersuites and protocols of the returned SSLParameters605* are always non-null.606*607* @return the SSLParameters in effect for this SSLSocket.608* @since 1.6609*/610public SSLParameters getSSLParameters() {611SSLParameters params = new SSLParameters();612params.setCipherSuites(getEnabledCipherSuites());613params.setProtocols(getEnabledProtocols());614if (getNeedClientAuth()) {615params.setNeedClientAuth(true);616} else if (getWantClientAuth()) {617params.setWantClientAuth(true);618}619return params;620}621622/**623* Applies SSLParameters to this socket.624*625* <p>This means:626* <ul>627* <li>If {@code params.getCipherSuites()} is non-null,628* {@code setEnabledCipherSuites()} is called with that value.</li>629* <li>If {@code params.getProtocols()} is non-null,630* {@code setEnabledProtocols()} is called with that value.</li>631* <li>If {@code params.getNeedClientAuth()} or632* {@code params.getWantClientAuth()} return {@code true},633* {@code setNeedClientAuth(true)} and634* {@code setWantClientAuth(true)} are called, respectively;635* otherwise {@code setWantClientAuth(false)} is called.</li>636* <li>If {@code params.getServerNames()} is non-null, the socket will637* configure its server names with that value.</li>638* <li>If {@code params.getSNIMatchers()} is non-null, the socket will639* configure its SNI matchers with that value.</li>640* </ul>641*642* @param params the parameters643* @throws IllegalArgumentException if the setEnabledCipherSuites() or644* the setEnabledProtocols() call fails645* @since 1.6646*/647public void setSSLParameters(SSLParameters params) {648String[] s;649s = params.getCipherSuites();650if (s != null) {651setEnabledCipherSuites(s);652}653s = params.getProtocols();654if (s != null) {655setEnabledProtocols(s);656}657if (params.getNeedClientAuth()) {658setNeedClientAuth(true);659} else if (params.getWantClientAuth()) {660setWantClientAuth(true);661} else {662setWantClientAuth(false);663}664}665666/**667* Returns the most recent application protocol value negotiated for this668* connection.669* <p>670* If supported by the underlying SSL/TLS/DTLS implementation,671* application name negotiation mechanisms such as <a672* href="http://www.ietf.org/rfc/rfc7301.txt"> RFC 7301 </a>, the673* Application-Layer Protocol Negotiation (ALPN), can negotiate674* application-level values between peers.675*676* @implSpec677* The implementation in this class throws678* {@code UnsupportedOperationException} and performs no other action.679*680* @return null if it has not yet been determined if application681* protocols might be used for this connection, an empty682* {@code String} if application protocols values will not683* be used, or a non-empty application protocol {@code String}684* if a value was successfully negotiated.685* @throws UnsupportedOperationException if the underlying provider686* does not implement the operation.687* @since 8688*/689public String getApplicationProtocol() {690throw new UnsupportedOperationException();691}692693/**694* Returns the application protocol value negotiated on a SSL/TLS695* handshake currently in progress.696* <p>697* Like {@link #getHandshakeSession()},698* a connection may be in the middle of a handshake. The699* application protocol may or may not yet be available.700*701* @implSpec702* The implementation in this class throws703* {@code UnsupportedOperationException} and performs no other action.704*705* @return null if it has not yet been determined if application706* protocols might be used for this handshake, an empty707* {@code String} if application protocols values will not708* be used, or a non-empty application protocol {@code String}709* if a value was successfully negotiated.710* @throws UnsupportedOperationException if the underlying provider711* does not implement the operation.712* @since 8713*/714public String getHandshakeApplicationProtocol() {715throw new UnsupportedOperationException();716}717718719/**720* Registers a callback function that selects an application protocol721* value for a SSL/TLS/DTLS handshake.722* The function overrides any values supplied using723* {@link SSLParameters#setApplicationProtocols724* SSLParameters.setApplicationProtocols} and it supports the following725* type parameters:726* <blockquote>727* <dl>728* <dt> {@code SSLSocket}729* <dd> The function's first argument allows the current {@code SSLSocket}730* to be inspected, including the handshake session and configuration731* settings.732* <dt> {@code List<String>}733* <dd> The function's second argument lists the application protocol names734* advertised by the TLS peer.735* <dt> {@code String}736* <dd> The function's result is an application protocol name, or null to737* indicate that none of the advertised names are acceptable.738* If the return value is an empty {@code String} then application739* protocol indications will not be used.740* If the return value is null (no value chosen) or is a value that741* was not advertised by the peer, the underlying protocol will742* determine what action to take. (For example, ALPN will send a743* "no_application_protocol" alert and terminate the connection.)744* </dl>745* </blockquote>746*747* For example, the following call registers a callback function that748* examines the TLS handshake parameters and selects an application protocol749* name:750* <pre>{@code751* serverSocket.setHandshakeApplicationProtocolSelector(752* (serverSocket, clientProtocols) -> {753* SSLSession session = serverSocket.getHandshakeSession();754* return chooseApplicationProtocol(755* serverSocket,756* clientProtocols,757* session.getProtocol(),758* session.getCipherSuite());759* });760* }</pre>761*762* @apiNote763* This method should be called by TLS server applications before the TLS764* handshake begins. Also, this {@code SSLSocket} should be configured with765* parameters that are compatible with the application protocol selected by766* the callback function. For example, enabling a poor choice of cipher767* suites could result in no suitable application protocol.768* See {@link SSLParameters}.769*770* @implSpec771* The implementation in this class throws772* {@code UnsupportedOperationException} and performs no other action.773*774* @param selector the callback function, or null to de-register.775* @throws UnsupportedOperationException if the underlying provider776* does not implement the operation.777* @since 8778*/779public void setHandshakeApplicationProtocolSelector(780BiFunction<SSLSocket, List<String>, String> selector) {781throw new UnsupportedOperationException();782}783784/**785* Retrieves the callback function that selects an application protocol786* value during a SSL/TLS/DTLS handshake.787* See {@link #setHandshakeApplicationProtocolSelector788* setHandshakeApplicationProtocolSelector}789* for the function's type parameters.790*791* @implSpec792* The implementation in this class throws793* {@code UnsupportedOperationException} and performs no other action.794*795* @return the callback function, or null if none has been set.796* @throws UnsupportedOperationException if the underlying provider797* does not implement the operation.798* @since 8799*/800public BiFunction<SSLSocket, List<String>, String>801getHandshakeApplicationProtocolSelector() {802throw new UnsupportedOperationException();803}804}805806807