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.IOException; 20 import java.net.InetAddress; 21 import java.net.ServerSocket; 22 import java.security.KeyManagementException; 23 24 public class OpenSSLServerSocketFactoryImpl extends javax.net.ssl.SSLServerSocketFactory { 25 26 private SSLParametersImpl sslParameters; 27 private IOException instantiationException; 28 29 public OpenSSLServerSocketFactoryImpl() { 30 try { 31 this.sslParameters = SSLParametersImpl.getDefault(); 32 this.sslParameters.setUseClientMode(false); 33 } catch (KeyManagementException e) { 34 instantiationException = 35 new IOException("Delayed instantiation exception:"); 36 instantiationException.initCause(e); 37 } 38 } 39 40 public OpenSSLServerSocketFactoryImpl(SSLParametersImpl sslParameters) { 41 this.sslParameters = (SSLParametersImpl) sslParameters.clone(); 42 this.sslParameters.setUseClientMode(false); 43 } 44 45 public String[] getDefaultCipherSuites() { 46 return NativeCrypto.getDefaultCipherSuites(); 47 } 48 49 public String[] getSupportedCipherSuites() { 50 return NativeCrypto.getSupportedCipherSuites(); 51 } 52 53 public ServerSocket createServerSocket() throws IOException { 54 return new OpenSSLServerSocketImpl((SSLParametersImpl) sslParameters.clone()); 55 } 56 57 public ServerSocket createServerSocket(int port) throws IOException { 58 return new OpenSSLServerSocketImpl(port, (SSLParametersImpl) sslParameters.clone()); 59 } 60 61 public ServerSocket createServerSocket(int port, int backlog) 62 throws IOException { 63 return new OpenSSLServerSocketImpl(port, 64 backlog, 65 (SSLParametersImpl) sslParameters.clone()); 66 } 67 68 public ServerSocket createServerSocket(int port, 69 int backlog, 70 InetAddress iAddress) throws IOException { 71 return new OpenSSLServerSocketImpl(port, 72 backlog, 73 iAddress, 74 (SSLParametersImpl) sslParameters.clone()); 75 } 76 } 77