Path: blob/master/src/java.base/share/classes/sun/security/provider/certpath/UntrustedChecker.java
41161 views
/*1* Copyright (c) 2012, 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 sun.security.provider.certpath;2627import java.security.cert.Certificate;28import java.security.cert.X509Certificate;29import java.security.cert.CertPathValidatorException;30import java.security.cert.PKIXCertPathChecker;31import java.util.Set;32import java.util.Collection;33import sun.security.util.Debug;34import sun.security.util.UntrustedCertificates;3536/**37* A <code>PKIXCertPathChecker</code> implementation to check whether a38* specified certificate is distrusted.39*40* @see PKIXCertPathChecker41* @see PKIXParameters42*/43public final class UntrustedChecker extends PKIXCertPathChecker {4445private static final Debug debug = Debug.getInstance("certpath");4647/**48* Default Constructor49*/50public UntrustedChecker() {51// blank52}5354@Override55public void init(boolean forward) throws CertPathValidatorException {56// Note that this class supports both forward and reverse modes.57}5859@Override60public boolean isForwardCheckingSupported() {61// Note that this class supports both forward and reverse modes.62return true;63}6465@Override66public Set<String> getSupportedExtensions() {67return null;68}6970@Override71public void check(Certificate cert,72Collection<String> unresolvedCritExts)73throws CertPathValidatorException {7475X509Certificate currCert = (X509Certificate)cert;7677if (UntrustedCertificates.isUntrusted(currCert)) {78if (debug != null) {79debug.println("UntrustedChecker: untrusted certificate " +80currCert.getSubjectX500Principal());81}8283throw new CertPathValidatorException(84"Untrusted certificate: " + currCert.getSubjectX500Principal());85}86}87}88899091