Example usage for java.security GuardedObject getObject

List of usage examples for java.security GuardedObject getObject

Introduction

In this page you can find the example usage for java.security GuardedObject getObject.

Prototype

public Object getObject() throws SecurityException 

Source Link

Document

Retrieves the guarded object, or throws an exception if access to the guarded object is denied by the guard.

Usage

From source file:Main.java

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 {/*w ww.  ja va  2 s  .  com*/
        Object o = gobj.getObject();
    } catch (AccessControlException e) {
        e.printStackTrace();
    }
}