KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)PKIXCertPathValidatorResult.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 validation algorithm.
15  *
16  * <p>Instances of <code>PKIXCertPathValidatorResult</code> are returned by the
17  * {@link CertPathValidator#validate validate} method of
18  * <code>CertPathValidator</code> objects implementing the PKIX algorithm.
19  *
20  * <p> All <code>PKIXCertPathValidatorResult</code> objects contain the
21  * valid policy tree and subject public key resulting from the
22  * validation algorithm, as well as a <code>TrustAnchor</code> describing
23  * the certification authority (CA) that served as a trust anchor for the
24  * certification path.
25  * <p>
26  * <b>Concurrent Access</b>
27  * <p>
28  * Unless otherwise specified, the methods defined in this class are not
29  * thread-safe. Multiple threads that need to access a single
30  * object concurrently should synchronize amongst themselves and
31  * provide the necessary locking. Multiple threads each manipulating
32  * separate objects need not synchronize.
33  *
34  * @see CertPathValidatorResult
35  *
36  * @version 1.9 12/19/03
37  * @since 1.4
38  * @author Yassir Elley
39  * @author Sean Mullan
40  */

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

59     public PKIXCertPathValidatorResult(TrustAnchor JavaDoc trustAnchor,
60         PolicyNode JavaDoc policyTree, PublicKey JavaDoc subjectPublicKey)
61     {
62     if (subjectPublicKey == null)
63         throw new NullPointerException JavaDoc("subjectPublicKey must be non-null");
64     if (trustAnchor == null)
65         throw new NullPointerException JavaDoc("trustAnchor must be non-null");
66         this.trustAnchor = trustAnchor;
67     this.policyTree = policyTree;
68         this.subjectPublicKey = subjectPublicKey;
69     }
70
71     /**
72      * Returns the <code>TrustAnchor</code> describing the CA that served
73      * as a trust anchor for the certification path.
74      *
75      * @return the <code>TrustAnchor</code> (never <code>null</code>)
76      */

77     public TrustAnchor JavaDoc getTrustAnchor() {
78     return trustAnchor;
79     }
80
81     /**
82      * Returns the root node of the valid policy tree resulting from the
83      * PKIX certification path validation algorithm. The
84      * <code>PolicyNode</code> object that is returned and any objects that
85      * it returns through public methods are immutable.
86      *
87      * <p>Most applications will not need to examine the valid policy tree.
88      * They can achieve their policy processing goals by setting the
89      * policy-related parameters in <code>PKIXParameters</code>. However, more
90      * sophisticated applications, especially those that process policy
91      * qualifiers, may need to traverse the valid policy tree using the
92      * {@link PolicyNode#getParent PolicyNode.getParent} and
93      * {@link PolicyNode#getChildren PolicyNode.getChildren} methods.
94      *
95      * @return the root node of the valid policy tree, or <code>null</code>
96      * if there are no valid policies
97      */

98     public PolicyNode JavaDoc getPolicyTree() {
99     return policyTree;
100     }
101
102     /**
103      * Returns the public key of the subject (target) of the certification
104      * path, including any inherited public key parameters if applicable.
105      *
106      * @return the public key of the subject (never <code>null</code>)
107      */

108     public PublicKey JavaDoc getPublicKey() {
109     return subjectPublicKey;
110     }
111
112     /**
113      * Returns a copy of this object.
114      *
115      * @return the copy
116      */

117     public Object JavaDoc clone() {
118         try {
119             return super.clone();
120         } catch (CloneNotSupportedException JavaDoc e) {
121             /* Cannot happen */
122             throw new InternalError JavaDoc(e.toString());
123         }
124     }
125
126     /**
127      * Return a printable representation of this
128      * <code>PKIXCertPathValidatorResult</code>.
129      *
130      * @return a <code>String</code> describing the contents of this
131      * <code>PKIXCertPathValidatorResult</code>
132      */

133     public String JavaDoc toString() {
134         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
135     sb.append("PKIXCertPathValidatorResult: [\n");
136         sb.append(" Trust Anchor: " + trustAnchor.toString() + "\n");
137         sb.append(" Policy Tree: " + String.valueOf(policyTree) + "\n");
138         sb.append(" Subject Public Key: " + subjectPublicKey + "\n");
139         sb.append("]");
140         return sb.toString();
141     }
142 }
143
Popular Tags