001 /*
002 * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.security.cert;
027
028 import java.security.PublicKey;
029
030 /**
031 * This class represents the successful result of the PKIX certification
032 * path builder algorithm. All certification paths that are built and
033 * returned using this algorithm are also validated according to the PKIX
034 * certification path validation algorithm.
035 *
036 * <p>Instances of <code>PKIXCertPathBuilderResult</code> are returned by
037 * the <code>build</code> method of <code>CertPathBuilder</code>
038 * objects implementing the PKIX algorithm.
039 *
040 * <p>All <code>PKIXCertPathBuilderResult</code> objects contain the
041 * certification path constructed by the build algorithm, the
042 * valid policy tree and subject public key resulting from the build
043 * algorithm, and a <code>TrustAnchor</code> describing the certification
044 * authority (CA) that served as a trust anchor for the certification path.
045 * <p>
046 * <b>Concurrent Access</b>
047 * <p>
048 * Unless otherwise specified, the methods defined in this class are not
049 * thread-safe. Multiple threads that need to access a single
050 * object concurrently should synchronize amongst themselves and
051 * provide the necessary locking. Multiple threads each manipulating
052 * separate objects need not synchronize.
053 *
054 * @see CertPathBuilderResult
055 *
056 * @version 1.16 05/05/07
057 * @since 1.4
058 * @author Anne Anderson
059 */
060 public class PKIXCertPathBuilderResult extends
061 PKIXCertPathValidatorResult implements CertPathBuilderResult {
062
063 private CertPath certPath;
064
065 /**
066 * Creates an instance of <code>PKIXCertPathBuilderResult</code>
067 * containing the specified parameters.
068 *
069 * @param certPath the validated <code>CertPath</code>
070 * @param trustAnchor a <code>TrustAnchor</code> describing the CA that
071 * served as a trust anchor for the certification path
072 * @param policyTree the immutable valid policy tree, or <code>null</code>
073 * if there are no valid policies
074 * @param subjectPublicKey the public key of the subject
075 * @throws NullPointerException if the <code>certPath</code>,
076 * <code>trustAnchor</code> or <code>subjectPublicKey</code> parameters
077 * are <code>null</code>
078 */
079 public PKIXCertPathBuilderResult(CertPath certPath,
080 TrustAnchor trustAnchor, PolicyNode policyTree,
081 PublicKey subjectPublicKey) {
082 super (trustAnchor, policyTree, subjectPublicKey);
083 if (certPath == null)
084 throw new NullPointerException("certPath must be non-null");
085 this .certPath = certPath;
086 }
087
088 /**
089 * Returns the built and validated certification path. The
090 * <code>CertPath</code> object does not include the trust anchor.
091 * Instead, use the {@link #getTrustAnchor() getTrustAnchor()} method to
092 * obtain the <code>TrustAnchor</code> that served as the trust anchor
093 * for the certification path.
094 *
095 * @return the built and validated <code>CertPath</code> (never
096 * <code>null</code>)
097 */
098 public CertPath getCertPath() {
099 return certPath;
100 }
101
102 /**
103 * Return a printable representation of this
104 * <code>PKIXCertPathBuilderResult</code>.
105 *
106 * @return a <code>String</code> describing the contents of this
107 * <code>PKIXCertPathBuilderResult</code>
108 */
109 public String toString() {
110 StringBuffer sb = new StringBuffer();
111 sb.append("PKIXCertPathBuilderResult: [\n");
112 sb.append(" Certification Path: " + certPath + "\n");
113 sb.append(" Trust Anchor: " + getTrustAnchor().toString()
114 + "\n");
115 sb.append(" Policy Tree: " + String.valueOf(getPolicyTree())
116 + "\n");
117 sb.append(" Subject Public Key: " + getPublicKey() + "\n");
118 sb.append("]");
119 return sb.toString();
120 }
121 }
|