src/java.base/share/classes/javax/net/ssl/X509KeyManager.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 38873 jdk/src/java.base/share/classes/javax/net/ssl/X509KeyManager.java@0d1f3f5d7898
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
38873
0d1f3f5d7898 8157925: Typo in the API documentation of X509KeyManager
jnimeh
parents: 25859
diff changeset
     2
 * Copyright (c) 1999, 2016, 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.PrivateKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.cert.X509Certificate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.net.Socket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Instances of this interface manage which X509 certificate-based
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * key pairs are used to authenticate the local side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <P>
38873
0d1f3f5d7898 8157925: Typo in the API documentation of X509KeyManager
jnimeh
parents: 25859
diff changeset
    38
 * During secure socket negotiations, implementations
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * call methods in this interface to:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <LI> determine the set of aliases that are available for negotiations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *      based on the criteria presented,
19602
b772e77c27c9 8023827: Fix doclint issues in javax.net.ssl
darcy
parents: 14514
diff changeset
    43
 * <LI> select the <i> best alias</i> based on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      the criteria presented, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <LI> obtain the corresponding key material for given aliases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Note: the X509ExtendedKeyManager should be used in favor of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public interface X509KeyManager extends KeyManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Get the matching aliases for authenticating the client side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @param keyType the key algorithm type name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param issuers the list of acceptable CA issuer subject names,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *          or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @return an array of the matching alias names, or null if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *          were no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public String[] getClientAliases(String keyType, Principal[] issuers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Choose an alias to authenticate the client side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param keyType the key algorithm type name(s), ordered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *          with the most-preferred key type first.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param issuers the list of acceptable CA issuer subject names
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *           or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param socket the socket to be used for this connection.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *          parameter can be null, which indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *          implementations are free to select an alias applicable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *          to any socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @return the alias name for the desired key, or null if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *          are no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public String chooseClientAlias(String[] keyType, Principal[] issuers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        Socket socket);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Get the matching aliases for authenticating the server side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param keyType the key algorithm type name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param issuers the list of acceptable CA issuer subject names
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *          or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @return an array of the matching alias names, or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *          if there were no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public String[] getServerAliases(String keyType, Principal[] issuers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Choose an alias to authenticate the server side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @param keyType the key algorithm type name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @param issuers the list of acceptable CA issuer subject names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *          or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @param socket the socket to be used for this connection.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *          parameter can be null, which indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *          implementations are free to select an alias applicable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *          to any socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @return the alias name for the desired key, or null if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *          are no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public String chooseServerAlias(String keyType, Principal[] issuers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        Socket socket);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Returns the certificate chain associated with the given alias.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @param alias the alias name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @return the certificate chain (ordered with the user's certificate first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *          and the root certificate authority last), or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *          if the alias can't be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public X509Certificate[] getCertificateChain(String alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Returns the key associated with the given alias.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param alias the alias name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @return the requested key, or null if the alias can't be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public PrivateKey getPrivateKey(String alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
}