Controlling Access to an Object using a permission : Permission « Security « Java

Controlling Access to an Object using a permission


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) {


Related examples in the same category

1.Checking Read/Write Permission for a Directory
2.Determining If One Permission Implies Another
3.Creating a Custom Permission
4.extends BasicPermission
5.boolean Permission.implies(Permission permission)
6.Guard guard = new PropertyPermission("java.home", "read");
7.Listing All Permissions Granted to a Loaded Class GuardedObject(Object obj, Guard)
9.Object GuardedObject.getObject()
10.Execution of reflection