1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
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. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
26 package sun.security.ssl; |
26 package sun.security.ssl; |
27 |
27 |
28 import java.io.IOException; |
28 import java.io.IOException; |
29 import java.net.InetAddress; |
29 import java.net.InetAddress; |
30 import java.net.ServerSocket; |
30 import java.net.ServerSocket; |
31 |
|
32 import javax.net.ssl.SSLServerSocketFactory; |
31 import javax.net.ssl.SSLServerSocketFactory; |
33 |
32 |
34 /** |
33 /** |
35 * This class creates SSL server sockets. |
34 * This class creates SSL server sockets. |
36 * |
35 * |
37 * @author David Brownell |
36 * @author David Brownell |
38 */ |
37 */ |
39 final |
38 public final class SSLServerSocketFactoryImpl extends SSLServerSocketFactory { |
40 public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory |
|
41 { |
|
42 private static final int DEFAULT_BACKLOG = 50; |
39 private static final int DEFAULT_BACKLOG = 50; |
43 private SSLContextImpl context; |
40 private final SSLContextImpl context; |
44 |
41 |
45 |
42 |
46 /** |
43 /** |
47 * Constructor used to instantiate the default factory. This method is |
44 * Constructor used to instantiate the default factory. This method is |
48 * only called if the old "ssl.ServerSocketFactory.provider" property in the |
45 * only called if the old "ssl.ServerSocketFactory.provider" property in the |
71 public ServerSocket createServerSocket() throws IOException { |
67 public ServerSocket createServerSocket() throws IOException { |
72 return new SSLServerSocketImpl(context); |
68 return new SSLServerSocketImpl(context); |
73 } |
69 } |
74 |
70 |
75 @Override |
71 @Override |
76 public ServerSocket createServerSocket (int port) |
72 public ServerSocket createServerSocket(int port) throws IOException { |
77 throws IOException |
73 return new SSLServerSocketImpl(context, port, DEFAULT_BACKLOG); |
78 { |
|
79 return new SSLServerSocketImpl (port, DEFAULT_BACKLOG, context); |
|
80 } |
74 } |
81 |
75 |
82 |
76 |
83 @Override |
77 @Override |
84 public ServerSocket createServerSocket (int port, int backlog) |
78 public ServerSocket createServerSocket ( |
85 throws IOException |
79 int port, int backlog) throws IOException { |
86 { |
80 return new SSLServerSocketImpl(context, port, backlog); |
87 return new SSLServerSocketImpl (port, backlog, context); |
|
88 } |
81 } |
89 |
82 |
90 @Override |
83 @Override |
91 public ServerSocket |
84 public ServerSocket |
92 createServerSocket (int port, int backlog, InetAddress ifAddress) |
85 createServerSocket (int port, |
93 throws IOException |
86 int backlog, InetAddress ifAddress) throws IOException { |
94 { |
87 return new SSLServerSocketImpl(context, port, backlog, ifAddress); |
95 return new SSLServerSocketImpl (port, backlog, ifAddress, context); |
|
96 } |
88 } |
97 |
89 |
98 /** |
90 /** |
99 * Returns the subset of the supported cipher suites which are |
91 * Returns the subset of the supported cipher suites which are |
100 * enabled by default. These cipher suites all provide a minimum |
92 * enabled by default. These cipher suites all provide a minimum |
102 * (preventing person-in-the-middle attacks) and where traffic |
94 * (preventing person-in-the-middle attacks) and where traffic |
103 * is encrypted to provide confidentiality. |
95 * is encrypted to provide confidentiality. |
104 */ |
96 */ |
105 @Override |
97 @Override |
106 public String[] getDefaultCipherSuites() { |
98 public String[] getDefaultCipherSuites() { |
107 return context.getDefaultCipherSuiteList(true).toStringArray(); |
99 return CipherSuite.namesOf(context.getDefaultCipherSuites(true)); |
108 } |
100 } |
109 |
101 |
110 /** |
102 /** |
111 * Returns the names of the cipher suites which could be enabled for use |
103 * Returns the names of the cipher suites which could be enabled for use |
112 * on an SSL connection. Normally, only a subset of these will actually |
104 * on an SSL connection. Normally, only a subset of these will actually |