0N/A/*
2362N/A * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.security.cert;
0N/A
0N/Aimport java.security.PublicKey;
0N/A
0N/A/**
0N/A * This class represents the successful result of the PKIX certification
0N/A * path validation algorithm.
0N/A *
0N/A * <p>Instances of <code>PKIXCertPathValidatorResult</code> are returned by the
0N/A * {@link CertPathValidator#validate validate} method of
0N/A * <code>CertPathValidator</code> objects implementing the PKIX algorithm.
0N/A *
0N/A * <p> All <code>PKIXCertPathValidatorResult</code> objects contain the
0N/A * valid policy tree and subject public key resulting from the
0N/A * validation algorithm, as well as a <code>TrustAnchor</code> describing
0N/A * the certification authority (CA) that served as a trust anchor for the
0N/A * certification path.
0N/A * <p>
0N/A * <b>Concurrent Access</b>
0N/A * <p>
0N/A * Unless otherwise specified, the methods defined in this class are not
0N/A * thread-safe. Multiple threads that need to access a single
0N/A * object concurrently should synchronize amongst themselves and
0N/A * provide the necessary locking. Multiple threads each manipulating
0N/A * separate objects need not synchronize.
0N/A *
0N/A * @see CertPathValidatorResult
0N/A *
0N/A * @since 1.4
0N/A * @author Yassir Elley
0N/A * @author Sean Mullan
0N/A */
0N/Apublic class PKIXCertPathValidatorResult implements CertPathValidatorResult {
0N/A
0N/A private TrustAnchor trustAnchor;
0N/A private PolicyNode policyTree;
0N/A private PublicKey subjectPublicKey;
0N/A
0N/A /**
0N/A * Creates an instance of <code>PKIXCertPathValidatorResult</code>
0N/A * containing the specified parameters.
0N/A *
0N/A * @param trustAnchor a <code>TrustAnchor</code> describing the CA that
0N/A * served as a trust anchor for the certification path
0N/A * @param policyTree the immutable valid policy tree, or <code>null</code>
0N/A * if there are no valid policies
0N/A * @param subjectPublicKey the public key of the subject
0N/A * @throws NullPointerException if the <code>subjectPublicKey</code> or
0N/A * <code>trustAnchor</code> parameters are <code>null</code>
0N/A */
0N/A public PKIXCertPathValidatorResult(TrustAnchor trustAnchor,
0N/A PolicyNode policyTree, PublicKey subjectPublicKey)
0N/A {
0N/A if (subjectPublicKey == null)
0N/A throw new NullPointerException("subjectPublicKey must be non-null");
0N/A if (trustAnchor == null)
0N/A throw new NullPointerException("trustAnchor must be non-null");
0N/A this.trustAnchor = trustAnchor;
0N/A this.policyTree = policyTree;
0N/A this.subjectPublicKey = subjectPublicKey;
0N/A }
0N/A
0N/A /**
0N/A * Returns the <code>TrustAnchor</code> describing the CA that served
0N/A * as a trust anchor for the certification path.
0N/A *
0N/A * @return the <code>TrustAnchor</code> (never <code>null</code>)
0N/A */
0N/A public TrustAnchor getTrustAnchor() {
0N/A return trustAnchor;
0N/A }
0N/A
0N/A /**
0N/A * Returns the root node of the valid policy tree resulting from the
0N/A * PKIX certification path validation algorithm. The
0N/A * <code>PolicyNode</code> object that is returned and any objects that
0N/A * it returns through public methods are immutable.
0N/A *
0N/A * <p>Most applications will not need to examine the valid policy tree.
0N/A * They can achieve their policy processing goals by setting the
0N/A * policy-related parameters in <code>PKIXParameters</code>. However, more
0N/A * sophisticated applications, especially those that process policy
0N/A * qualifiers, may need to traverse the valid policy tree using the
0N/A * {@link PolicyNode#getParent PolicyNode.getParent} and
0N/A * {@link PolicyNode#getChildren PolicyNode.getChildren} methods.
0N/A *
0N/A * @return the root node of the valid policy tree, or <code>null</code>
0N/A * if there are no valid policies
0N/A */
0N/A public PolicyNode getPolicyTree() {
0N/A return policyTree;
0N/A }
0N/A
0N/A /**
0N/A * Returns the public key of the subject (target) of the certification
0N/A * path, including any inherited public key parameters if applicable.
0N/A *
0N/A * @return the public key of the subject (never <code>null</code>)
0N/A */
0N/A public PublicKey getPublicKey() {
0N/A return subjectPublicKey;
0N/A }
0N/A
0N/A /**
0N/A * Returns a copy of this object.
0N/A *
0N/A * @return the copy
0N/A */
0N/A public Object clone() {
0N/A try {
0N/A return super.clone();
0N/A } catch (CloneNotSupportedException e) {
0N/A /* Cannot happen */
0N/A throw new InternalError(e.toString());
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Return a printable representation of this
0N/A * <code>PKIXCertPathValidatorResult</code>.
0N/A *
0N/A * @return a <code>String</code> describing the contents of this
0N/A * <code>PKIXCertPathValidatorResult</code>
0N/A */
0N/A public String toString() {
0N/A StringBuffer sb = new StringBuffer();
0N/A sb.append("PKIXCertPathValidatorResult: [\n");
0N/A sb.append(" Trust Anchor: " + trustAnchor.toString() + "\n");
0N/A sb.append(" Policy Tree: " + String.valueOf(policyTree) + "\n");
0N/A sb.append(" Subject Public Key: " + subjectPublicKey + "\n");
0N/A sb.append("]");
0N/A return sb.toString();
0N/A }
0N/A}