KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > cert > PKIXCertPathBuilderResult


1 /*
2  * @(#)PKIXCertPathBuilderResult.java 1.9 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.security.cert;
9
10 import java.security.PublicKey JavaDoc;
11
12 /**
13  * This class represents the successful result of the PKIX certification
14  * path builder algorithm. All certification paths that are built and
15  * returned using this algorithm are also validated according to the PKIX
16  * certification path validation algorithm.
17  *
18  * <p>Instances of <code>PKIXCertPathBuilderResult</code> are returned by
19  * the <code>build</code> method of <code>CertPathBuilder</code>
20  * objects implementing the PKIX algorithm.
21  *
22  * <p>All <code>PKIXCertPathBuilderResult</code> objects contain the
23  * certification path constructed by the build algorithm, the
24  * valid policy tree and subject public key resulting from the build
25  * algorithm, and a <code>TrustAnchor</code> describing the certification
26  * authority (CA) that served as a trust anchor for the certification path.
27  * <p>
28  * <b>Concurrent Access</b>
29  * <p>
30  * Unless otherwise specified, the methods defined in this class are not
31  * thread-safe. Multiple threads that need to access a single
32  * object concurrently should synchronize amongst themselves and
33  * provide the necessary locking. Multiple threads each manipulating
34  * separate objects need not synchronize.
35  *
36  * @see CertPathBuilderResult
37  *
38  * @version 1.9 12/19/03
39  * @since 1.4
40  * @author Anne Anderson
41  */

42 public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult JavaDoc
43     implements CertPathBuilderResult JavaDoc {
44
45     private CertPath JavaDoc certPath;
46
47     /**
48      * Creates an instance of <code>PKIXCertPathBuilderResult</code>
49      * containing the specified parameters.
50      *
51      * @param certPath the validated <code>CertPath</code>
52      * @param trustAnchor a <code>TrustAnchor</code> describing the CA that
53      * served as a trust anchor for the certification path
54      * @param policyTree the immutable valid policy tree, or <code>null</code>
55      * if there are no valid policies
56      * @param subjectPublicKey the public key of the subject
57      * @throws NullPointerException if the <code>certPath</code>,
58      * <code>trustAnchor</code> or <code>subjectPublicKey</code> parameters
59      * are <code>null</code>
60      */

61     public PKIXCertPathBuilderResult(CertPath JavaDoc certPath,
62     TrustAnchor JavaDoc trustAnchor, PolicyNode JavaDoc policyTree,
63     PublicKey JavaDoc subjectPublicKey)
64     {
65     super(trustAnchor, policyTree, subjectPublicKey);
66     if (certPath == null)
67         throw new NullPointerException JavaDoc("certPath must be non-null");
68     this.certPath = certPath;
69     }
70
71     /**
72      * Returns the built and validated certification path. The
73      * <code>CertPath</code> object does not include the trust anchor.
74      * Instead, use the {@link #getTrustAnchor() getTrustAnchor()} method to
75      * obtain the <code>TrustAnchor</code> that served as the trust anchor
76      * for the certification path.
77      *
78      * @return the built and validated <code>CertPath</code> (never
79      * <code>null</code>)
80      */

81     public CertPath JavaDoc getCertPath() {
82     return certPath;
83     }
84
85     /**
86      * Return a printable representation of this
87      * <code>PKIXCertPathBuilderResult</code>.
88      *
89      * @return a <code>String</code> describing the contents of this
90      * <code>PKIXCertPathBuilderResult</code>
91      */

92     public String JavaDoc toString() {
93         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
94         sb.append("PKIXCertPathBuilderResult: [\n");
95         sb.append(" Certification Path: " + certPath + "\n");
96         sb.append(" Trust Anchor: " + getTrustAnchor().toString() + "\n");
97         sb.append(" Policy Tree: " + String.valueOf(getPolicyTree()) + "\n");
98         sb.append(" Subject Public Key: " + getPublicKey() + "\n");
99         sb.append("]");
100         return sb.toString();
101     }
102 }
103
Popular Tags