Search in sources :

Example 1 with PolicyNode

use of java.security.cert.PolicyNode in project robovm by robovm.

the class PKIXCertPathValidatorResultTest method testGetPolicyTree01.

/**
     * Test for <code>getPolicyTree()</code> method<br>
     * Assertion: returns the root node of the valid
     * policy tree or <code>null</code> if there are
     * no valid policies
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
public final void testGetPolicyTree01() throws Exception {
    TrustAnchor ta = TestUtils.getTrustAnchor();
    if (ta == null) {
        fail(getName() + ": not performed (could not create test TrustAnchor)");
    }
    // valid policy tree case;
    PolicyNode pn = TestUtils.getPolicyTree();
    PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult(ta, pn, testPublicKey);
    // must return the same reference passed
    // as a parameter to the constructor
    assertSame(pn, vr.getPolicyTree());
}
Also used : PKIXCertPathValidatorResult(java.security.cert.PKIXCertPathValidatorResult) TrustAnchor(java.security.cert.TrustAnchor) PolicyNode(java.security.cert.PolicyNode)

Example 2 with PolicyNode

use of java.security.cert.PolicyNode in project robovm by robovm.

the class TestUtils method getPolicyTree.

/**
     * Creates policy tree stub containing two <code>PolicyNode</code>s
     * for testing purposes
     *
     * @return root <code>PolicyNode</code> of the policy tree
     */
public static PolicyNode getPolicyTree() {
    return new PolicyNode() {

        final PolicyNode parent = this;

        public int getDepth() {
            // parent
            return 0;
        }

        public boolean isCritical() {
            return false;
        }

        public String getValidPolicy() {
            return null;
        }

        public PolicyNode getParent() {
            return null;
        }

        public Iterator<PolicyNode> getChildren() {
            PolicyNode child = new PolicyNode() {

                public int getDepth() {
                    // child
                    return 1;
                }

                public boolean isCritical() {
                    return false;
                }

                public String getValidPolicy() {
                    return null;
                }

                public PolicyNode getParent() {
                    return parent;
                }

                public Iterator<PolicyNode> getChildren() {
                    return null;
                }

                public Set<String> getExpectedPolicies() {
                    return null;
                }

                public Set<? extends PolicyQualifierInfo> getPolicyQualifiers() {
                    return null;
                }
            };
            HashSet<PolicyNode> s = new HashSet<PolicyNode>();
            s.add(child);
            return s.iterator();
        }

        public Set<String> getExpectedPolicies() {
            return null;
        }

        public Set<? extends PolicyQualifierInfo> getPolicyQualifiers() {
            return null;
        }
    };
}
Also used : PolicyNode(java.security.cert.PolicyNode) HashSet(java.util.HashSet)

Aggregations

PolicyNode (java.security.cert.PolicyNode)2 PKIXCertPathValidatorResult (java.security.cert.PKIXCertPathValidatorResult)1 TrustAnchor (java.security.cert.TrustAnchor)1 HashSet (java.util.HashSet)1