jdk/src/share/classes/javax/net/ssl/X509KeyManager.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2004 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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.KeyManagementException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.PrivateKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.cert.X509Certificate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.net.Socket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Instances of this interface manage which X509 certificate-based
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * key pairs are used to authenticate the local side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * During secure socket negotiations, implentations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * call methods in this interface to:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <LI> determine the set of aliases that are available for negotiations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *      based on the criteria presented,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <LI> select the <ITALIC> best alias </ITALIC> based on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      the criteria presented, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <LI> obtain the corresponding key material for given aliases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Note: the X509ExtendedKeyManager should be used in favor of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
public interface X509KeyManager extends KeyManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Get the matching aliases for authenticating the client side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param keyType the key algorithm type name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @param issuers the list of acceptable CA issuer subject names,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *          or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @return an array of the matching alias names, or null if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *          were no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public String[] getClientAliases(String keyType, Principal[] issuers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Choose an alias to authenticate the client side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @param keyType the key algorithm type name(s), ordered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *          with the most-preferred key type first.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param issuers the list of acceptable CA issuer subject names
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *           or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @param socket the socket to be used for this connection.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *          parameter can be null, which indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *          implementations are free to select an alias applicable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *          to any socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @return the alias name for the desired key, or null if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *          are no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public String chooseClientAlias(String[] keyType, Principal[] issuers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        Socket socket);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Get the matching aliases for authenticating the server side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param keyType the key algorithm type name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param issuers the list of acceptable CA issuer subject names
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *          or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @return an array of the matching alias names, or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *          if there were no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public String[] getServerAliases(String keyType, Principal[] issuers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Choose an alias to authenticate the server side of a secure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * socket given the public key type and the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * certificate issuer authorities recognized by the peer (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @param keyType the key algorithm type name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param issuers the list of acceptable CA issuer subject names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *          or null if it does not matter which issuers are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param socket the socket to be used for this connection.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *          parameter can be null, which indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *          implementations are free to select an alias applicable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *          to any socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @return the alias name for the desired key, or null if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *          are no matches.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public String chooseServerAlias(String keyType, Principal[] issuers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        Socket socket);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Returns the certificate chain associated with the given alias.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param alias the alias name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @return the certificate chain (ordered with the user's certificate first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *          and the root certificate authority last), or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *          if the alias can't be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public X509Certificate[] getCertificateChain(String alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Returns the key associated with the given alias.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param alias the alias name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @return the requested key, or null if the alias can't be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public PrivateKey getPrivateKey(String alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
}