Path: blob/master/src/java.base/share/classes/javax/net/ssl/X509TrustManager.java
41159 views
/*1* Copyright (c) 1999, 2005, 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.cert.*;2829/**30* Instance of this interface manage which X509 certificates31* may be used to authenticate the remote side of a secure32* socket. Decisions may be based on trusted certificate33* authorities, certificate revocation lists, online34* status checking or other means.35*36* @since 1.437*/38public interface X509TrustManager extends TrustManager {39/**40* Given the partial or complete certificate chain provided by the41* peer, build a certificate path to a trusted root and return if42* it can be validated and is trusted for client SSL43* authentication based on the authentication type.44* <p>45* The authentication type is determined by the actual certificate46* used. For instance, if RSAPublicKey is used, the authType47* should be "RSA". Checking is case-sensitive.48*49* @param chain the peer certificate chain50* @param authType the authentication type based on the client certificate51* @throws IllegalArgumentException if null or zero-length chain52* is passed in for the chain parameter or if null or zero-length53* string is passed in for the authType parameter54* @throws CertificateException if the certificate chain is not trusted55* by this TrustManager.56*/57public void checkClientTrusted(X509Certificate[] chain, String authType)58throws CertificateException;5960/**61* Given the partial or complete certificate chain provided by the62* peer, build a certificate path to a trusted root and return if63* it can be validated and is trusted for server SSL64* authentication based on the authentication type.65* <p>66* The authentication type is the key exchange algorithm portion67* of the cipher suites represented as a String, such as "RSA",68* "DHE_DSS". Note: for some exportable cipher suites, the key69* exchange algorithm is determined at run time during the70* handshake. For instance, for TLS_RSA_EXPORT_WITH_RC4_40_MD5,71* the authType should be RSA_EXPORT when an ephemeral RSA key is72* used for the key exchange, and RSA when the key from the server73* certificate is used. Checking is case-sensitive.74*75* @param chain the peer certificate chain76* @param authType the key exchange algorithm used77* @throws IllegalArgumentException if null or zero-length chain78* is passed in for the chain parameter or if null or zero-length79* string is passed in for the authType parameter80* @throws CertificateException if the certificate chain is not trusted81* by this TrustManager.82*/83public void checkServerTrusted(X509Certificate[] chain, String authType)84throws CertificateException;8586/**87* Return an array of certificate authority certificates88* which are trusted for authenticating peers.89*90* @return a non-null (possibly empty) array of acceptable91* CA issuer certificates.92*/93public X509Certificate[] getAcceptedIssuers();94}959697