Java Tutorial/Security/GuardedObject
Версия от 17:44, 31 мая 2010; (обсуждение)
Guard guard = new PropertyPermission(java.home, read);
import java.security.AccessControlException;
import java.security.Guard;
import java.security.GuardedObject;
import java.util.PropertyPermission;
public class Main {
public static void main(String[] argv) throws Exception {
String secretObj = "secret";
Guard guard = new PropertyPermission("java.home", "read");
GuardedObject gobj = new GuardedObject(secretObj, guard);
try {
Object o = gobj.getObject();
} catch (AccessControlException e) {
e.printStackTrace();
}
}
}
new GuardedObject(Object obj, Guard)
import java.security.AccessControlException;
import java.security.Guard;
import java.security.GuardedObject;
import java.util.PropertyPermission;
public class Main {
public static void main(String[] argv) throws Exception {
String secretObj = "secret";
Guard guard = new PropertyPermission("java.home", "read");
GuardedObject gobj = new GuardedObject(secretObj, guard);
try {
Object o = gobj.getObject();
} catch (AccessControlException e) {
e.printStackTrace();
}
}
}
Object GuardedObject.getObject()
import java.security.AccessControlException;
import java.security.Guard;
import java.security.GuardedObject;
import java.util.PropertyPermission;
public class Main {
public static void main(String[] argv) throws Exception {
String secretObj = "secret";
Guard guard = new PropertyPermission("java.home", "read");
GuardedObject gobj = new GuardedObject(secretObj, guard);
try {
Object o = gobj.getObject();
} catch (AccessControlException e) {
e.printStackTrace();
}
}
}