-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
5.0
-
generic
-
generic
The Permissions class effectively ignores UnresolvedPermissions for a given class that are added after an actual instance of the class is added or passed to implies. Demonstrated with this test program:
import java.security.*;
public class Test {
public static class FooPermission extends BasicPermission {
public FooPermission(String name) {
super(name);
}
}
public static void main(String[] args) throws Exception {
Permissions pc = new Permissions();
pc.add(new FooPermission("foo"));
pc.add(new UnresolvedPermission(FooPermission.class.getName(),
"bar", null, null));
if (!pc.implies(new FooPermission("bar"))) {
System.out.println("first test failed");
}
pc = new Permissions();
pc.add(new UnresolvedPermission(FooPermission.class.getName(),
"foo", null, null));
if (!pc.implies(new FooPermission("foo"))) {
throw new RuntimeException("oops");
}
pc.add(new UnresolvedPermission(FooPermission.class.getName(),
"bar", null, null));
if (!pc.implies(new FooPermission("bar"))) {
System.out.println("second test failed");
}
}
}
import java.security.*;
public class Test {
public static class FooPermission extends BasicPermission {
public FooPermission(String name) {
super(name);
}
}
public static void main(String[] args) throws Exception {
Permissions pc = new Permissions();
pc.add(new FooPermission("foo"));
pc.add(new UnresolvedPermission(FooPermission.class.getName(),
"bar", null, null));
if (!pc.implies(new FooPermission("bar"))) {
System.out.println("first test failed");
}
pc = new Permissions();
pc.add(new UnresolvedPermission(FooPermission.class.getName(),
"foo", null, null));
if (!pc.implies(new FooPermission("foo"))) {
throw new RuntimeException("oops");
}
pc.add(new UnresolvedPermission(FooPermission.class.getName(),
"bar", null, null));
if (!pc.implies(new FooPermission("bar"))) {
System.out.println("second test failed");
}
}
}
- relates to
-
JDK-6387002 Improve security check performance
- Closed