GNU Classpath (0.20) | |
Frames | No Frames |
1: /* PKIXCertPathChecker.java -- checks X.509 certificate paths. 2: Copyright (C) 2003 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package java.security.cert; 40: 41: import java.util.Collection; 42: import java.util.Set; 43: 44: /** 45: * A validator for X.509 certificates when approving certificate chains. 46: * 47: * <p>Concrete subclasses can be passed to the {@link 48: * PKIXParameters#setCertPathCheckers(java.util.List)} and {@link 49: * PKIXParameters#addCertPathChecker(java.security.cert.PKIXCertPathChecker} 50: * methods, which are then used to set up PKIX certificate chain 51: * builders or validators. These classes then call the {@link 52: * #check(java.security.cert.Certificate,java.util.Collection)} method 53: * of this class, performing whatever checks on the certificate, 54: * throwing an exception if any check fails. 55: * 56: * <p>Subclasses of this must be able to perform their checks in the 57: * backward direction -- from the most-trusted certificate to the target 58: * -- and may optionally support forward checking -- from the target to 59: * the most-trusted certificate. 60: * 61: * @see PKIXParameters 62: */ 63: public abstract class PKIXCertPathChecker implements Cloneable 64: { 65: 66: // Constructor. 67: // ------------------------------------------------------------------------ 68: 69: /** Default constructor. */ 70: protected PKIXCertPathChecker() 71: { 72: super(); 73: } 74: 75: // Cloneable interface. 76: // ------------------------------------------------------------------------ 77: 78: public Object clone() 79: { 80: try 81: { 82: return super.clone(); 83: } 84: catch (CloneNotSupportedException cnse) 85: { 86: throw new InternalError(cnse.getMessage()); 87: } 88: } 89: 90: // Abstract methods. 91: // ------------------------------------------------------------------------ 92: 93: /** 94: * Initialize this PKIXCertPathChecker. If subclasses support forward 95: * checking, a value of true can be passed to this method, and 96: * certificates can be validated from the target certificate to the 97: * most-trusted certifcate. 98: * 99: * @param forward The direction of this PKIXCertPathChecker. 100: * @throws CertPathValidatorException If <i>forward</i> is true and 101: * this class does not support forward checking. 102: */ 103: public abstract void init(boolean forward) throws CertPathValidatorException; 104: 105: /** 106: * Returns whether or not this class supports forward checking. 107: * 108: * @return Whether or not this class supports forward checking. 109: */ 110: public abstract boolean isForwardCheckingSupported(); 111: 112: /** 113: * Returns an immutable set of X.509 extension object identifiers (OIDs) 114: * supported by this PKIXCertPathChecker. 115: * 116: * @return An immutable set of Strings of the supported X.509 OIDs, or 117: * null if no extensions are supported. 118: */ 119: public abstract Set getSupportedExtensions(); 120: 121: /** 122: * Checks a certificate, removing any critical extensions that are 123: * resolved in this check. 124: * 125: * @param cert The certificate to check. 126: * @param unresolvedCritExts The (mutable) collection of as-of-yet 127: * unresolved critical extensions, as OID strings. 128: * @throws CertPathValidatorException If this certificate fails this 129: * check. 130: */ 131: public abstract void check(Certificate cert, Collection unresolvedCritExts) 132: throws CertPathValidatorException; 133: }
GNU Classpath (0.20) |