1 /* 2 * Copyright (C) 2015 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.apache.harmony.xnet.provider.jsse; 18 import java.io.FileDescriptor; 19 import java.io.IOException; 20 import java.io.InputStream; 21 import java.io.OutputStream; 22 import java.net.InetAddress; 23 import java.net.Socket; 24 import java.net.SocketException; 25 import java.security.PrivateKey; 26 import java.security.cert.CertificateEncodingException; 27 import java.security.cert.CertificateException; 28 import javax.net.ssl.HandshakeCompletedListener; 29 import javax.net.ssl.SSLException; 30 import javax.net.ssl.SSLSession; 31 32 /** 33 * Implementation of the class OpenSSLSocketImpl based on OpenSSL. 34 * <p> 35 * Extensions to SSLSocket include: 36 * <ul> 37 * <li>handshake timeout 38 * <li>session tickets 39 * <li>Server Name Indication 40 * </ul> 41 */ 42 public class OpenSSLSocketImpl 43 extends javax.net.ssl.SSLSocket implements NativeCrypto.SSLHandshakeCallbacks { OpenSSLSocketImpl(SSLParametersImpl sslParameters)44 protected OpenSSLSocketImpl(SSLParametersImpl sslParameters) throws IOException { 45 throw new RuntimeException("Stub!"); 46 } 47 OpenSSLSocketImpl(SSLParametersImpl sslParameters, String[] enabledProtocols, String[] enabledCipherSuites)48 protected OpenSSLSocketImpl(SSLParametersImpl sslParameters, String[] enabledProtocols, 49 String[] enabledCipherSuites) throws IOException { 50 throw new RuntimeException("Stub!"); 51 } 52 OpenSSLSocketImpl(String host, int port, SSLParametersImpl sslParameters)53 protected OpenSSLSocketImpl(String host, int port, SSLParametersImpl sslParameters) 54 throws IOException { 55 throw new RuntimeException("Stub!"); 56 } 57 OpenSSLSocketImpl(InetAddress address, int port, SSLParametersImpl sslParameters)58 protected OpenSSLSocketImpl(InetAddress address, int port, SSLParametersImpl sslParameters) 59 throws IOException { 60 throw new RuntimeException("Stub!"); 61 } 62 OpenSSLSocketImpl(String host, int port, InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters)63 protected OpenSSLSocketImpl(String host, int port, InetAddress clientAddress, int clientPort, 64 SSLParametersImpl sslParameters) throws IOException { 65 throw new RuntimeException("Stub!"); 66 } 67 OpenSSLSocketImpl(InetAddress address, int port, InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters)68 protected OpenSSLSocketImpl(InetAddress address, int port, InetAddress clientAddress, 69 int clientPort, SSLParametersImpl sslParameters) throws IOException { 70 throw new RuntimeException("Stub!"); 71 } 72 OpenSSLSocketImpl(Socket socket, String host, int port, boolean autoClose, SSLParametersImpl sslParameters)73 protected OpenSSLSocketImpl(Socket socket, String host, int port, boolean autoClose, 74 SSLParametersImpl sslParameters) throws IOException { 75 throw new RuntimeException("Stub!"); 76 } 77 78 @Override startHandshake()79 public synchronized void startHandshake() throws IOException { 80 throw new RuntimeException("Stub!"); 81 } 82 83 @SuppressWarnings("unused") // used by NativeCrypto.SSLHandshakeCallbacks / client_cert_cb 84 @Override clientCertificateRequested(byte[] keyTypeBytes, byte[][] asn1DerEncodedPrincipals)85 public void clientCertificateRequested(byte[] keyTypeBytes, byte[][] asn1DerEncodedPrincipals) 86 throws CertificateEncodingException, SSLException { 87 throw new RuntimeException("Stub!"); 88 } 89 90 @SuppressWarnings("unused") // used by NativeCrypto.SSLHandshakeCallbacks / info_callback 91 @Override handshakeCompleted()92 public void handshakeCompleted() { 93 throw new RuntimeException("Stub!"); 94 } 95 96 @SuppressWarnings("unused") // used by NativeCrypto.SSLHandshakeCallbacks 97 @Override verifyCertificateChain(byte[][] bytes, String authMethod)98 public void verifyCertificateChain(byte[][] bytes, String authMethod) 99 throws CertificateException { 100 throw new RuntimeException("Stub!"); 101 } 102 103 @Override getInputStream()104 public InputStream getInputStream() throws IOException { 105 throw new RuntimeException("Stub!"); 106 } 107 108 @Override getOutputStream()109 public OutputStream getOutputStream() throws IOException { 110 throw new RuntimeException("Stub!"); 111 } 112 113 @Override getSession()114 public SSLSession getSession() { 115 throw new RuntimeException("Stub!"); 116 } 117 118 @Override addHandshakeCompletedListener(HandshakeCompletedListener listener)119 public void addHandshakeCompletedListener(HandshakeCompletedListener listener) { 120 throw new RuntimeException("Stub!"); 121 } 122 123 @Override removeHandshakeCompletedListener(HandshakeCompletedListener listener)124 public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) { 125 throw new RuntimeException("Stub!"); 126 } 127 128 @Override getEnableSessionCreation()129 public boolean getEnableSessionCreation() { 130 throw new RuntimeException("Stub!"); 131 } 132 133 @Override setEnableSessionCreation(boolean flag)134 public void setEnableSessionCreation(boolean flag) { 135 throw new RuntimeException("Stub!"); 136 } 137 138 @Override getSupportedCipherSuites()139 public String[] getSupportedCipherSuites() { 140 throw new RuntimeException("Stub!"); 141 } 142 143 @Override getEnabledCipherSuites()144 public String[] getEnabledCipherSuites() { 145 throw new RuntimeException("Stub!"); 146 } 147 148 @Override setEnabledCipherSuites(String[] suites)149 public void setEnabledCipherSuites(String[] suites) { 150 throw new RuntimeException("Stub!"); 151 } 152 153 @Override getSupportedProtocols()154 public String[] getSupportedProtocols() { 155 throw new RuntimeException("Stub!"); 156 } 157 158 @Override getEnabledProtocols()159 public String[] getEnabledProtocols() { 160 throw new RuntimeException("Stub!"); 161 } 162 163 @Override setEnabledProtocols(String[] protocols)164 public void setEnabledProtocols(String[] protocols) { 165 throw new RuntimeException("Stub!"); 166 } 167 setUseSessionTickets(boolean useSessionTickets)168 public void setUseSessionTickets(boolean useSessionTickets) { 169 throw new RuntimeException("Stub!"); 170 } 171 setHostname(String hostname)172 public void setHostname(String hostname) { 173 throw new RuntimeException("Stub!"); 174 } 175 setChannelIdEnabled(boolean enabled)176 public void setChannelIdEnabled(boolean enabled) { 177 throw new RuntimeException("Stub!"); 178 } 179 getChannelId()180 public byte[] getChannelId() throws SSLException { 181 throw new RuntimeException("Stub!"); 182 } 183 setChannelIdPrivateKey(PrivateKey privateKey)184 public void setChannelIdPrivateKey(PrivateKey privateKey) { 185 throw new RuntimeException("Stub!"); 186 } 187 188 @Override getUseClientMode()189 public boolean getUseClientMode() { 190 throw new RuntimeException("Stub!"); 191 } 192 193 @Override setUseClientMode(boolean mode)194 public void setUseClientMode(boolean mode) { 195 throw new RuntimeException("Stub!"); 196 } 197 198 @Override getWantClientAuth()199 public boolean getWantClientAuth() { 200 throw new RuntimeException("Stub!"); 201 } 202 203 @Override getNeedClientAuth()204 public boolean getNeedClientAuth() { 205 throw new RuntimeException("Stub!"); 206 } 207 208 @Override setNeedClientAuth(boolean need)209 public void setNeedClientAuth(boolean need) { 210 throw new RuntimeException("Stub!"); 211 } 212 213 @Override setWantClientAuth(boolean want)214 public void setWantClientAuth(boolean want) { 215 throw new RuntimeException("Stub!"); 216 } 217 218 @Override sendUrgentData(int data)219 public void sendUrgentData(int data) throws IOException { 220 throw new RuntimeException("Stub!"); 221 } 222 223 @Override setOOBInline(boolean on)224 public void setOOBInline(boolean on) throws SocketException { 225 throw new RuntimeException("Stub!"); 226 } 227 228 @SuppressWarnings("UnsynchronizedOverridesSynchronized") 229 @Override setSoTimeout(int readTimeoutMilliseconds)230 public void setSoTimeout(int readTimeoutMilliseconds) throws SocketException { 231 throw new RuntimeException("Stub!"); 232 } 233 234 @SuppressWarnings("UnsynchronizedOverridesSynchronized") 235 @Override getSoTimeout()236 public int getSoTimeout() throws SocketException { 237 throw new RuntimeException("Stub!"); 238 } 239 240 /** 241 * Note write timeouts are not part of the javax.net.ssl.SSLSocket API 242 */ setSoWriteTimeout(int writeTimeoutMilliseconds)243 public void setSoWriteTimeout(int writeTimeoutMilliseconds) throws SocketException { 244 throw new RuntimeException("Stub!"); 245 } 246 247 /** 248 * Note write timeouts are not part of the javax.net.ssl.SSLSocket API 249 */ getSoWriteTimeout()250 public int getSoWriteTimeout() throws SocketException { 251 throw new RuntimeException("Stub!"); 252 } 253 254 /** 255 * Set the handshake timeout on this socket. This timeout is specified in 256 * milliseconds and will be used only during the handshake process. 257 */ setHandshakeTimeout(int handshakeTimeoutMilliseconds)258 public void setHandshakeTimeout(int handshakeTimeoutMilliseconds) throws SocketException { 259 throw new RuntimeException("Stub!"); 260 } 261 262 @SuppressWarnings("UnsynchronizedOverridesSynchronized") 263 @Override close()264 public void close() throws IOException { 265 throw new RuntimeException("Stub!"); 266 } 267 getFileDescriptor$()268 public FileDescriptor getFileDescriptor$() { 269 throw new RuntimeException("Stub!"); 270 } 271 getNpnSelectedProtocol()272 public byte[] getNpnSelectedProtocol() { 273 throw new RuntimeException("Stub!"); 274 } 275 setNpnProtocols(byte[] npnProtocols)276 public void setNpnProtocols(byte[] npnProtocols) { 277 throw new RuntimeException("Stub!"); 278 } 279 } 280