package okhttp3.internal.platform; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; import okhttp3.Protocol; import okhttp3.internal.Util; /* loaded from: classes2.dex */ final class Jdk9Platform extends Platform { final Method getProtocolMethod; final Method setProtocolMethod; Jdk9Platform(Method method, Method method2) { this.setProtocolMethod = method; this.getProtocolMethod = method2; } public static Jdk9Platform buildIfSupported() { try { return new Jdk9Platform(SSLParameters.class.getMethod("setApplicationProtocols", String[].class), SSLSocket.class.getMethod("getApplicationProtocol", new Class[0])); } catch (NoSuchMethodException unused) { return null; } } @Override // okhttp3.internal.platform.Platform public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) { try { SSLParameters sSLParameters = sSLSocket.getSSLParameters(); List alpnProtocolNames = Platform.alpnProtocolNames(list); this.setProtocolMethod.invoke(sSLParameters, alpnProtocolNames.toArray(new String[alpnProtocolNames.size()])); sSLSocket.setSSLParameters(sSLParameters); } catch (IllegalAccessException | InvocationTargetException e) { throw Util.assertionError("unable to set ssl parameters", e); } } @Override // okhttp3.internal.platform.Platform public String getSelectedProtocol(SSLSocket sSLSocket) { try { String str = (String) this.getProtocolMethod.invoke(sSLSocket, new Object[0]); if (str == null) { return null; } if (str.equals("")) { return null; } return str; } catch (IllegalAccessException | InvocationTargetException e) { throw Util.assertionError("unable to get selected protocols", e); } } @Override // okhttp3.internal.platform.Platform public X509TrustManager trustManager(SSLSocketFactory sSLSocketFactory) { throw new UnsupportedOperationException("clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+"); } }