1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.conscrypt; 18 19 import java.io.FileDescriptor; 20 import java.io.IOException; 21 import java.net.InetAddress; 22 import java.net.Socket; 23 import java.net.SocketException; 24 import java.security.PrivateKey; 25 import javax.net.ssl.SSLException; 26 import javax.net.ssl.SSLSession; 27 28 /** 29 * Public shim allowing us to stay backward-compatible with legacy applications which were using 30 * Conscrypt's extended socket API before the introduction of the {@link Conscrypt} class. 31 * 32 * @hide 33 */ 34 @Internal 35 public abstract class OpenSSLSocketImpl extends ConscryptSocketBase { 36 OpenSSLSocketImpl() throws IOException { 37 } 38 39 OpenSSLSocketImpl(String hostname, int port) throws IOException { 40 super(hostname, port); 41 } 42 43 OpenSSLSocketImpl(InetAddress address, int port) throws IOException { 44 super(address, port); 45 } 46 47 OpenSSLSocketImpl(String hostname, int port, InetAddress clientAddress, int clientPort) 48 throws IOException { 49 super(hostname, port, clientAddress, clientPort); 50 } 51 52 OpenSSLSocketImpl(InetAddress address, int port, InetAddress clientAddress, 53 int clientPort) 54 throws IOException { 55 super(address, port, clientAddress, clientPort); 56 } 57 58 OpenSSLSocketImpl(Socket socket, String hostname, int port, boolean autoClose) 59 throws IOException { 60 super(socket, hostname, port, autoClose); 61 } 62 63 @Override 64 public String getHostname() { 65 return super.getHostname(); 66 } 67 68 @Override 69 public void setHostname(String hostname) { 70 super.setHostname(hostname); 71 } 72 73 @Override 74 public String getHostnameOrIP() { 75 return super.getHostnameOrIP(); 76 } 77 78 @Override 79 public FileDescriptor getFileDescriptor$() { 80 return super.getFileDescriptor$(); 81 } 82 83 @Override 84 public void setSoWriteTimeout(int writeTimeoutMilliseconds) throws SocketException { 85 super.setSoWriteTimeout(writeTimeoutMilliseconds); 86 } 87 88 @Override 89 public int getSoWriteTimeout() throws SocketException { 90 return super.getSoWriteTimeout(); 91 } 92 93 @Override 94 public void setHandshakeTimeout(int handshakeTimeoutMilliseconds) throws SocketException { 95 super.setHandshakeTimeout(handshakeTimeoutMilliseconds); 96 } 97 98 @Override 99 public abstract SSLSession getHandshakeSession(); 100 101 @Override 102 public abstract void setUseSessionTickets(boolean useSessionTickets); 103 104 @Override 105 public abstract void setChannelIdEnabled(boolean enabled); 106 107 @Override 108 public abstract byte[] getChannelId() throws SSLException; 109 110 @Override 111 public abstract void setChannelIdPrivateKey(PrivateKey privateKey); 112 113 @Override 114 @Deprecated 115 public final byte[] getNpnSelectedProtocol() { 116 return super.getNpnSelectedProtocol(); 117 } 118 119 @Override 120 @Deprecated 121 public final void setNpnProtocols(byte[] npnProtocols) { 122 super.setNpnProtocols(npnProtocols); 123 } 124 125 @Override 126 @Deprecated 127 public final void setAlpnProtocols(String[] alpnProtocols) { 128 setApplicationProtocols(alpnProtocols == null ? EmptyArray.STRING : alpnProtocols); 129 } 130 131 @Deprecated 132 @Override 133 public final byte[] getAlpnSelectedProtocol() { 134 return SSLUtils.toProtocolBytes(getApplicationProtocol()); 135 } 136 137 /** 138 * @deprecated Use {@link #setAlpnProtocols(String[])} instead. 139 */ 140 @Override 141 @Deprecated 142 public final void setAlpnProtocols(byte[] protocols) { 143 setApplicationProtocols(SSLUtils.decodeProtocols(protocols == null ? EmptyArray.BYTE : protocols)); 144 } 145 } 146