1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
26 package sun.security.ssl;
27
28 import java.io.*;
29 import java.net.*;
30 import javax.net.ssl.SSLSocketFactory;
31
32
33 /**
34 * Implementation of an SSL socket factory. This provides the public
35 * hooks to create SSL sockets, using a "high level" programming
36 * interface which encapsulates system security policy defaults rather than
37 * offering application flexibility. In particular, it uses a configurable
38 * authentication context (and the keys held there) rather than offering
39 * any flexibility about which keys to use; that context defaults to the
40 * process-default context, but may be explicitly specified.
41 *
42 * @author David Brownell
43 */
44 public final class SSLSocketFactoryImpl extends SSLSocketFactory {
45
46 private SSLContextImpl context;
47
48 /**
49 * Constructor used to instantiate the default factory. This method is
50 * only called if the old "ssl.SocketFactory.provider" property in the
51 * java.security file is set.
52 */
53 public SSLSocketFactoryImpl() throws Exception {
54 this.context = SSLContextImpl.DefaultSSLContext.getDefaultImpl();
55 }
56
57 /**
58 * Constructs an SSL socket factory.
59 */
60 SSLSocketFactoryImpl(SSLContextImpl context) {
61 this.context = context;
62 }
63
64 /**
65 * Creates an unconnected socket.
66 *
163 */
164 @Override
165 public Socket createSocket(InetAddress address, int port,
166 InetAddress clientAddress, int clientPort)
167 throws IOException
168 {
169 return new SSLSocketImpl(context, address, port,
170 clientAddress, clientPort);
171 }
172
173
174 /**
175 * Returns the subset of the supported cipher suites which are
176 * enabled by default. These cipher suites all provide a minimum
177 * quality of service whereby the server authenticates itself
178 * (preventing person-in-the-middle attacks) and where traffic
179 * is encrypted to provide confidentiality.
180 */
181 @Override
182 public String[] getDefaultCipherSuites() {
183 return context.getDefaultCipherSuiteList(false).toStringArray();
184 }
185
186 /**
187 * Returns the names of the cipher suites which could be enabled for use
188 * on an SSL connection. Normally, only a subset of these will actually
189 * be enabled by default, since this list may include cipher suites which
190 * do not support the mutual authentication of servers and clients, or
191 * which do not protect data confidentiality. Servers may also need
192 * certain kinds of certificates to use certain cipher suites.
193 */
194 @Override
195 public String[] getSupportedCipherSuites() {
196 return context.getSupportedCipherSuiteList().toStringArray();
197 }
198 }
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
26 package sun.security.ssl;
27
28 import java.io.*;
29 import java.net.*;
30 import javax.net.ssl.SSLSocketFactory;
31
32
33 /**
34 * Implementation of an SSL socket factory. This provides the public
35 * hooks to create SSL sockets, using a "high level" programming
36 * interface which encapsulates system security policy defaults rather than
37 * offering application flexibility. In particular, it uses a configurable
38 * authentication context (and the keys held there) rather than offering
39 * any flexibility about which keys to use; that context defaults to the
40 * process-default context, but may be explicitly specified.
41 *
42 * @author David Brownell
43 */
44 public final class SSLSocketFactoryImpl extends SSLSocketFactory {
45
46 private final SSLContextImpl context;
47
48 /**
49 * Constructor used to instantiate the default factory. This method is
50 * only called if the old "ssl.SocketFactory.provider" property in the
51 * java.security file is set.
52 */
53 public SSLSocketFactoryImpl() throws Exception {
54 this.context = SSLContextImpl.DefaultSSLContext.getDefaultImpl();
55 }
56
57 /**
58 * Constructs an SSL socket factory.
59 */
60 SSLSocketFactoryImpl(SSLContextImpl context) {
61 this.context = context;
62 }
63
64 /**
65 * Creates an unconnected socket.
66 *
163 */
164 @Override
165 public Socket createSocket(InetAddress address, int port,
166 InetAddress clientAddress, int clientPort)
167 throws IOException
168 {
169 return new SSLSocketImpl(context, address, port,
170 clientAddress, clientPort);
171 }
172
173
174 /**
175 * Returns the subset of the supported cipher suites which are
176 * enabled by default. These cipher suites all provide a minimum
177 * quality of service whereby the server authenticates itself
178 * (preventing person-in-the-middle attacks) and where traffic
179 * is encrypted to provide confidentiality.
180 */
181 @Override
182 public String[] getDefaultCipherSuites() {
183 return CipherSuite.namesOf(context.getDefaultCipherSuites(false));
184 }
185
186 /**
187 * Returns the names of the cipher suites which could be enabled for use
188 * on an SSL connection. Normally, only a subset of these will actually
189 * be enabled by default, since this list may include cipher suites which
190 * do not support the mutual authentication of servers and clients, or
191 * which do not protect data confidentiality. Servers may also need
192 * certain kinds of certificates to use certain cipher suites.
193 */
194 @Override
195 public String[] getSupportedCipherSuites() {
196 return CipherSuite.namesOf(context.getSupportedCipherSuites());
197 }
198 }
|