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 package com.android.org.conscrypt;
17 
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
clientCertificateRequested(byte[] keyTypeBytes, byte[][] asn1DerEncodedPrincipals)84     public void clientCertificateRequested(byte[] keyTypeBytes, byte[][] asn1DerEncodedPrincipals)
85             throws CertificateEncodingException, SSLException {
86         throw new RuntimeException("Stub!");
87     }
88 
89     @SuppressWarnings("unused") // used by NativeCrypto.SSLHandshakeCallbacks / info_callback
handshakeCompleted()90     public void handshakeCompleted() {
91         throw new RuntimeException("Stub!");
92     }
93     @SuppressWarnings("unused") // used by NativeCrypto.SSLHandshakeCallbacks
94     @Override
verifyCertificateChain(byte[][] bytes, String authMethod)95     public void verifyCertificateChain(byte[][] bytes, String authMethod)
96             throws CertificateException {
97         throw new RuntimeException("Stub!");
98     }
99 
100     @Override
getInputStream()101     public InputStream getInputStream() throws IOException {
102         throw new RuntimeException("Stub!");
103     }
104 
105     @Override
getOutputStream()106     public OutputStream getOutputStream() throws IOException {
107         throw new RuntimeException("Stub!");
108     }
109     @Override
getSession()110     public SSLSession getSession() {
111         throw new RuntimeException("Stub!");
112     }
113 
114     @Override
addHandshakeCompletedListener(HandshakeCompletedListener listener)115     public void addHandshakeCompletedListener(HandshakeCompletedListener listener) {
116         throw new RuntimeException("Stub!");
117     }
118 
119     @Override
removeHandshakeCompletedListener(HandshakeCompletedListener listener)120     public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) {
121         throw new RuntimeException("Stub!");
122     }
123 
124     @Override
getEnableSessionCreation()125     public boolean getEnableSessionCreation() {
126         throw new RuntimeException("Stub!");
127     }
128 
129     @Override
setEnableSessionCreation(boolean flag)130     public void setEnableSessionCreation(boolean flag) {
131         throw new RuntimeException("Stub!");
132     }
133 
134     @Override
getSupportedCipherSuites()135     public String[] getSupportedCipherSuites() {
136         throw new RuntimeException("Stub!");
137     }
138 
139     @Override
getEnabledCipherSuites()140     public String[] getEnabledCipherSuites() {
141         throw new RuntimeException("Stub!");
142     }
143 
144     @Override
setEnabledCipherSuites(String[] suites)145     public void setEnabledCipherSuites(String[] suites) {
146         throw new RuntimeException("Stub!");
147     }
148 
149     @Override
getSupportedProtocols()150     public String[] getSupportedProtocols() {
151         throw new RuntimeException("Stub!");
152     }
153 
154     @Override
getEnabledProtocols()155     public String[] getEnabledProtocols() {
156         throw new RuntimeException("Stub!");
157     }
158 
159     @Override
setEnabledProtocols(String[] protocols)160     public void setEnabledProtocols(String[] protocols) {
161         throw new RuntimeException("Stub!");
162     }
setUseSessionTickets(boolean useSessionTickets)163     public void setUseSessionTickets(boolean useSessionTickets) {
164         throw new RuntimeException("Stub!");
165     }
166 
setHostname(String hostname)167     public void setHostname(String hostname) {
168         throw new RuntimeException("Stub!");
169     }
170 
setChannelIdEnabled(boolean enabled)171     public void setChannelIdEnabled(boolean enabled) {
172         throw new RuntimeException("Stub!");
173     }
174 
getChannelId()175     public byte[] getChannelId() throws SSLException {
176         throw new RuntimeException("Stub!");
177     }
setChannelIdPrivateKey(PrivateKey privateKey)178     public void setChannelIdPrivateKey(PrivateKey privateKey) {
179         throw new RuntimeException("Stub!");
180     }
181 
182     @Override
getUseClientMode()183     public boolean getUseClientMode() {
184         throw new RuntimeException("Stub!");
185     }
186 
187     @Override
setUseClientMode(boolean mode)188     public void setUseClientMode(boolean mode) {
189         throw new RuntimeException("Stub!");
190     }
191 
192     @Override
getWantClientAuth()193     public boolean getWantClientAuth() {
194         throw new RuntimeException("Stub!");
195     }
196 
197     @Override
getNeedClientAuth()198     public boolean getNeedClientAuth() {
199         throw new RuntimeException("Stub!");
200     }
201 
202     @Override
setNeedClientAuth(boolean need)203     public void setNeedClientAuth(boolean need) {
204         throw new RuntimeException("Stub!");
205     }
206 
207     @Override
setWantClientAuth(boolean want)208     public void setWantClientAuth(boolean want) {
209         throw new RuntimeException("Stub!");
210     }
211 
212     @Override
sendUrgentData(int data)213     public void sendUrgentData(int data) throws IOException {
214         throw new RuntimeException("Stub!");
215     }
216 
217     @Override
setOOBInline(boolean on)218     public void setOOBInline(boolean on) throws SocketException {
219         throw new RuntimeException("Stub!");
220     }
221 
222     @Override
setSoTimeout(int readTimeoutMilliseconds)223     public void setSoTimeout(int readTimeoutMilliseconds) throws SocketException {
224         throw new RuntimeException("Stub!");
225     }
226 
227     @Override
getSoTimeout()228     public int getSoTimeout() throws SocketException {
229         throw new RuntimeException("Stub!");
230     }
231 
232     /**
233      * Note write timeouts are not part of the javax.net.ssl.SSLSocket API
234      */
setSoWriteTimeout(int writeTimeoutMilliseconds)235     public void setSoWriteTimeout(int writeTimeoutMilliseconds) throws SocketException {
236         throw new RuntimeException("Stub!");
237     }
238 
239     /**
240      * Note write timeouts are not part of the javax.net.ssl.SSLSocket API
241      */
getSoWriteTimeout()242     public int getSoWriteTimeout() throws SocketException {
243         throw new RuntimeException("Stub!");
244     }
245 
246     /**
247      * Set the handshake timeout on this socket.  This timeout is specified in
248      * milliseconds and will be used only during the handshake process.
249      */
setHandshakeTimeout(int handshakeTimeoutMilliseconds)250     public void setHandshakeTimeout(int handshakeTimeoutMilliseconds) throws SocketException {
251         throw new RuntimeException("Stub!");
252     }
253 
254     @Override
close()255     public void close() throws IOException {
256         throw new RuntimeException("Stub!");
257     }
258 
getFileDescriptor$()259     public FileDescriptor getFileDescriptor$() {
260         throw new RuntimeException("Stub!");
261     }
262 
getNpnSelectedProtocol()263     public byte[] getNpnSelectedProtocol() {
264         throw new RuntimeException("Stub!");
265     }
266 
setNpnProtocols(byte[] npnProtocols)267     public void setNpnProtocols(byte[] npnProtocols) {
268         throw new RuntimeException("Stub!");
269     }
270 }
271