Package com.thoughtworks.proxy.toys.privilege

A toy to run method calls as privileged actions.

See:
          Description

Interface Summary
ActionExecutor Interface to execute a PrivilegedExceptionAction.
 

Class Summary
AccessControllerExecutor Execution of a PrivilegedExceptionAction with the AccessController.
DirectExecutor Direct execution of a PrivilegedExceptionAction.
Privileging<T> Toy factory to create proxies executing the method calls as privileged actions.
Privileging.PrivilegingBuild<T>  
Privileging.PrivilegingExecutedByOrBuild<T>  
Privileging.PrivilegingWith<T>  
PrivilegingInvoker<T> Invoker that creates for the invoked method a PrivilegedExceptionAction and runs this action with the provided ActionExecutor.
SubjectExecutor Execution of a PrivilegedExceptionAction with a Subject.
 

Package com.thoughtworks.proxy.toys.privilege Description

A toy to run method calls as privileged actions.

The package provides a proxy factory creating proxies, that wrap each method call into a security.PrivilegedExceptionAction and pass this action to a user provided ActionExecutor. The toy is delivered with three predefined action executors:

The following using the AccessController to perform privileged read actions on the file:

File file = Privileging.proxy(new File("src/main/java/" + PoolToyExample.class.getName().replace('.', '/') + ".java"))
        .executedBy(new AccessControllerExecutor())
        .build(new CglibProxyFactory());
LineNumberReader reader = new LineNumberReader(new FileReader(file), 16 * 1024);
while (reader.readLine() != null);
System.out.println("Lines of code: " + reader.getLineNumber());
reader.close();



Copyright © 2005-2010 Codehaus. All Rights Reserved.