Path: blob/master/src/java.base/share/classes/javax/net/ssl/X509KeyManager.java
41159 views
/*1* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.net.ssl;2627import java.security.PrivateKey;28import java.security.Principal;29import java.security.cert.X509Certificate;30import java.net.Socket;3132/**33* Instances of this interface manage which X509 certificate-based34* key pairs are used to authenticate the local side of a secure35* socket.36* <P>37* During secure socket negotiations, implementations38* call methods in this interface to:39* <UL>40* <LI> determine the set of aliases that are available for negotiations41* based on the criteria presented,42* <LI> select the <i> best alias</i> based on43* the criteria presented, and44* <LI> obtain the corresponding key material for given aliases.45* </UL>46* <P>47* Note: the X509ExtendedKeyManager should be used in favor of this48* class.49*50* @since 1.451*/52public interface X509KeyManager extends KeyManager {53/**54* Get the matching aliases for authenticating the client side of a secure55* socket given the public key type and the list of56* certificate issuer authorities recognized by the peer (if any).57*58* @param keyType the key algorithm type name59* @param issuers the list of acceptable CA issuer subject names,60* or null if it does not matter which issuers are used.61* @return an array of the matching alias names, or null if there62* were no matches.63*/64public String[] getClientAliases(String keyType, Principal[] issuers);6566/**67* Choose an alias to authenticate the client side of a secure68* socket given the public key type and the list of69* certificate issuer authorities recognized by the peer (if any).70*71* @param keyType the key algorithm type name(s), ordered72* with the most-preferred key type first.73* @param issuers the list of acceptable CA issuer subject names74* or null if it does not matter which issuers are used.75* @param socket the socket to be used for this connection. This76* parameter can be null, which indicates that77* implementations are free to select an alias applicable78* to any socket.79* @return the alias name for the desired key, or null if there80* are no matches.81*/82public String chooseClientAlias(String[] keyType, Principal[] issuers,83Socket socket);8485/**86* Get the matching aliases for authenticating the server side of a secure87* socket given the public key type and the list of88* certificate issuer authorities recognized by the peer (if any).89*90* @param keyType the key algorithm type name91* @param issuers the list of acceptable CA issuer subject names92* or null if it does not matter which issuers are used.93* @return an array of the matching alias names, or null94* if there were no matches.95*/96public String[] getServerAliases(String keyType, Principal[] issuers);9798/**99* Choose an alias to authenticate the server side of a secure100* socket given the public key type and the list of101* certificate issuer authorities recognized by the peer (if any).102*103* @param keyType the key algorithm type name.104* @param issuers the list of acceptable CA issuer subject names105* or null if it does not matter which issuers are used.106* @param socket the socket to be used for this connection. This107* parameter can be null, which indicates that108* implementations are free to select an alias applicable109* to any socket.110* @return the alias name for the desired key, or null if there111* are no matches.112*/113public String chooseServerAlias(String keyType, Principal[] issuers,114Socket socket);115116/**117* Returns the certificate chain associated with the given alias.118*119* @param alias the alias name120* @return the certificate chain (ordered with the user's certificate first121* and the root certificate authority last), or null122* if the alias can't be found.123*/124public X509Certificate[] getCertificateChain(String alias);125126/**127* Returns the key associated with the given alias.128*129* @param alias the alias name130* @return the requested key, or null if the alias can't be found.131*/132public PrivateKey getPrivateKey(String alias);133}134135136