Methods Summary |
---|
public void | setUp()
perms = new Permissions();
Permissions.Permission perm = new Permissions.Permission();
// Grant extra permissions to read and write the user.* properties and read to the
// java.home property
perm.setActions("read, write");
perm.setName("user.*");
perm.setClass("java.util.PropertyPermission");
perms.addConfiguredGrant(perm);
perm = new Permissions.Permission();
perm.setActions("read");
perm.setName("java.home");
perm.setClass("java.util.PropertyPermission");
perms.addConfiguredGrant(perm);
perm = new Permissions.Permission();
perm.setActions("read");
perm.setName("file.encoding");
perm.setClass("java.util.PropertyPermission");
perms.addConfiguredGrant(perm);
// Revoke permission to write user.home (granted above via user.*), still able to read though.
// and the default granted permission to read os.name.
perm = new Permissions.Permission();
perm.setActions("write");
perm.setName("user.home");
perm.setClass("java.util.PropertyPermission");
perms.addConfiguredRevoke(perm);
perm = new Permissions.Permission();
perm.setActions("read");
perm.setName("os.*");
perm.setClass("java.util.PropertyPermission");
perms.addConfiguredRevoke(perm);
|
public void | tearDown()
|
public void | testDefaultGranted()Tests a permission that is granted per default.
perms.setSecurityManager();
try {
String s = System.getProperty("line.separator");
} finally {
perms.restoreSecurityManager();
}
|
public void | testDefaultRevoked()Tests a permission that is granted as per default but revoked later via wildcard.
perms.setSecurityManager();
try {
System.getProperty("os.name");
fail("Could perform an action that should have been forbidden.");
} catch (SecurityException e){
// Was expected, test passes
} finally {
perms.restoreSecurityManager();
}
|
public void | testExit()Tests an exit condition.
perms.setSecurityManager();
try {
System.out.println("If this is the last line on standard out the testExit f.a.i.l.e.d");
System.exit(3);
fail("Totaly impossible that this fail is ever executed. Please let me know if it is!");
} catch (ExitException e) {
if (e.getStatus() != 3) {
fail("Received wrong exit status in Exit Exception.");
}
System.out.println("testExit successful.");
} finally {
perms.restoreSecurityManager();
}
|
public void | testGranted()Tests a permission that has been granted later via wildcard.
perms.setSecurityManager();
try {
String s = System.getProperty("user.name");
System.setProperty("user.name", s);
} finally {
perms.restoreSecurityManager();
}
|
public void | testGrantedAndRevoked()Tests a permission that has been granted and revoked later.
perms.setSecurityManager();
try {
String s = System.getProperty("user.home");
System.setProperty("user.home", s);
fail("Could perform an action that should have been forbidden.");
} catch (SecurityException e){
// Was expected, test passes
} finally {
perms.restoreSecurityManager();
}
|
public void | testOther()Tests a permission that has not been granted or revoked.
String ls = System.getProperty("line.separator");
perms.setSecurityManager();
try {
String s = System.setProperty("line.separator",ls);
fail("Could perform an action that should have been forbidden.");
} catch (SecurityException e){
// Was expected, test passes
} finally {
perms.restoreSecurityManager();
}
|