src/java.base/share/classes/javax/net/ssl/SSLSession.java
author xuelei
Wed, 13 Mar 2019 07:14:50 -0700
changeset 54099 fd332722014c
parent 53131 e412d5c096bc
permissions -rw-r--r--
8160247: Mark deprecated javax.security.cert APIs with forRemoval=true Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
53131
e412d5c096bc 8179943: Typo in javax.net.ssl.SSLSession.removeValue(String) method documentation
coffeys
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2019, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
package javax.net.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * In SSL, sessions are used to describe an ongoing relationship between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * two entities.  Each SSL connection involves one session at a time, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * that session may be used on many connections between those entities,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * simultaneously or sequentially.  The session used on a connection may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * also be replaced by a different session.  Sessions are created, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * rejoined, as part of the SSL handshaking protocol. Sessions may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * invalidated due to policies affecting security or resource usage,
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
    38
 * or by an application explicitly calling {@code invalidate}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Session management policies are typically used to tune performance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <P> In addition to the standard session attributes, SSL sessions expose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * these read-only attributes:  <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      <LI> <em>Peer Identity.</em>  Sessions are between a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      client and a particular server.  The identity of the peer may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *      have been established as part of session setup.  Peers are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      generally identified by X.509 certificate chains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *      <LI> <em>Cipher Suite Name.</em>  Cipher suites describe the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *      kind of cryptographic protection that's used by connections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *      in a particular session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *      <LI> <em>Peer Host.</em>  All connections in a session are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *      between the same two hosts.  The address of the host on the other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *      side of the connection is available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *      </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <P> Sessions may be explicitly invalidated.  Invalidation may also
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * be done implicitly, when faced with certain kinds of errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @author David Brownell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
public interface SSLSession {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Returns the identifier assigned to this Session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @return the Session identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public byte[] getId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Returns the context in which this session is bound.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * This context may be unavailable in some environments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * in which case this method returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * If the context is available and there is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * security manager installed, the caller may require
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * permission to access it or a security exception may be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * In a Java environment, the security manager's
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
    85
     * {@code checkPermission} method is called with a
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
    86
     * {@code SSLPermission("getSSLSessionContext")} permission.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @throws SecurityException if the calling thread does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *         permission to get SSL session context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @return the session context used for this session, or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * if the context is unavailable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public SSLSessionContext getSessionContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Returns the time at which this Session representation was created,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * in milliseconds since midnight, January 1, 1970 UTC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @return the time this Session was created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public long getCreationTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Returns the last time this Session representation was accessed by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * session level infrastructure, in milliseconds since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * midnight, January 1, 1970 UTC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Access indicates a new connection being established using session data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Application level operations, such as getting or setting a value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * associated with the session, are not reflected in this access time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <P> This information is particularly useful in session management
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * policies.  For example, a session manager thread could leave all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * sessions in a given context which haven't been used in a long time;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * or, the sessions might be sorted according to age to optimize some task.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @return the last time this Session was accessed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public long getLastAccessedTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Invalidates the session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Future connections will not be able to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * resume or join this session.  However, any existing connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * using this session can continue to use the session until the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * connection is closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @see #isValid()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public void invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Returns whether this session is valid and available for resuming or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * joining.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @return true if this session may be rejoined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @see #invalidate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public boolean isValid();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   151
     * Binds the specified {@code value} object into the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * session's application layer data
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   153
     * with the given {@code name}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * <P>
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   155
     * Any existing binding using the same {@code name} is
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   156
     * replaced.  If the new (or existing) {@code value} implements the
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   157
     * {@code SSLSessionBindingListener} interface, the object
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   158
     * represented by {@code value} is notified appropriately.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * For security reasons, the same named values may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * visible across different access control contexts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param name the name to which the data object will be bound.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *          This may not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param value the data object to be bound. This may not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @throws IllegalArgumentException if either argument is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public void putValue(String name, Object value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Returns the object bound to the given name in the session's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * application layer data.  Returns null if there is no such binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * For security reasons, the same named values may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * visible across different access control contexts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @param name the name of the binding to find.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @return the value bound to that name, or null if the binding does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *          not exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @throws IllegalArgumentException if the argument is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public Object getValue(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Removes the object bound to the given name in the session's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * application layer data.  Does nothing if there is no object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * bound to the given name.  If the bound existing object
53131
e412d5c096bc 8179943: Typo in javax.net.ssl.SSLSession.removeValue(String) method documentation
coffeys
parents: 47216
diff changeset
   190
     * implements the {@code SSLSessionBindingListener} interface,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * it is notified appropriately.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * For security reasons, the same named values may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * visible across different access control contexts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @param name the name of the object to remove visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *          across different access control contexts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @throws IllegalArgumentException if the argument is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public void removeValue(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * Returns an array of the names of all the application layer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * data objects bound into the Session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * For security reasons, the same named values may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * visible across different access control contexts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @return a non-null (possibly empty) array of names of the objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *  bound to this Session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public String [] getValueNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Returns the identity of the peer which was established as part
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * of defining the session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Note: This method can be used only when using certificate-based
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * cipher suites; using it with non-certificate-based cipher suites,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * such as Kerberos, will throw an SSLPeerUnverifiedException.
43195
e7f80841643d 8151465: SSLSession may not return a valid chain
xuelei
parents: 39828
diff changeset
   222
     * <P>
e7f80841643d 8151465: SSLSession may not return a valid chain
xuelei
parents: 39828
diff changeset
   223
     * Note: The returned value may not be a valid certificate chain
e7f80841643d 8151465: SSLSession may not return a valid chain
xuelei
parents: 39828
diff changeset
   224
     * and should not be relied on for trust decisions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @return an ordered array of peer certificates,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *          with the peer's own certificate first followed by any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *          certificate authorities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @exception SSLPeerUnverifiedException if the peer's identity has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *          been verified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @see #getPeerPrincipal()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    public java.security.cert.Certificate [] getPeerCertificates()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            throws SSLPeerUnverifiedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Returns the certificate(s) that were sent to the peer during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * handshaking.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * Note: This method is useful only when using certificate-based
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * cipher suites.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * When multiple certificates are available for use in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * handshake, the implementation chooses what it considers the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * "best" certificate chain available, and transmits that to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * the other side.  This method allows the caller to know
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * which certificate chain was actually used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @return an ordered array of certificates,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * with the local certificate first followed by any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * certificate authorities.  If no certificates were sent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * then null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @see #getLocalPrincipal()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public java.security.cert.Certificate [] getLocalCertificates();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Returns the identity of the peer which was identified as part
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * of defining the session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Note: This method can be used only when using certificate-based
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * cipher suites; using it with non-certificate-based cipher suites,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * such as Kerberos, will throw an SSLPeerUnverifiedException.
43195
e7f80841643d 8151465: SSLSession may not return a valid chain
xuelei
parents: 39828
diff changeset
   265
     * <P>
e7f80841643d 8151465: SSLSession may not return a valid chain
xuelei
parents: 39828
diff changeset
   266
     * Note: The returned value may not be a valid certificate chain
e7f80841643d 8151465: SSLSession may not return a valid chain
xuelei
parents: 39828
diff changeset
   267
     * and should not be relied on for trust decisions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * <p><em>Note: this method exists for compatibility with previous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * releases. New applications should use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * {@link #getPeerCertificates} instead.</em></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @return an ordered array of peer X.509 certificates,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *          with the peer's own certificate first followed by any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *          certificate authorities.  (The certificates are in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *          the original JSSE certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *          {@link javax.security.cert.X509Certificate} format.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @exception SSLPeerUnverifiedException if the peer's identity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *          has not been verified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @see #getPeerPrincipal()
29377
d3f457ce9c48 8073430: Deprecate security APIs that have been superseded
juh
parents: 25859
diff changeset
   281
     * @deprecated The {@link #getPeerCertificates()} method that returns an
43541
9aeb1de77a63 8173827: Remove forRemoval=true from several deprecated security APIs
mullan
parents: 43195
diff changeset
   282
     *               array of {@code java.security.cert.Certificate} should
9aeb1de77a63 8173827: Remove forRemoval=true from several deprecated security APIs
mullan
parents: 43195
diff changeset
   283
     *               be used instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
54099
fd332722014c 8160247: Mark deprecated javax.security.cert APIs with forRemoval=true
xuelei
parents: 53131
diff changeset
   285
    @SuppressWarnings("removal")
fd332722014c 8160247: Mark deprecated javax.security.cert APIs with forRemoval=true
xuelei
parents: 53131
diff changeset
   286
    @Deprecated(since="9", forRemoval=true)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public javax.security.cert.X509Certificate [] getPeerCertificateChain()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            throws SSLPeerUnverifiedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Returns the identity of the peer which was established as part of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * defining the session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @return the peer's principal. Returns an X500Principal of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * end-entity certiticate for X509-based cipher suites, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * KerberosPrincipal for Kerberos cipher suites.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @throws SSLPeerUnverifiedException if the peer's identity has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *          been verified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @see #getPeerCertificates()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @see #getLocalPrincipal()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public Principal getPeerPrincipal()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            throws SSLPeerUnverifiedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * Returns the principal that was sent to the peer during handshaking.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @return the principal sent to the peer. Returns an X500Principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * of the end-entity certificate for X509-based cipher suites, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * KerberosPrincipal for Kerberos cipher suites. If no principal was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * sent, then null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @see #getLocalCertificates()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @see #getPeerPrincipal()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public Principal getLocalPrincipal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Returns the name of the SSL cipher suite which is used for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * connections in the session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * <P> This defines the level of protection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * provided to the data sent on the connection, including the kind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * of encryption used and most aspects of how authentication is done.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @return the name of the session's cipher suite
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public String getCipherSuite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * Returns the standard name of the protocol used for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * connections in the session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * <P> This defines the protocol used in the connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @return the standard name of the protocol used for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * connections in the session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    public String getProtocol();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * Returns the host name of the peer in this session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * For the server, this is the client's host;  and for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * the client, it is the server's host. The name may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * a fully qualified host name or even a host name at all as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * it may represent a string encoding of the peer's network address.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * If such a name is desired, it might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * be resolved through a name service based on the value returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * by this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * This value is not authenticated and should not be relied upon.
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   359
     * It is mainly used as a hint for {@code SSLSession} caching
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * strategies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @return  the host name of the peer host, or null if no information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *          is available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public String getPeerHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * Returns the port number of the peer in this session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * For the server, this is the client's port number;  and for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * the client, it is the server's port number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * This value is not authenticated and should not be relied upon.
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   374
     * It is mainly used as a hint for {@code SSLSession} caching
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * strategies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @return  the port number of the peer host, or -1 if no information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     *          is available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public int getPeerPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   385
     * Gets the current size of the largest SSL/TLS/DTLS packet that is
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   386
     * expected when using this session.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * <P>
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   388
     * An {@code SSLEngine} using this session may generate SSL/TLS/DTLS
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * packets of any size up to and including the value returned by this
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   390
     * method. All {@code SSLEngine} network buffers should be sized
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * at least this large to avoid insufficient space problems when
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   392
     * performing {@code wrap} and {@code unwrap} calls.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @return  the current maximum expected network packet size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @see SSLEngine#wrap(ByteBuffer, ByteBuffer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @see SSLEngine#unwrap(ByteBuffer, ByteBuffer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public int getPacketBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * Gets the current size of the largest application data that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * expected when using this session.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * <P>
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29377
diff changeset
   408
     * {@code SSLEngine} application data buffers must be large
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * enough to hold the application data from any inbound network
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * application data packet received.  Typically, outbound
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * application data buffers can be of any size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return  the current maximum expected application packet size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see SSLEngine#wrap(ByteBuffer, ByteBuffer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @see SSLEngine#unwrap(ByteBuffer, ByteBuffer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public int getApplicationBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
}