new PropertyPermission(not_a_property, "write")};
Permission[] setSecurityManager = new Permission[] {
new RuntimePermission("setSecurityManager")};
TestSecurityManager sm = new TestSecurityManager(harness);
try {
sm.install();
// throwpoint: java.lang.System-exit
harness.checkPoint("exit");
try {
sm.prepareHaltingChecks(exitVM);
System.exit(0);
harness.check(false);
}
catch (TestSecurityManager.SuccessException ex) {
harness.check(true);
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-runFinalizersOnExit
harness.checkPoint("runFinalizersOnExit");
try {
sm.prepareChecks(exitVM);
System.runFinalizersOnExit(false);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-load
harness.checkPoint("load");
try {
sm.prepareHaltingChecks(loadLibrary_name);
System.load(library_name);
harness.check(false);
}
catch (TestSecurityManager.SuccessException ex) {
harness.check(true);
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-loadLibrary
harness.checkPoint("loadLibrary");
try {
sm.prepareHaltingChecks(loadLibrary_path);
System.loadLibrary(library_path);
harness.check(false);
}
catch (TestSecurityManager.SuccessException ex) {
harness.check(true);
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: TODO: java.lang.System-getenv()
// throwpoint: java.lang.System-getenv(String)
harness.checkPoint("getenv(String)");
try {
sm.prepareChecks(readVariable);
System.getenv(a_variable);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(readNonVariable);
System.getenv(not_a_variable);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-getProperties
harness.checkPoint("getProperties");
try {
sm.prepareChecks(readWriteAllProperties);
System.getProperties();
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-setProperties
harness.checkPoint("setProperties");
try {
sm.prepareChecks(readWriteAllProperties);
System.setProperties(properties);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-getProperty(String)
harness.checkPoint("getProperty(String)");
try {
sm.prepareChecks(readProperty);
System.getProperty(a_property);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(readNonProperty);
System.getProperty(not_a_property);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-getProperty(String, String)
harness.checkPoint("getProperty(String, String)");
try {
sm.prepareChecks(readProperty);
System.getProperty(a_property, "quadrant");
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(readNonProperty);
System.getProperty(not_a_property, "blade");
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-setIn
harness.checkPoint("setIn");
try {
sm.prepareChecks(setIO);
System.setIn(System.in);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-setOut
harness.checkPoint("setOut");
try {
sm.prepareChecks(setIO);
System.setOut(System.out);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-setErr
harness.checkPoint("setErr");
try {
sm.prepareChecks(setIO);
System.setErr(System.err);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: java.lang.System-setProperty
harness.checkPoint("setProperty");
try {
sm.prepareChecks(writeProperty);
System.setProperty(a_property, properties.getProperty(a_property));
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
try {
sm.prepareChecks(writeNonProperty);
System.setProperty(not_a_property, "hello mum");
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
// throwpoint: TODO: java.lang.System-clearProperty
// throwpoint: java.lang.System-setSecurityManager
harness.checkPoint("setSecurityManager");
try {
sm.prepareChecks(setSecurityManager);
System.setSecurityManager(sm);
sm.checkAllChecked();
}
catch (SecurityException ex) {
harness.debug(ex);
harness.check(false, "unexpected check");
}
}
finally {
sm.uninstall();
}
}
catch (Exception ex) {
harness.debug(ex);
harness.check(false, "Unexpected exception");