java.security
Class GuardedObject

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.GuardedObject
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class GuardedObject
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

A GuardedObject is an object that is used to protect access to another object.

A GuardedObject encapsulates a target object and a Guard object, such that access to the target object is possible only if the Guard object allows it. Once an object is encapsulated by a GuardedObject, access to that object is controlled by the getObject method, which invokes the checkGuard method on the Guard object that is guarding access. If access is not allowed, an exception is thrown.

See Also:
Guard sample code for java.security.Guard definition code for java.security.Guard , Permission sample code for java.security.Permission definition code for java.security.Permission , Serialized Form

Constructor Summary
GuardedObject sample code for java.security.GuardedObject.GuardedObject(java.lang.Object, java.security.Guard) definition code for java.security.GuardedObject.GuardedObject(java.lang.Object, java.security.Guard) (Object sample code for java.lang.Object definition code for java.lang.Object  object, Guard sample code for java.security.Guard definition code for java.security.Guard  guard)
          Constructs a GuardedObject using the specified object and guard.
 
Method Summary
 Object sample code for java.lang.Object definition code for java.lang.Object getObject sample code for java.security.GuardedObject.getObject() definition code for java.security.GuardedObject.getObject() ()
          Retrieves the guarded object, or throws an exception if access to the guarded object is denied by the guard.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

GuardedObject sample code for java.security.GuardedObject(java.lang.Object, java.security.Guard) definition code for java.security.GuardedObject(java.lang.Object, java.security.Guard)

public GuardedObject(Object sample code for java.lang.Object definition code for java.lang.Object  object,
                     Guard sample code for java.security.Guard definition code for java.security.Guard  guard)
Constructs a GuardedObject using the specified object and guard. If the Guard object is null, then no restrictions will be placed on who can access the object.

Parameters:
object - the object to be guarded.
guard - the Guard object that guards access to the object.
Method Detail

getObject sample code for java.security.GuardedObject.getObject() definition code for java.security.GuardedObject.getObject()

public Object sample code for java.lang.Object definition code for java.lang.Object  getObject()
                 throws SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException 
Retrieves the guarded object, or throws an exception if access to the guarded object is denied by the guard.

Returns:
the guarded object.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if access to the guarded object is denied.