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 @Internal 33 public abstract class OpenSSLSocketImpl extends AbstractConscryptSocket { OpenSSLSocketImpl()34 OpenSSLSocketImpl() throws IOException { 35 } 36 OpenSSLSocketImpl(String hostname, int port)37 OpenSSLSocketImpl(String hostname, int port) throws IOException { 38 super(hostname, port); 39 } 40 OpenSSLSocketImpl(InetAddress address, int port)41 OpenSSLSocketImpl(InetAddress address, int port) throws IOException { 42 super(address, port); 43 } 44 OpenSSLSocketImpl(String hostname, int port, InetAddress clientAddress, int clientPort)45 OpenSSLSocketImpl(String hostname, int port, InetAddress clientAddress, int clientPort) 46 throws IOException { 47 super(hostname, port, clientAddress, clientPort); 48 } 49 OpenSSLSocketImpl(InetAddress address, int port, InetAddress clientAddress, int clientPort)50 OpenSSLSocketImpl(InetAddress address, int port, InetAddress clientAddress, 51 int clientPort) 52 throws IOException { 53 super(address, port, clientAddress, clientPort); 54 } 55 OpenSSLSocketImpl(Socket socket, String hostname, int port, boolean autoClose)56 OpenSSLSocketImpl(Socket socket, String hostname, int port, boolean autoClose) 57 throws IOException { 58 super(socket, hostname, port, autoClose); 59 } 60 61 @Override getHostname()62 public String getHostname() { 63 return super.getHostname(); 64 } 65 66 @Override setHostname(String hostname)67 public void setHostname(String hostname) { 68 super.setHostname(hostname); 69 } 70 71 @Override getHostnameOrIP()72 public String getHostnameOrIP() { 73 return super.getHostnameOrIP(); 74 } 75 76 @Override getFileDescriptor$()77 public FileDescriptor getFileDescriptor$() { 78 return super.getFileDescriptor$(); 79 } 80 81 @Override setSoWriteTimeout(int writeTimeoutMilliseconds)82 public void setSoWriteTimeout(int writeTimeoutMilliseconds) throws SocketException { 83 super.setSoWriteTimeout(writeTimeoutMilliseconds); 84 } 85 86 @Override getSoWriteTimeout()87 public int getSoWriteTimeout() throws SocketException { 88 return super.getSoWriteTimeout(); 89 } 90 91 @Override setHandshakeTimeout(int handshakeTimeoutMilliseconds)92 public void setHandshakeTimeout(int handshakeTimeoutMilliseconds) throws SocketException { 93 super.setHandshakeTimeout(handshakeTimeoutMilliseconds); 94 } 95 96 @Override getHandshakeSession()97 public abstract SSLSession getHandshakeSession(); 98 99 @Override setUseSessionTickets(boolean useSessionTickets)100 public abstract void setUseSessionTickets(boolean useSessionTickets); 101 102 @Override setChannelIdEnabled(boolean enabled)103 public abstract void setChannelIdEnabled(boolean enabled); 104 105 @Override getChannelId()106 public abstract byte[] getChannelId() throws SSLException; 107 108 @Override setChannelIdPrivateKey(PrivateKey privateKey)109 public abstract void setChannelIdPrivateKey(PrivateKey privateKey); 110 111 /** 112 * @deprecated NPN is not supported 113 */ 114 @Override 115 @Deprecated getNpnSelectedProtocol()116 public final byte[] getNpnSelectedProtocol() { 117 return super.getNpnSelectedProtocol(); 118 } 119 120 /** 121 * @deprecated NPN is not supported 122 */ 123 @Override 124 @Deprecated setNpnProtocols(byte[] npnProtocols)125 public final void setNpnProtocols(byte[] npnProtocols) { 126 super.setNpnProtocols(npnProtocols); 127 } 128 129 /** 130 * @deprecated use {@link #setApplicationProtocols(String[])} instead. 131 */ 132 @Override 133 @Deprecated setAlpnProtocols(String[] alpnProtocols)134 public final void setAlpnProtocols(String[] alpnProtocols) { 135 setApplicationProtocols(alpnProtocols == null ? EmptyArray.STRING : alpnProtocols); 136 } 137 138 /** 139 * @deprecated use {@link #getApplicationProtocol()} instead. 140 */ 141 @Override 142 @Deprecated getAlpnSelectedProtocol()143 public final byte[] getAlpnSelectedProtocol() { 144 return SSLUtils.toProtocolBytes(getApplicationProtocol()); 145 } 146 147 /** 148 * @deprecated Use {@link #setAlpnProtocols(String[])} instead. 149 */ 150 @Override 151 @Deprecated setAlpnProtocols(byte[] protocols)152 public final void setAlpnProtocols(byte[] protocols) { 153 setApplicationProtocols(SSLUtils.decodeProtocols(protocols == null ? EmptyArray.BYTE : protocols)); 154 } 155 } 156