1. /*
  2. * @(#)PrivilegedAction.java 1.10 04/05/05
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security;
  8. /**
  9. * A computation to be performed with privileges enabled. The computation is
  10. * performed by invoking <code>AccessController.doPrivileged</code> on the
  11. * <code>PrivilegedAction</code> object. This interface is used only for
  12. * computations that do not throw checked exceptions; computations that
  13. * throw checked exceptions must use <code>PrivilegedExceptionAction</code>
  14. * instead.
  15. *
  16. * @see AccessController
  17. * @see AccessController#doPrivileged(PrivilegedAction)
  18. * @see PrivilegedExceptionAction
  19. */
  20. public interface PrivilegedAction<T> {
  21. /**
  22. * Performs the computation. This method will be called by
  23. * <code>AccessController.doPrivileged</code> after enabling privileges.
  24. *
  25. * @return a class-dependent value that may represent the results of the
  26. * computation. Each class that implements
  27. * <code>PrivilegedAction</code>
  28. * should document what (if anything) this value represents.
  29. * @see AccessController#doPrivileged(PrivilegedAction)
  30. * @see AccessController#doPrivileged(PrivilegedAction,
  31. * AccessControlContext)
  32. */
  33. T run();
  34. }