AccessController.doPrivileged(new PrivilegedAction() ) : AccessController « Security « Java






AccessController.doPrivileged(new PrivilegedAction() )

 

import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedAction;


public class Main {

  
  static long getLastModified(final File f) {
      return ((Long)
              AccessController.doPrivileged(new PrivilegedAction() {
                  public Object run() {
                      return new Long(f.lastModified());
                  }
              })).longValue();
  }
  
}

   
  








Related examples in the same category

1.Use AccessController to check the file permission
2.Use AccessController to check the AWT permission
3.Make AccessibleObject Accessible
4. ClassLoader java.security.AccessController.doPrivileged(PrivilegedAction action)
5.Security Support
6.Load class
7.Search for resource in different places.
8.Lock request from going up in the classloader hierarchy