38. Execution flow PrivilegedAction action = new SampleAction(); // The call to Subject.doAsPrivileged is performed via: Subject.doAsPrivileged(mySubject, action, null); public class SampleAction implements PrivilegedAction { public Object run() { System.out.println("Your java.home property value is: " + System.getProperty("java.home")); System.out.println("Your user.home property value is: " + System.getProperty("user.home")); File f = new File("foo.txt"); System.out.print("foo.txt does "); if (!f.exists()) System.out.print("not "); System.out.println("exist in the current working directory."); return null; }}
39.
40.
41.
Notas del editor
LoginModule never gets called directly. Sun provides a few default LoginModule implementations such as the JNDILoginModule etc.
Maybe I should add another slide here to illustrate everything that happens when login() is called. This method is a little confusing at first because it results in the callbacks to be called, and that has a asynchronous feel to it (like one hand is acting independently of the other – one hand does not know what the other is doing).