From PermissionCollection to Policy

A

Andrew Thompson

In attempts to create security environments for applet testing,
I have come up with a (java.security.)PermissionCollection that
represents a typical sandbox.

Unfortunately I can see no easy way to turn a PermissionCollection
into a Policy, so that I might call java.security.Policy.setPolicy
(Policy).

Did I miss something? Is there an easier way to go from a
PermissionCollection to a workable SecurityManager?
 
A

Andrew Thompson

...go from a
PermissionCollection to a workable SecurityManager?

Extend SecurityManager to accept a
PermissionCollection and ..

@Override
public void checkPermission(Permission perm) {
if (permissionCollection.implies(perm)) {
} else {
throw new SecurityException(
perm +
" denied by security manager!");
}
}

...To answer my own question.

Better/alternate answers still welcome, though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top