1. /*
  2. * @(#)PolicyNode.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. package java.security.cert;
  8. import java.util.Iterator;
  9. import java.util.Set;
  10. /**
  11. * An immutable valid policy tree node as defined by the PKIX certification
  12. * path validation algorithm.
  13. *
  14. * <p>One of the outputs of the PKIX certification path validation
  15. * algorithm is a valid policy tree, which includes the policies that
  16. * were determined to be valid, how this determination was reached,
  17. * and any policy qualifiers encountered. This tree is of depth
  18. * <i>n</i>, where <i>n</i> is the length of the certification
  19. * path that has been validated.
  20. *
  21. * <p>Most applications will not need to examine the valid policy tree.
  22. * They can achieve their policy processing goals by setting the
  23. * policy-related parameters in <code>PKIXParameters</code>. However,
  24. * the valid policy tree is available for more sophisticated applications,
  25. * especially those that process policy qualifiers.
  26. *
  27. * <p>{@link PKIXCertPathValidatorResult#getPolicyTree()
  28. * PKIXCertPathValidatorResult.getPolicyTree} returns the root node of the
  29. * valid policy tree. The tree can be traversed using the
  30. * {@link #getChildren getChildren} and {@link #getParent getParent} methods.
  31. * Data about a particular node can be retrieved using other methods of
  32. * <code>PolicyNode</code>.
  33. *
  34. * <p><b>Concurrent Access</b>
  35. * <p>All <code>PolicyNode</code> objects must be immutable and
  36. * thread-safe. Multiple threads may concurrently invoke the methods defined
  37. * in this class on a single <code>PolicyNode</code> object (or more than one)
  38. * with no ill effects. This stipulation applies to all public fields and
  39. * methods of this class and any added or overridden by subclasses.
  40. *
  41. * @version 1.9 12/19/03
  42. * @since 1.4
  43. * @author Sean Mullan
  44. */
  45. public interface PolicyNode {
  46. /**
  47. * Returns the parent of this node, or <code>null</code> if this is the
  48. * root node.
  49. *
  50. * @return the parent of this node, or <code>null</code> if this is the
  51. * root node
  52. */
  53. PolicyNode getParent();
  54. /**
  55. * Returns an iterator over the children of this node. Any attempts to
  56. * modify the children of this node through the
  57. * <code>Iterator</code>'s remove method must throw an
  58. * <code>UnsupportedOperationException</code>.
  59. *
  60. * @return an iterator over the children of this node
  61. */
  62. Iterator<? extends PolicyNode> getChildren();
  63. /**
  64. * Returns the depth of this node in the valid policy tree.
  65. *
  66. * @return the depth of this node (0 for the root node, 1 for its
  67. * children, and so on)
  68. */
  69. int getDepth();
  70. /**
  71. * Returns the valid policy represented by this node.
  72. *
  73. * @return the <code>String</code> OID of the valid policy
  74. * represented by this node, or the special value "any-policy". For
  75. * the root node, this method always returns the special value "any-policy".
  76. */
  77. String getValidPolicy();
  78. /**
  79. * Returns the set of policy qualifiers associated with the
  80. * valid policy represented by this node.
  81. *
  82. * @return an immutable <code>Set</code> of
  83. * <code>PolicyQualifierInfo</code>s. For the root node, this
  84. * is always an empty <code>Set</code>.
  85. */
  86. Set<? extends PolicyQualifierInfo> getPolicyQualifiers();
  87. /**
  88. * Returns the set of expected policies that would satisfy this
  89. * node's valid policy in the next certificate to be processed.
  90. *
  91. * @return an immutable <code>Set</code> of expected policy
  92. * <code>String</code> OIDs, or an immutable <code>Set</code> with
  93. * the single special value "any-policy". For the root node, this method
  94. * always returns a <code>Set</code> with the single value "any-policy".
  95. */
  96. Set<String> getExpectedPolicies();
  97. /**
  98. * Returns the criticality indicator of the certificate policy extension
  99. * in the most recently processed certificate.
  100. *
  101. * @return <code>true</code> if extension marked critical,
  102. * <code>false</code> otherwise. For the root node, <code>false</code>
  103. * is always returned.
  104. */
  105. boolean isCritical();
  106. }