jdk/src/share/classes/java/security/cert/PolicyNode.java
author xuelei
Wed, 20 Jan 2010 21:38:37 +0800
changeset 4807 2521b7dcf505
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6862064: incorrect implementation of PKIXParameters.clone() Reviewed-by: weijun, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2003 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security.cert;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * An immutable valid policy tree node as defined by the PKIX certification
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * path validation algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <p>One of the outputs of the PKIX certification path validation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * algorithm is a valid policy tree, which includes the policies that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * were determined to be valid, how this determination was reached,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * and any policy qualifiers encountered. This tree is of depth
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <i>n</i>, where <i>n</i> is the length of the certification
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * path that has been validated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>Most applications will not need to examine the valid policy tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * They can achieve their policy processing goals by setting the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * policy-related parameters in <code>PKIXParameters</code>. However,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * the valid policy tree is available for more sophisticated applications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * especially those that process policy qualifiers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <p>{@link PKIXCertPathValidatorResult#getPolicyTree()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * PKIXCertPathValidatorResult.getPolicyTree} returns the root node of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * valid policy tree. The tree can be traversed using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * {@link #getChildren getChildren} and {@link #getParent getParent} methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Data about a particular node can be retrieved using other methods of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code>PolicyNode</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p><b>Concurrent Access</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <p>All <code>PolicyNode</code> objects must be immutable and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * thread-safe. Multiple threads may concurrently invoke the methods defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * in this class on a single <code>PolicyNode</code> object (or more than one)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * with no ill effects. This stipulation applies to all public fields and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * methods of this class and any added or overridden by subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @since       1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @author      Sean Mullan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
public interface PolicyNode {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Returns the parent of this node, or <code>null</code> if this is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * root node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @return the parent of this node, or <code>null</code> if this is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * root node
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    PolicyNode getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Returns an iterator over the children of this node. Any attempts to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * modify the children of this node through the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * <code>Iterator</code>'s remove method must throw an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * <code>UnsupportedOperationException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @return an iterator over the children of this node
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    Iterator<? extends PolicyNode> getChildren();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Returns the depth of this node in the valid policy tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @return the depth of this node (0 for the root node, 1 for its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * children, and so on)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    int getDepth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Returns the valid policy represented by this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @return the <code>String</code> OID of the valid policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * represented by this node. For the root node, this method always returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * the special anyPolicy OID: "2.5.29.32.0".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    String getValidPolicy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Returns the set of policy qualifiers associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * valid policy represented by this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @return an immutable <code>Set</code> of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <code>PolicyQualifierInfo</code>s. For the root node, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * is always an empty <code>Set</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    Set<? extends PolicyQualifierInfo> getPolicyQualifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Returns the set of expected policies that would satisfy this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * node's valid policy in the next certificate to be processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @return an immutable <code>Set</code> of expected policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * <code>String</code> OIDs. For the root node, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * always returns a <code>Set</code> with one element, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * special anyPolicy OID: "2.5.29.32.0".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    Set<String> getExpectedPolicies();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Returns the criticality indicator of the certificate policy extension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * in the most recently processed certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @return <code>true</code> if extension marked critical,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * <code>false</code> otherwise. For the root node, <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * is always returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    boolean isCritical();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
}