⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pkixparameters.java

📁 gcc的JAVA模块的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* PKIXParameters.java -- parameters for the PKIX cert path algorithm   Copyright (C) 2003 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version. GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package java.security.cert;import java.security.InvalidAlgorithmParameterException;import java.security.KeyStore;import java.security.KeyStoreException;import java.util.Collections;import java.util.Date;import java.util.Enumeration;import java.util.HashSet;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Set;/** * Parameters for verifying certificate paths using the PKIX * (Public-Key Infrastructure (X.509)) algorithm. * * @see CertPathBulider */public class PKIXParameters implements CertPathParameters{  // Fields.  // ------------------------------------------------------------------------  /** The trusted certificates. */  private final Set trustAnchors;  /** The set of initial policy identifiers. */  private final Set initPolicies;  /** The list of certificate stores. */  private final List certStores;  /** The list of path checkers. */  private final List pathCheckers;  /** The revocation enabled flag. */  private boolean revocationEnabled;  /** The explicit policy required flag. */  private boolean exPolicyRequired;  /** The policy mapping inhibited flag. */  private boolean policyMappingInhibited;  /** The any policy inhibited flag. */  private boolean anyPolicyInhibited;  /** The policy qualifiers rejected flag. */  private boolean policyQualRejected;  /** The target validation date. */  private Date date;  /** The signature algorithm provider. */  private String sigProvider;  /** The target constraints. */  private CertSelector targetConstraints;  // Constructors.  // ------------------------------------------------------------------------  /**   * Create a new PKIXParameters object, populating the trusted   * certificates set with all certificates found in the given key   * store. All certificates found in the key store are assumed to be   * trusted by this constructor.   *   * @param keystore The key store.   * @throws KeyStoreException If the certificates cannot be retrieved   *         from the key store.   * @throws InvalidAlgorithmParameterException If there are no   *         certificates in the key store.   * @throws NullPointerException If <i>keystore</i> is null.   */  public PKIXParameters(KeyStore keystore)    throws KeyStoreException, InvalidAlgorithmParameterException  {    this();    for (Enumeration e = keystore.aliases(); e.hasMoreElements(); )      {        String alias = (String) e.nextElement();        if (!keystore.isCertificateEntry(alias))          continue;        Certificate cert = keystore.getCertificate(alias);        if (cert instanceof X509Certificate)          trustAnchors.add(new TrustAnchor((X509Certificate) cert, null));      }    if (trustAnchors.isEmpty())      throw new InvalidAlgorithmParameterException("no certs in the key store");  }  /**   * Create a new PKIXParameters object, populating the trusted   * certificates set with the elements of the given set, each of which   * must be a {@link TrustAnchor}.   *   * @param trustAnchors The set of trust anchors.   * @throws InvalidAlgorithmParameterException If there are no   *         certificates in the set.   * @throws NullPointerException If <i>trustAnchors</i> is null.   * @throws ClassCastException If every element in <i>trustAnchors</i>   *         is not a {@link TrustAnchor}.   */  public PKIXParameters(Set trustAnchors)    throws InvalidAlgorithmParameterException  {    this();    setTrustAnchors(trustAnchors);  }  /**   * Default constructor.   */  private PKIXParameters()  {    trustAnchors = new HashSet();    initPolicies = new HashSet();    certStores = new LinkedList();    pathCheckers = new LinkedList();    revocationEnabled = true;    exPolicyRequired = false;    policyMappingInhibited = false;    anyPolicyInhibited = false;    policyQualRejected = true;  }  /**   * Copying constructor for cloning.   *   * @param that The instance being cloned.   */  private PKIXParameters(PKIXParameters that)  {    this();    this.trustAnchors.addAll(that.trustAnchors);    this.initPolicies.addAll(that.initPolicies);    this.certStores.addAll(that.certStores);    this.pathCheckers.addAll(that.pathCheckers);    this.revocationEnabled = that.revocationEnabled;    this.exPolicyRequired = that.exPolicyRequired;    this.policyMappingInhibited = that.policyMappingInhibited;    this.anyPolicyInhibited = that.anyPolicyInhibited;    this.policyQualRejected = that.policyQualRejected;    this.date = that.date;    this.sigProvider = that.sigProvider;    this.targetConstraints = that.targetConstraints != null      ? (CertSelector) that.targetConstraints.clone() : null;  }  // Instance methods.  // ------------------------------------------------------------------------  /**   * Returns an immutable set of trust anchors. The set returned will   * never be null and will never be empty.   *   * @return A (never null, never empty) immutable set of trust anchors.   */  public Set getTrustAnchors()  {    return Collections.unmodifiableSet(trustAnchors);  }  /**   * Sets the trust anchors of this class, replacing the current trust   * anchors with those in the given set. The supplied set is copied to   * prevent modification.   *   * @param trustAnchors The new set of trust anchors.   * @throws InvalidAlgorithmParameterException If there are no   *         certificates in the set.   * @throws NullPointerException If <i>trustAnchors</i> is null.   * @throws ClassCastException If every element in <i>trustAnchors</i>   *         is not a {@link TrustAnchor}.   */  public void setTrustAnchors(Set trustAnchors)    throws InvalidAlgorithmParameterException  {    if (trustAnchors.isEmpty())      throw new InvalidAlgorithmParameterException("no trust anchors");    this.trustAnchors.clear();    for (Iterator i = trustAnchors.iterator(); i.hasNext(); )      {        this.trustAnchors.add((TrustAnchor) i.next());      }  }  /**   * Returns the set of initial policy identifiers (as OID strings). If   * any policy is accepted, this method returns the empty set.   *   * @return An immutable set of initial policy OID strings, or the   *         empty set if any policy is acceptable.   */  public Set getInitialPolicies()  {    return Collections.unmodifiableSet(initPolicies);  }  /**   * Sets the initial policy identifiers (as OID strings). If the   * argument is null or the empty set, then any policy identifier will   * be accepted.   *   * @param initPolicies The new set of policy strings, or null.   * @throws ClassCastException If any element in <i>initPolicies</i> is   *         not a string.   */  public void setInitialPolicies(Set initPolicies)  {    this.initPolicies.clear();    if (initPolicies == null)      return;    for (Iterator i = initPolicies.iterator(); i.hasNext(); )      {        this.initPolicies.add((String) i.next());      }  }  /**   * Add a {@link CertStore} to the list of cert stores.   *   * @param store The CertStore to add.   */  public void addCertStore(CertStore store)  {    if (store != null)      certStores.add(store);  }  /**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -