1. /*
  2. * @(#)PKIXCertPathBuilderResult.java 1.8 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security.cert;
  8. import java.security.PublicKey;
  9. /**
  10. * This class represents the successful result of the PKIX certification
  11. * path builder algorithm. All certification paths that are built and
  12. * returned using this algorithm are also validated according to the PKIX
  13. * certification path validation algorithm.
  14. *
  15. * <p>Instances of <code>PKIXCertPathBuilderResult</code> are returned by
  16. * the <code>build</code> method of <code>CertPathBuilder</code>
  17. * objects implementing the PKIX algorithm.
  18. *
  19. * <p>All <code>PKIXCertPathBuilderResult</code> objects contain the
  20. * certification path constructed by the build algorithm, the
  21. * valid policy tree and subject public key resulting from the build
  22. * algorithm, and a <code>TrustAnchor</code> describing the certification
  23. * authority (CA) that served as a trust anchor for the certification path.
  24. * <p>
  25. * <b>Concurrent Access</b>
  26. * <p>
  27. * Unless otherwise specified, the methods defined in this class are not
  28. * thread-safe. Multiple threads that need to access a single
  29. * object concurrently should synchronize amongst themselves and
  30. * provide the necessary locking. Multiple threads each manipulating
  31. * separate objects need not synchronize.
  32. *
  33. * @see CertPathBuilderResult
  34. *
  35. * @version 1.8 01/23/03
  36. * @since 1.4
  37. * @author Anne Anderson
  38. */
  39. public class PKIXCertPathBuilderResult extends PKIXCertPathValidatorResult
  40. implements CertPathBuilderResult {
  41. private CertPath certPath;
  42. /**
  43. * Creates an instance of <code>PKIXCertPathBuilderResult</code>
  44. * containing the specified parameters.
  45. *
  46. * @param certPath the validated <code>CertPath</code>
  47. * @param trustAnchor a <code>TrustAnchor</code> describing the CA that
  48. * served as a trust anchor for the certification path
  49. * @param policyTree the immutable valid policy tree, or <code>null</code>
  50. * if there are no valid policies
  51. * @param subjectPublicKey the public key of the subject
  52. * @throws NullPointerException if the <code>certPath</code>,
  53. * <code>trustAnchor</code> or <code>subjectPublicKey</code> parameters
  54. * are <code>null</code>
  55. */
  56. public PKIXCertPathBuilderResult(CertPath certPath,
  57. TrustAnchor trustAnchor, PolicyNode policyTree,
  58. PublicKey subjectPublicKey)
  59. {
  60. super(trustAnchor, policyTree, subjectPublicKey);
  61. if (certPath == null)
  62. throw new NullPointerException("certPath must be non-null");
  63. this.certPath = certPath;
  64. }
  65. /**
  66. * Returns the built and validated certification path. The
  67. * <code>CertPath</code> object does not include the trust anchor.
  68. * Instead, use the {@link #getTrustAnchor() getTrustAnchor()} method to
  69. * obtain the <code>TrustAnchor</code> that served as the trust anchor
  70. * for the certification path.
  71. *
  72. * @return the built and validated <code>CertPath</code> (never
  73. * <code>null</code>)
  74. */
  75. public CertPath getCertPath() {
  76. return certPath;
  77. }
  78. /**
  79. * Return a printable representation of this
  80. * <code>PKIXCertPathBuilderResult</code>.
  81. *
  82. * @return a <code>String</code> describing the contents of this
  83. * <code>PKIXCertPathBuilderResult</code>
  84. */
  85. public String toString() {
  86. StringBuffer sb = new StringBuffer();
  87. sb.append("PKIXCertPathBuilderResult: [\n");
  88. sb.append(" Certification Path: " + certPath + "\n");
  89. sb.append(" Trust Anchor: " + getTrustAnchor().toString() + "\n");
  90. sb.append(" Policy Tree: " + String.valueOf(getPolicyTree()) + "\n");
  91. sb.append(" Subject Public Key: " + getPublicKey() + "\n");
  92. sb.append("]");
  93. return sb.toString();
  94. }
  95. }