src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java
author igerasim
Sat, 15 Sep 2018 22:02:08 -0700
changeset 51759 ac6e9a2ebc04
parent 47216 71c04702a3d5
permissions -rw-r--r--
8210786: Typo s/overriden/overridden/ in several places Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
51759
ac6e9a2ebc04 8210786: Typo s/overriden/overridden/ in several places
igerasim
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package javax.net.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.net.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
45941
c864a5791b3a 8184316: Typo in javax.net.ssl.SSLServerSocket class documentation
xuelei
parents: 45118
diff changeset
    34
 * This class extends <code>ServerSocket</code> and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * provides secure server sockets using protocols such as the Secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Sockets Layer (SSL) or Transport Layer Security (TLS) protocols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <P>
45941
c864a5791b3a 8184316: Typo in javax.net.ssl.SSLServerSocket class documentation
xuelei
parents: 45118
diff changeset
    38
 * Instances of this class are generally created using an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <code>SSLServerSocketFactory</code>.  The primary function
45941
c864a5791b3a 8184316: Typo in javax.net.ssl.SSLServerSocket class documentation
xuelei
parents: 45118
diff changeset
    40
 * of an <code>SSLServerSocket</code>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * is to create <code>SSLSocket</code>s by <code>accept</code>ing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <P>
45941
c864a5791b3a 8184316: Typo in javax.net.ssl.SSLServerSocket class documentation
xuelei
parents: 45118
diff changeset
    44
 * An <code>SSLServerSocket</code> contains several pieces of state data
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * which are inherited by the <code>SSLSocket</code> at
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * socket creation.  These include the enabled cipher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * suites and protocols, whether client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * authentication is necessary, and whether created sockets should
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * begin handshaking in client or server mode.  The state
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * inherited by the created <code>SSLSocket</code> can be
51759
ac6e9a2ebc04 8210786: Typo s/overriden/overridden/ in several places
igerasim
parents: 47216
diff changeset
    51
 * overridden by calling the appropriate methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @see java.net.ServerSocket
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see SSLSocket
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @author David Brownell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
    59
public abstract class SSLServerSocket extends ServerSocket {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
    60
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Used only by subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Create an unbound TCP server socket using the default authentication
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @throws IOException if an I/O error occurs when creating the socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected SSLServerSocket()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        { super(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * Used only by subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Create a TCP server socket on a port, using the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * authentication context.  The connection backlog defaults to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * fifty connections queued up before the system starts to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * reject new connection requests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * A port number of <code>0</code> creates a socket on any free port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * If there is a security manager, its <code>checkListen</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * method is called with the <code>port</code> argument as its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * argument to ensure the operation is allowed. This could result
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param port the port on which to listen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @throws IOException if an I/O error occurs when creating the socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @throws SecurityException if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *         <code>checkListen</code> method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @throws IllegalArgumentException if the port parameter is outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *         specified range of valid port values, which is between 0 and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *         65535, inclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see    SecurityManager#checkListen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    protected SSLServerSocket(int port)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        { super(port); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Used only by subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Create a TCP server socket on a port, using the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * authentication context and a specified backlog of connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * A port number of <code>0</code> creates a socket on any free port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <P>
1096
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   111
     * The <code>backlog</code> argument is the requested maximum number of
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   112
     * pending connections on the socket. Its exact semantics are implementation
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   113
     * specific. In particular, an implementation may impose a maximum length
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   114
     * or may choose to ignore the parameter altogther. The value provided
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   115
     * should be greater than <code>0</code>. If it is less than or equal to
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   116
     * <code>0</code>, then an implementation specific default will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * If there is a security manager, its <code>checkListen</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * method is called with the <code>port</code> argument as its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * argument to ensure the operation is allowed. This could result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param port the port on which to listen
1096
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   124
     * @param backlog  requested maximum length of the queue of incoming
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   125
     *                  connections.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @throws IOException if an I/O error occurs when creating the socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @throws SecurityException if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *         <code>checkListen</code> method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @throws IllegalArgumentException if the port parameter is outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *         specified range of valid port values, which is between 0 and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *         65535, inclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @see    SecurityManager#checkListen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    protected SSLServerSocket(int port, int backlog)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        { super(port, backlog); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Used only by subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Create a TCP server socket on a port, using the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * authentication context and a specified backlog of connections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * as well as a particular specified network interface.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * constructor is used on multihomed hosts, such as those used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * for firewalls or as routers, to control through which interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * a network service is provided.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * If there is a security manager, its <code>checkListen</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * method is called with the <code>port</code> argument as its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * argument to ensure the operation is allowed. This could result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * A port number of <code>0</code> creates a socket on any free port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * <P>
1096
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   156
     * The <code>backlog</code> argument is the requested maximum number of
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   157
     * pending connections on the socket. Its exact semantics are implementation
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   158
     * specific. In particular, an implementation may impose a maximum length
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   159
     * or may choose to ignore the parameter altogther. The value provided
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   160
     * should be greater than <code>0</code>. If it is less than or equal to
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   161
     * <code>0</code>, then an implementation specific default will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * If <i>address</i> is null, it will default accepting connections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * on any/all local addresses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param port the port on which to listen
1096
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   167
     * @param backlog  requested maximum length of the queue of incoming
7906d13db4eb 6258215: Num of backlog in ServerSocket(int, int) should be mentioned more explicitly
michaelm
parents: 2
diff changeset
   168
     *                  connections.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param address the address of the network interface through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *          which connections will be accepted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @throws IOException if an I/O error occurs when creating the socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @throws SecurityException if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *         <code>checkListen</code> method doesn't allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @throws IllegalArgumentException if the port parameter is outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *         specified range of valid port values, which is between 0 and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *         65535, inclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @see    SecurityManager#checkListen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    protected SSLServerSocket(int port, int backlog, InetAddress address)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        { super(port, backlog, address); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Returns the list of cipher suites which are currently enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * for use by newly accepted connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * If this list has not been explicitly modified, a system-provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * default guarantees a minimum quality of service in all enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * cipher suites.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * <P>
36008
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   193
     * Note that even if a suite is enabled, it may never be used. This
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   194
     * can occur if the peer does not support it, or its use is restricted,
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   195
     * or the requisite certificates (and private keys) for the suite are
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   196
     * not available, or an anonymous suite is enabled but authentication
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   197
     * is required.
40411
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   198
     * <P>
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   199
     * The returned array includes cipher suites from the list of standard
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   200
     * cipher suite names in the <a href=
45118
e4258d800b54 8178278: Move Standard Algorithm Names document to specs directory
ihse
parents: 40411
diff changeset
   201
     * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names">
40411
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   202
     * JSSE Cipher Suite Names</a> section of the Java Cryptography
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   203
     * Architecture Standard Algorithm Name Documentation, and may also
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   204
     * include other cipher suites that the provider supports.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @return an array of cipher suites enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @see #getSupportedCipherSuites()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @see #setEnabledCipherSuites(String [])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public abstract String [] getEnabledCipherSuites();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Sets the cipher suites enabled for use by accepted connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * The cipher suites must have been listed by getSupportedCipherSuites()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * as being supported.  Following a successful call to this method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * only suites listed in the <code>suites</code> parameter are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * for use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Suites that require authentication information which is not available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * in this ServerSocket's authentication context will not be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * in any case, even if they are enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * <P>
40411
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   225
     * Note that the standard list of cipher suite names may be found in the
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   226
     * <a href=
45118
e4258d800b54 8178278: Move Standard Algorithm Names document to specs directory
ihse
parents: 40411
diff changeset
   227
     * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names">
40411
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   228
     * JSSE Cipher Suite Names</a> section of the Java Cryptography
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   229
     * Architecture Standard Algorithm Name Documentation.  Providers
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   230
     * may support cipher suite names not found in this list or might not
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   231
     * use the recommended name for a certain cipher suite.
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   232
     * <P>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * <code>SSLSocket</code>s returned from <code>accept()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * inherit this setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @param suites Names of all the cipher suites to enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @exception IllegalArgumentException when one or more of ciphers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *          named by the parameter is not supported, or when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *          the parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @see #getSupportedCipherSuites()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @see #getEnabledCipherSuites()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public abstract void setEnabledCipherSuites(String suites []);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * Returns the names of the cipher suites which could be enabled for use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * on an SSL connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Normally, only a subset of these will actually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * be enabled by default, since this list may include cipher suites which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * do not meet quality of service requirements for those defaults.  Such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * cipher suites are useful in specialized applications.
40411
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   254
     * <P>
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   255
     * The returned array includes cipher suites from the list of standard
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   256
     * cipher suite names in the <a href=
45118
e4258d800b54 8178278: Move Standard Algorithm Names document to specs directory
ihse
parents: 40411
diff changeset
   257
     * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names">
40411
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   258
     * JSSE Cipher Suite Names</a> section of the Java Cryptography
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   259
     * Architecture Standard Algorithm Name Documentation, and may also
e936d2ba0281 8162808: Add references to the standard JSSE cipher suite names in javadoc
jnimeh
parents: 36008
diff changeset
   260
     * include other cipher suites that the provider supports.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @return an array of cipher suite names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @see #getEnabledCipherSuites()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @see #setEnabledCipherSuites(String [])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public abstract String [] getSupportedCipherSuites();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * Returns the names of the protocols which could be enabled for use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @return an array of protocol names supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @see #getEnabledProtocols()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @see #setEnabledProtocols(String [])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    public abstract String [] getSupportedProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Returns the names of the protocols which are currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * enabled for use by the newly accepted connections.
36008
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   282
     * <P>
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   283
     * Note that even if a protocol is enabled, it may never be used.
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   284
     * This can occur if the peer does not support the protocol, or its
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   285
     * use is restricted, or there are no enabled cipher suites supported
3113bdef9cb1 8148500: [Spec] Enabled SSL Protocols may not be used
xuelei
parents: 25859
diff changeset
   286
     * by the protocol.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @return an array of protocol names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @see #getSupportedProtocols()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @see #setEnabledProtocols(String [])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public abstract String [] getEnabledProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * Controls which particular protocols are enabled for use by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * accepted connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * The protocols must have been listed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * getSupportedProtocols() as being supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * Following a successful call to this method, only protocols listed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * in the <code>protocols</code> parameter are enabled for use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * <code>SSLSocket</code>s returned from <code>accept()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * inherit this setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param protocols Names of all the protocols to enable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @exception IllegalArgumentException when one or more of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *            the protocols named by the parameter is not supported or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *            when the protocols parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @see #getEnabledProtocols()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @see #getSupportedProtocols()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    public abstract void setEnabledProtocols(String protocols[]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * Controls whether <code>accept</code>ed server-mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * <code>SSLSockets</code> will be initially configured to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * <i>require</i> client authentication.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * A socket's client authentication setting is one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * <li> client authentication required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * <li> client authentication requested
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * <li> no client authentication desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * Unlike {@link #setWantClientAuth(boolean)}, if the accepted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * socket's option is set and the client chooses not to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * authentication information about itself, <i>the negotiations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * will stop and the connection will be dropped</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * Calling this method overrides any previous setting made by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * this method or {@link #setWantClientAuth(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * The initial inherited setting may be overridden by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * {@link SSLSocket#setNeedClientAuth(boolean)} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * {@link SSLSocket#setWantClientAuth(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @param   need set to true if client authentication is required,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *          or false if no client authentication is desired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @see #getNeedClientAuth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @see #setWantClientAuth(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @see #getWantClientAuth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @see #setUseClientMode(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    public abstract void setNeedClientAuth(boolean need);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * Returns true if client authentication will be <i>required</i> on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * newly <code>accept</code>ed server-mode <code>SSLSocket</code>s.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * The initial inherited setting may be overridden by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * {@link SSLSocket#setNeedClientAuth(boolean)} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * {@link SSLSocket#setWantClientAuth(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @return  true if client authentication is required,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *          or false if no client authentication is desired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @see #setNeedClientAuth(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @see #setWantClientAuth(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @see #getWantClientAuth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @see #setUseClientMode(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public abstract boolean getNeedClientAuth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * Controls whether <code>accept</code>ed server-mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * <code>SSLSockets</code> will be initially configured to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * <i>request</i> client authentication.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * A socket's client authentication setting is one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * <li> client authentication required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * <li> client authentication requested
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * <li> no client authentication desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * Unlike {@link #setNeedClientAuth(boolean)}, if the accepted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * socket's option is set and the client chooses not to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * authentication information about itself, <i>the negotiations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * will continue</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * Calling this method overrides any previous setting made by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * this method or {@link #setNeedClientAuth(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * The initial inherited setting may be overridden by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * {@link SSLSocket#setNeedClientAuth(boolean)} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * {@link SSLSocket#setWantClientAuth(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @param   want set to true if client authentication is requested,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *          or false if no client authentication is desired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @see #getWantClientAuth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @see #setNeedClientAuth(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @see #getNeedClientAuth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @see #setUseClientMode(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    public abstract void setWantClientAuth(boolean want);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * Returns true if client authentication will be <i>requested</i> on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * newly accepted server-mode connections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * The initial inherited setting may be overridden by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * {@link SSLSocket#setNeedClientAuth(boolean)} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * {@link SSLSocket#setWantClientAuth(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @return  true if client authentication is requested,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *          or false if no client authentication is desired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @see #setWantClientAuth(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @see #setNeedClientAuth(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see #getNeedClientAuth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @see #setUseClientMode(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public abstract boolean getWantClientAuth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * Controls whether accepted connections are in the (default) SSL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * server mode, or the SSL client mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * Servers normally authenticate themselves, and clients are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * required to do so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * In rare cases, TCP servers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * need to act in the SSL client mode on newly accepted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * connections. For example, FTP clients acquire server sockets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * and listen there for reverse connections from the server. An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * FTP client would use an SSLServerSocket in "client" mode to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * accept the reverse connection while the FTP server uses an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * SSLSocket with "client" mode disabled to initiate the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * connection. During the resulting handshake, existing SSL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * sessions may be reused.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * <code>SSLSocket</code>s returned from <code>accept()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * inherit this setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * @param mode true if newly accepted connections should use SSL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     *          client mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @see #getUseClientMode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    public abstract void setUseClientMode(boolean mode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * Returns true if accepted connections will be in SSL client mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @see #setUseClientMode(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @return true if the connection should use SSL client mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    public abstract boolean getUseClientMode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * Controls whether new SSL sessions may be established by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * sockets which are created from this server socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * <code>SSLSocket</code>s returned from <code>accept()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * inherit this setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @param flag true indicates that sessions may be created; this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *          is the default. false indicates that an existing session
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *          must be resumed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * @see #getEnableSessionCreation()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    public abstract void setEnableSessionCreation(boolean flag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * Returns true if new SSL sessions may be established by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * sockets which are created from this server socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * @return true indicates that sessions may be created; this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     *          is the default.  false indicates that an existing
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   478
     *          session must be resumed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * @see #setEnableSessionCreation(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    public abstract boolean getEnableSessionCreation();
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   482
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   483
    /**
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   484
     * Returns the SSLParameters in effect for newly accepted connections.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   485
     * The ciphersuites and protocols of the returned SSLParameters
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   486
     * are always non-null.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   487
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   488
     * @return the SSLParameters in effect for newly accepted connections
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   489
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   490
     * @see #setSSLParameters(SSLParameters)
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   491
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   492
     * @since 1.7
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   493
     */
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   494
    public SSLParameters getSSLParameters() {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   495
        SSLParameters parameters = new SSLParameters();
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   496
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   497
        parameters.setCipherSuites(getEnabledCipherSuites());
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   498
        parameters.setProtocols(getEnabledProtocols());
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   499
        if (getNeedClientAuth()) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   500
            parameters.setNeedClientAuth(true);
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   501
        } else if (getWantClientAuth()) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   502
            parameters.setWantClientAuth(true);
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   503
        }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   504
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   505
        return parameters;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   506
    }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   507
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   508
    /**
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   509
     * Applies SSLParameters to newly accepted connections.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   510
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   511
     * <p>This means:
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   512
     * <ul>
14194
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   513
     * <li>If {@code params.getCipherSuites()} is non-null,
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   514
     *   {@code setEnabledCipherSuites()} is called with that value.</li>
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   515
     * <li>If {@code params.getProtocols()} is non-null,
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   516
     *   {@code setEnabledProtocols()} is called with that value.</li>
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   517
     * <li>If {@code params.getNeedClientAuth()} or
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   518
     *   {@code params.getWantClientAuth()} return {@code true},
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   519
     *   {@code setNeedClientAuth(true)} and
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   520
     *   {@code setWantClientAuth(true)} are called, respectively;
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   521
     *   otherwise {@code setWantClientAuth(false)} is called.</li>
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   522
     * <li>If {@code params.getServerNames()} is non-null, the socket will
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   523
     *   configure its server names with that value.</li>
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   524
     * <li>If {@code params.getSNIMatchers()} is non-null, the socket will
971f46db533d 7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents: 7043
diff changeset
   525
     *   configure its SNI matchers with that value.</li>
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   526
     * </ul>
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   527
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   528
     * @param params the parameters
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   529
     * @throws IllegalArgumentException if the setEnabledCipherSuites() or
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   530
     *    the setEnabledProtocols() call fails
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   531
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   532
     * @see #getSSLParameters()
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   533
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   534
     * @since 1.7
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   535
     */
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   536
    public void setSSLParameters(SSLParameters params) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   537
        String[] s;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   538
        s = params.getCipherSuites();
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   539
        if (s != null) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   540
            setEnabledCipherSuites(s);
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   541
        }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   542
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   543
        s = params.getProtocols();
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   544
        if (s != null) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   545
            setEnabledProtocols(s);
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   546
        }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   547
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   548
        if (params.getNeedClientAuth()) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   549
            setNeedClientAuth(true);
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   550
        } else if (params.getWantClientAuth()) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   551
            setWantClientAuth(true);
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   552
        } else {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   553
            setWantClientAuth(false);
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   554
        }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   555
    }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 5506
diff changeset
   556
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
}