diff --git a/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java b/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java
deleted file mode 100644
index be010d327a4..00000000000
--- a/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.provider;
-
-import java.net.URL;
-import java.util.*;
-import java.security.CodeSource;
-import java.security.Principal;
-import java.security.cert.Certificate;
-import java.lang.reflect.Constructor;
-
-import javax.security.auth.Subject;
-import sun.security.provider.PolicyParser.PrincipalEntry;
-import sun.security.util.ResourcesMgr;
-
-/**
- *
This SubjectCodeSource
class contains
- * a URL
, signer certificates, and either a Subject
- * (that represents the Subject
in the current
- * AccessControlContext
), or a linked list of Principals
- * (that represent a "subject" in a Policy
).
- *
- */
-class SubjectCodeSource extends CodeSource implements java.io.Serializable {
-
- @java.io.Serial
- private static final long serialVersionUID = 6039418085604715275L;
-
- private final Subject subject;
- private final LinkedList principals;
- private static final Class>[] PARAMS = { String.class };
- private static final sun.security.util.Debug debug =
- sun.security.util.Debug.getInstance("auth", "\t[Auth Access]");
- @SuppressWarnings("serial") // Not statically typed as Serializable
- private final ClassLoader sysClassLoader;
-
- /**
- * Creates a new SubjectCodeSource
- * with the given Subject
, principals, URL
,
- * and signers (Certificates). The Subject
- * represents the Subject
associated with the current
- * AccessControlContext
.
- * The Principals are given as a LinkedList
- * of PolicyParser.PrincipalEntry
objects.
- * Typically either a Subject
will be provided,
- * or a list of principals
will be provided
- * (not both).
- *
- *
- *
- * @param subject the Subject
associated with this
- * SubjectCodeSource
- *
- * @param url the URL
associated with this
- * SubjectCodeSource
- *
- * @param certs the signers associated with this
- * SubjectCodeSource
- */
- @SuppressWarnings("removal")
- SubjectCodeSource(Subject subject,
- LinkedList principals,
- URL url, Certificate[] certs) {
-
- super(url, certs);
- this.subject = subject;
- this.principals = (principals == null ?
- new LinkedList() :
- new LinkedList(principals));
- sysClassLoader = java.security.AccessController.doPrivileged
- (new java.security.PrivilegedAction() {
- public ClassLoader run() {
- return ClassLoader.getSystemClassLoader();
- }
- });
- }
-
- /**
- * Get the Principals associated with this SubjectCodeSource
.
- * The Principals are retrieved as a LinkedList
- * of PolicyParser.PrincipalEntry
objects.
- *
- *
- *
- * @return the Principals associated with this
- * SubjectCodeSource
as a LinkedList
- * of PolicyParser.PrincipalEntry
objects.
- */
- LinkedList getPrincipals() {
- return principals;
- }
-
- /**
- * Get the Subject
associated with this
- * SubjectCodeSource
. The Subject
- * represents the Subject
associated with the
- * current AccessControlContext
.
- *
- *
- *
- * @return the Subject
associated with this
- * SubjectCodeSource
.
- */
- Subject getSubject() {
- return subject;
- }
-
- /**
- * Returns true if this SubjectCodeSource
object "implies"
- * the specified CodeSource
.
- * More specifically, this method makes the following checks.
- * If any fail, it returns false. If they all succeed, it returns true.
- *
- *
- *
- * - The provided codesource must not be
null
.
- * - codesource must be an instance of
SubjectCodeSource
.
- * - super.implies(codesource) must return true.
- *
- for each principal in this codesource's principal list:
- *
- * - if the principal is an instanceof
- *
Principal
, then the principal must
- * imply the provided codesource's Subject
.
- * - if the principal is not an instanceof
- *
Principal
, then the provided
- * codesource's Subject
must have an
- * associated Principal
, P, where
- * P.getClass().getName equals principal.principalClass,
- * and P.getName() equals principal.principalName.
- *
- *
- *
- *
- *
- * @param codesource the CodeSource
to compare against.
- *
- * @return true if this SubjectCodeSource
implies
- * the specified CodeSource
.
- */
- public boolean implies(CodeSource codesource) {
-
- LinkedList subjectList = null;
-
- if (!(codesource instanceof SubjectCodeSource that) ||
- !super.implies(codesource)) {
-
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: FAILURE 1");
- return false;
- }
-
- // if the principal list in the policy "implies"
- // the Subject associated with the current AccessControlContext,
- // then return true
-
- if (this.principals == null) {
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: PASS 1");
- return true;
- }
-
- if (that.getSubject() == null ||
- that.getSubject().getPrincipals().size() == 0) {
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: FAILURE 2");
- return false;
- }
-
- ListIterator li = this.principals.listIterator(0);
- while (li.hasNext()) {
- PrincipalEntry pppe = li.next();
- try {
-
- // use new Principal.implies method
-
- Class> pClass = Class.forName(pppe.principalClass,
- true, sysClassLoader);
- if (!Principal.class.isAssignableFrom(pClass)) {
- // not the right subtype
- throw new ClassCastException(pppe.principalClass +
- " is not a Principal");
- }
- Constructor> c = pClass.getConstructor(PARAMS);
- Principal p = (Principal)c.newInstance(new Object[] {
- pppe.principalName });
-
- if (!p.implies(that.getSubject())) {
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: FAILURE 3");
- return false;
- } else {
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: PASS 2");
- return true;
- }
- } catch (Exception e) {
-
- // simply compare Principals
-
- if (subjectList == null) {
-
- if (that.getSubject() == null) {
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: " +
- "FAILURE 4");
- return false;
- }
- Iterator i =
- that.getSubject().getPrincipals().iterator();
-
- subjectList = new LinkedList<>();
- while (i.hasNext()) {
- Principal p = i.next();
- PrincipalEntry spppe = new PrincipalEntry
- (p.getClass().getName(), p.getName());
- subjectList.add(spppe);
- }
- }
-
- if (!subjectListImpliesPrincipalEntry(subjectList, pppe)) {
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: FAILURE 5");
- return false;
- }
- }
- }
-
- if (debug != null)
- debug.println("\tSubjectCodeSource.implies: PASS 3");
- return true;
- }
-
- /**
- * This method returns, true, if the provided subjectList
- * "contains" the Principal
specified
- * in the provided pppe argument.
- *
- * Note that the provided pppe argument may have
- * wildcards (*) for the Principal
class and name,
- * which need to be considered.
- *
- *
- *
- * @param subjectList a list of PolicyParser.PrincipalEntry objects
- * that correspond to all the Principals in the Subject currently
- * on this thread's AccessControlContext.
- *
- * @param pppe the Principals specified in a grant entry.
- *
- * @return true if the provided subjectList "contains"
- * the Principal
specified in the provided
- * pppe argument.
- */
- private boolean subjectListImpliesPrincipalEntry(
- LinkedList subjectList, PrincipalEntry pppe) {
-
- ListIterator li = subjectList.listIterator(0);
- while (li.hasNext()) {
- PrincipalEntry listPppe = li.next();
-
- if (pppe.getPrincipalClass().equals
- (PrincipalEntry.WILDCARD_CLASS) ||
- pppe.getPrincipalClass().equals(listPppe.getPrincipalClass()))
- {
- if (pppe.getPrincipalName().equals
- (PrincipalEntry.WILDCARD_NAME) ||
- pppe.getPrincipalName().equals(listPppe.getPrincipalName()))
- return true;
- }
- }
- return false;
- }
-
- /**
- * Tests for equality between the specified object and this
- * object. Two SubjectCodeSource
objects are considered equal
- * if their locations are of identical value, if the two sets of
- * Certificates are of identical values, and if the
- * Subjects are equal, and if the PolicyParser.PrincipalEntry values
- * are of identical values. It is not required that
- * the Certificates or PolicyParser.PrincipalEntry values
- * be in the same order.
- *
- *
- *
- * @param obj the object to test for equality with this object.
- *
- * @return true if the objects are considered equal, false otherwise.
- */
- public boolean equals(Object obj) {
-
- if (obj == this)
- return true;
-
- if (!super.equals(obj))
- return false;
-
- if (!(obj instanceof SubjectCodeSource that))
- return false;
-
- // the principal lists must match
- try {
- if (this.getSubject() != that.getSubject())
- return false;
- } catch (SecurityException se) {
- return false;
- }
-
- if ((this.principals == null && that.principals != null) ||
- (this.principals != null && that.principals == null))
- return false;
-
- if (this.principals != null) {
- return this.principals.containsAll(that.principals) &&
- that.principals.containsAll(this.principals);
- }
-
- return true;
- }
-
- /**
- * Return a hashcode for this SubjectCodeSource
.
- *
- *
- *
- * @return a hashcode for this SubjectCodeSource
.
- */
- public int hashCode() {
- return super.hashCode();
- }
-
- /**
- * Return a String representation of this SubjectCodeSource
.
- *
- *
- *
- * @return a String representation of this SubjectCodeSource
.
- */
- @SuppressWarnings("removal")
- public String toString() {
- String returnMe = super.toString();
- if (getSubject() != null) {
- if (debug != null) {
- final Subject finalSubject = getSubject();
- returnMe = returnMe + "\n" +
- java.security.AccessController.doPrivileged
- (new java.security.PrivilegedAction() {
- public String run() {
- return finalSubject.toString();
- }
- });
- } else {
- returnMe = returnMe + "\n" + getSubject().toString();
- }
- }
- if (principals != null) {
- for (PrincipalEntry pppe : principals) {
- returnMe = returnMe + ResourcesMgr.getAuthResourceString("NEWLINE") +
- pppe.getPrincipalClass() + " " +
- pppe.getPrincipalName();
- }
- }
- return returnMe;
- }
-}
diff --git a/test/jdk/sun/security/provider/PolicyFile/Comparator.Combined.Policy b/test/jdk/sun/security/provider/PolicyFile/Comparator.Combined.Policy
deleted file mode 100644
index 3db6a34f785..00000000000
--- a/test/jdk/sun/security/provider/PolicyFile/Comparator.Combined.Policy
+++ /dev/null
@@ -1,33 +0,0 @@
-
-// should be granted
-grant principal com.sun.security.auth.UnixPrincipal "1",
- principal Comparator$PCompare2 "2" {
- permission java.util.PropertyPermission "foo", "read";
-};
-
-// should be granted
-grant principal Comparator$PCompare1 "1",
- principal com.sun.security.auth.NTUserPrincipal "4" {
- permission java.util.PropertyPermission "bar", "read";
-};
-
-// should be granted
-grant principal com.sun.security.auth.UnixPrincipal "1",
- principal javax.security.auth.x500.X500Principal "cn=x500",
- principal Comparator$PCompare2 "2" {
- permission java.util.PropertyPermission "hello", "read";
-};
-
-// should be granted
-grant principal Comparator$PCompare1 "1",
- principal com.sun.security.auth.NTUserPrincipal "4",
- principal javax.security.auth.x500.X500Principal "cn=x500" {
- permission java.util.PropertyPermission "world", "read";
-};
-
-// should not be granted
-grant principal Comparator$PCompare1 "1",
- principal Comparator$PCompare3 "3" {
- permission java.util.PropertyPermission "foobar", "read";
-};
-
diff --git a/test/jdk/sun/security/provider/PolicyFile/Comparator.Comparator.Policy b/test/jdk/sun/security/provider/PolicyFile/Comparator.Comparator.Policy
deleted file mode 100644
index d0357c27613..00000000000
--- a/test/jdk/sun/security/provider/PolicyFile/Comparator.Comparator.Policy
+++ /dev/null
@@ -1,18 +0,0 @@
-
-// should be granted
-grant principal Comparator$PCompare1 "1" {
- permission java.util.PropertyPermission "foo", "read";
-};
-
-// should be granted
-grant principal Comparator$PCompare1 "1",
- principal Comparator$PCompare2 "2" {
- permission java.util.PropertyPermission "bar", "read";
-};
-
-// should not be granted
-grant principal Comparator$PCompare1 "1",
- principal Comparator$PCompare3 "3" {
- permission java.util.PropertyPermission "foobar", "read";
-};
-
diff --git a/test/jdk/sun/security/provider/PolicyFile/Comparator.Principal.Policy b/test/jdk/sun/security/provider/PolicyFile/Comparator.Principal.Policy
deleted file mode 100644
index f837f8c25ff..00000000000
--- a/test/jdk/sun/security/provider/PolicyFile/Comparator.Principal.Policy
+++ /dev/null
@@ -1,18 +0,0 @@
-
-// should be granted
-grant principal com.sun.security.auth.UnixPrincipal "1" {
- permission java.util.PropertyPermission "foo", "read";
-};
-
-// should be granted
-grant principal javax.security.auth.x500.X500Principal "cn=2",
- principal com.sun.security.auth.NTUserPrincipal "2" {
- permission java.util.PropertyPermission "bar", "read";
-};
-
-// should not be granted
-grant principal javax.security.auth.x500.X500Principal "cn=2",
- principal com.sun.security.auth.UnixPrincipal "1" {
- permission java.util.PropertyPermission "foobar", "read";
-};
-
diff --git a/test/jdk/sun/security/provider/PolicyFile/Comparator.java b/test/jdk/sun/security/provider/PolicyFile/Comparator.java
deleted file mode 100644
index 07a9c44cecd..00000000000
--- a/test/jdk/sun/security/provider/PolicyFile/Comparator.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 5037004
- * @summary Frivolous ClassCastExceptions thrown by SubjectCodeSource.implies
- * @modules java.base/sun.security.provider
- * @run main/othervm Comparator
- *
- * Note: if you want to see the java.security.debug output,
- * you can not simply set the system property.
- * you must run this test by hand and pass -Djava.security.debug=...
- */
-
-import java.io.*;
-import java.security.*;
-import java.util.PropertyPermission;
-import javax.security.auth.Subject;
-import javax.security.auth.x500.X500Principal;
-
-import sun.security.provider.PolicyFile;
-import com.sun.security.auth.UnixPrincipal;
-import com.sun.security.auth.NTUserPrincipal;
-
-public class Comparator {
-
- private static final PropertyPermission FOO =
- new PropertyPermission("foo", "read");
- private static final PropertyPermission BAR =
- new PropertyPermission("bar", "read");
- private static final PropertyPermission FOOBAR =
- new PropertyPermission("foobar", "read");
- private static final PropertyPermission HELLO =
- new PropertyPermission("hello", "read");
- private static final PropertyPermission WORLD =
- new PropertyPermission("world", "read");
-
- private static final CodeSource cs =
- new CodeSource(null, (java.security.cert.Certificate[])null);
-
- private static final Principal[] p1 = new Principal[] {
- new UnixPrincipal("1") };
-
- private static final Principal[] p2 = new Principal[] {
- new X500Principal("cn=2"),
- new NTUserPrincipal("2") };
-
- private static final Principal[] p3 = new Principal[] {
- new UnixPrincipal("1"),
- new X500Principal("cn=2"),
- new NTUserPrincipal("2") };
-
- private static final Principal[] p4 = new Principal[] {
- new UnixPrincipal("1"),
- new NTUserPrincipal("4") };
-
- private static final Principal[] p5 = new Principal[] {
- new UnixPrincipal("1"),
- new X500Principal("cn=2"),
- new NTUserPrincipal("2"),
- new X500Principal("cn=x500") };
-
- private static final Principal[] p6 = new Principal[] {
- new UnixPrincipal("1"),
- new NTUserPrincipal("4"),
- new X500Principal("cn=x500") };
-
- private static final Principal[] badP = new Principal[] {
- new UnixPrincipal("bad") };
-
- public static class PCompare1 implements Principal {
-
- private String name;
-
- public PCompare1(String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean implies (Subject subject) {
- if (subject.getPrincipals().contains(p1[0])) {
- return true;
- }
- return false;
- }
- }
-
- public static class PCompare2 implements Principal {
- private String name;
-
- public PCompare2(String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean implies (Subject subject) {
- if (subject.getPrincipals().contains(p2[0]) &&
- subject.getPrincipals().contains(p2[1])) {
- return true;
- }
- return false;
- }
- }
-
- public static class PCompare3 implements Principal {
- private String name;
-
- public PCompare3(String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean implies (Subject subject) {
- return false;
- }
- }
-
- public static void main(String[] args) throws Exception {
-
- int testnum = 1;
-
- // in case we run standalone
- String policyDir = System.getProperty("test.src");
- if (policyDir == null) {
- policyDir = ".";
- }
-
- // do principal-only tests
- System.setProperty("java.security.policy",
- "=" +
- policyDir +
- File.separatorChar +
- "Comparator.Principal.Policy");
- PolicyFile policy = new PolicyFile();
- testnum = doPrincipalTest(policy, testnum);
- System.out.println("============ Principal Test Passed ============");
-
- // do comparator-only tests
- System.setProperty("java.security.policy",
- "=" +
- policyDir +
- File.separatorChar +
- "Comparator.Comparator.Policy");
- policy = new PolicyFile();
- testnum = doComparatorTest(policy, testnum);
- System.out.println("============ Comparator Test Passed ============");
-
- // combined principal/comparator tests
- System.setProperty("java.security.policy",
- "=" +
- policyDir +
- File.separatorChar +
- "Comparator.Combined.Policy");
- policy = new PolicyFile();
- testnum = doCombinedTest(policy, testnum);
- System.out.println("============ Combined Test Passed ============");
- }
-
- private static int doBadTest(PolicyFile policy, int testnum) {
-
- // this principal is not in policy - should not match any policy grants
- ProtectionDomain pd = new ProtectionDomain(cs, null, null, badP);
- if (policy.implies(pd, FOO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // this principal is not in policy - should not match any policy grants
- if (policy.implies(pd, BAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // this principal is not in policy - should not match any policy grants
- if (policy.implies(pd, FOOBAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- return testnum;
- }
-
- private static int doPrincipalTest(PolicyFile policy, int testnum) {
-
- // security check against one principal should pass
- ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
- if (!policy.implies(pd, FOO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match BAR grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p1);
- if (policy.implies(pd, BAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // security check against two principals should pass
- pd = new ProtectionDomain(cs, null, null, p2);
- if (!policy.implies(pd, BAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match FOOBAR grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p1);
- if (policy.implies(pd, FOOBAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match FOOBAR grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p2);
- if (policy.implies(pd, FOOBAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- testnum = doBadTest(policy, testnum);
-
- return testnum;
- }
-
- private static int doComparatorTest(PolicyFile policy, int testnum) {
-
- // security check against one comparator should pass
- ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
- if (!policy.implies(pd, FOO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match BAR grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p1);
- if (policy.implies(pd, BAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // security check against two comparators should pass for FOO
- pd = new ProtectionDomain(cs, null, null, p3);
- if (!policy.implies(pd, FOO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // security check against two comparators should pass for BAR
- pd = new ProtectionDomain(cs, null, null, p3);
- if (!policy.implies(pd, BAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // security check should fail against FOOBAR
- pd = new ProtectionDomain(cs, null, null, p3);
- if (policy.implies(pd, FOOBAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- testnum = doBadTest(policy, testnum);
-
- return testnum;
- }
-
- private static int doCombinedTest(PolicyFile policy, int testnum) {
-
- // security check against principal followed by comparator should pass
- ProtectionDomain pd = new ProtectionDomain(cs, null, null, p3);
- if (!policy.implies(pd, FOO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match BAR grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p3);
- if (policy.implies(pd, BAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // security check against comparator followed by principal should pass
- pd = new ProtectionDomain(cs, null, null, p4);
- if (!policy.implies(pd, BAR)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match FOO grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p4);
- if (policy.implies(pd, FOO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // security check against principal-principal-comparator should pass
- pd = new ProtectionDomain(cs, null, null, p5);
- if (!policy.implies(pd, HELLO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match WORLD grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p5);
- if (policy.implies(pd, WORLD)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // security check against principal-principal-comparator should pass
- pd = new ProtectionDomain(cs, null, null, p6);
- if (!policy.implies(pd, WORLD)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- // should not match HELLO grant entry in policy
- pd = new ProtectionDomain(cs, null, null, p6);
- if (policy.implies(pd, HELLO)) {
- throw new SecurityException("test." + testnum + " failed");
- }
- testnum++;
-
- testnum = doBadTest(policy, testnum);
-
- return testnum;
- }
-}