org.conscrypt.Java8FileDescriptorSocket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qetcher-client-bundle Show documentation
Show all versions of qetcher-client-bundle Show documentation
Qetcher Java client, OSGi bundle, minimal dependencies
package org.conscrypt;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.List;
import java.util.function.BiFunction;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket;
/**
* A version of ConscryptFileDescriptorSocket that includes the new Java 9 (and potentially later
* patches of 8) {@code setHandshakeApplicationProtocolSelector} API (which requires Java 8 for
* compilation, due to the use of {@link BiFunction}).
*/
final class Java8FileDescriptorSocket extends ConscryptFileDescriptorSocket {
private BiFunction, String> selector;
Java8FileDescriptorSocket(SSLParametersImpl sslParameters) throws IOException {
super(sslParameters);
}
Java8FileDescriptorSocket(String hostname, int port, SSLParametersImpl sslParameters)
throws IOException {
super(hostname, port, sslParameters);
}
Java8FileDescriptorSocket(InetAddress address, int port, SSLParametersImpl sslParameters)
throws IOException {
super(address, port, sslParameters);
}
Java8FileDescriptorSocket(String hostname, int port, InetAddress clientAddress, int clientPort,
SSLParametersImpl sslParameters) throws IOException {
super(hostname, port, clientAddress, clientPort, sslParameters);
}
Java8FileDescriptorSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort,
SSLParametersImpl sslParameters) throws IOException {
super(address, port, clientAddress, clientPort, sslParameters);
}
Java8FileDescriptorSocket(Socket socket, String hostname, int port, boolean autoClose,
SSLParametersImpl sslParameters) throws IOException {
super(socket, hostname, port, autoClose, sslParameters);
}
/* @Override */
@SuppressWarnings("MissingOverride") // For compilation with Java < 9.
public void setHandshakeApplicationProtocolSelector(
final BiFunction, String> selector) {
this.selector = selector;
setApplicationProtocolSelector(toApplicationProtocolSelector(selector));
}
/* @Override */
@SuppressWarnings("MissingOverride") // For compilation with Java < 9.
public BiFunction, String> getHandshakeApplicationProtocolSelector() {
return selector;
}
private static ApplicationProtocolSelector toApplicationProtocolSelector(
final BiFunction, String> selector) {
return selector == null ? null : new ApplicationProtocolSelector() {
@Override
public String selectApplicationProtocol(SSLEngine socket, List protocols) {
throw new UnsupportedOperationException();
}
@Override
public String selectApplicationProtocol(SSLSocket socket, List protocols) {
return selector.apply(socket, protocols);
}
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy