2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
|
2
|
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
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
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 |
*
|
5506
|
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
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
package sun.security.ssl;
|
|
27 |
|
|
28 |
import java.io.IOException;
|
|
29 |
import java.net.InetAddress;
|
|
30 |
import java.net.ServerSocket;
|
|
31 |
|
|
32 |
import javax.net.ssl.SSLServerSocketFactory;
|
|
33 |
|
|
34 |
/**
|
|
35 |
* This class creates SSL server sockets.
|
|
36 |
*
|
|
37 |
* @author David Brownell
|
|
38 |
*/
|
|
39 |
final
|
|
40 |
public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory
|
|
41 |
{
|
|
42 |
private static final int DEFAULT_BACKLOG = 50;
|
|
43 |
private SSLContextImpl context;
|
|
44 |
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Constructor used to instantiate the default factory. This method is
|
|
48 |
* only called if the old "ssl.ServerSocketFactory.provider" property in the
|
|
49 |
* java.security file is set.
|
|
50 |
*/
|
|
51 |
public SSLServerSocketFactoryImpl() throws Exception {
|
|
52 |
this.context = DefaultSSLContextImpl.getDefaultImpl();
|
|
53 |
}
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Called from SSLContextImpl's getSSLServerSocketFactory().
|
|
57 |
*/
|
|
58 |
SSLServerSocketFactoryImpl (SSLContextImpl context)
|
|
59 |
{
|
|
60 |
this.context = context;
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Returns an unbound server socket.
|
|
65 |
*
|
|
66 |
* @return the unbound socket
|
|
67 |
* @throws IOException if the socket cannot be created
|
|
68 |
* @see java.net.Socket#bind(java.net.SocketAddress)
|
|
69 |
*/
|
|
70 |
public ServerSocket createServerSocket() throws IOException {
|
|
71 |
return new SSLServerSocketImpl(context);
|
|
72 |
}
|
|
73 |
|
|
74 |
public ServerSocket createServerSocket (int port)
|
|
75 |
throws IOException
|
|
76 |
{
|
|
77 |
return new SSLServerSocketImpl (port, DEFAULT_BACKLOG, context);
|
|
78 |
}
|
|
79 |
|
|
80 |
|
|
81 |
public ServerSocket createServerSocket (int port, int backlog)
|
|
82 |
throws IOException
|
|
83 |
{
|
|
84 |
return new SSLServerSocketImpl (port, backlog, context);
|
|
85 |
}
|
|
86 |
|
|
87 |
public ServerSocket
|
|
88 |
createServerSocket (int port, int backlog, InetAddress ifAddress)
|
|
89 |
throws IOException
|
|
90 |
{
|
|
91 |
return new SSLServerSocketImpl (port, backlog, ifAddress, context);
|
|
92 |
}
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Returns the subset of the supported cipher suites which are
|
|
96 |
* enabled by default. These cipher suites all provide a minimum
|
|
97 |
* quality of service whereby the server authenticates itself
|
|
98 |
* (preventing person-in-the-middle attacks) and where traffic
|
|
99 |
* is encrypted to provide confidentiality.
|
|
100 |
*/
|
|
101 |
public String[] getDefaultCipherSuites() {
|
|
102 |
CipherSuiteList.clearAvailableCache();
|
|
103 |
return CipherSuiteList.getDefault().toStringArray();
|
|
104 |
}
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Returns the names of the cipher suites which could be enabled for use
|
|
108 |
* on an SSL connection. Normally, only a subset of these will actually
|
|
109 |
* be enabled by default, since this list may include cipher suites which
|
|
110 |
* do not support the mutual authentication of servers and clients, or
|
|
111 |
* which do not protect data confidentiality. Servers may also need
|
|
112 |
* certain kinds of certificates to use certain cipher suites.
|
|
113 |
*
|
|
114 |
* @return an array of cipher suite names
|
|
115 |
*/
|
|
116 |
public String[] getSupportedCipherSuites() {
|
|
117 |
CipherSuiteList.clearAvailableCache();
|
|
118 |
return CipherSuiteList.getSupported().toStringArray();
|
|
119 |
}
|
|
120 |
|
|
121 |
}
|