1. /*
  2. * @(#)PrivilegedExceptionAction.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, that throws one or
  10. * more checked exceptions. The computation is performed by invoking
  11. * <code>AccessController.doPrivileged</code> on the
  12. * <code>PrivilegedExceptionAction</code> object. This interface is
  13. * used only for computations that throw checked exceptions;
  14. * computations that do not throw
  15. * checked exceptions should use <code>PrivilegedAction</code> instead.
  16. *
  17. * @see AccessController
  18. * @see AccessController#doPrivileged(PrivilegedExceptionAction)
  19. * @see AccessController#doPrivileged(PrivilegedExceptionAction,
  20. * AccessControlContext)
  21. * @see PrivilegedAction
  22. */
  23. public interface PrivilegedExceptionAction<T> {
  24. /**
  25. * Performs the computation. This method will be called by
  26. * <code>AccessController.doPrivileged</code> after enabling privileges.
  27. *
  28. * @return a class-dependent value that may represent the results of the
  29. * computation. Each class that implements
  30. * <code>PrivilegedExceptionAction</code> should document what
  31. * (if anything) this value represents.
  32. * @throws Exception an exceptional condition has occurred. Each class
  33. * that implements <code>PrivilegedExceptionAction</code> should
  34. * document the exceptions that its run method can throw.
  35. * @see AccessController#doPrivileged(PrivilegedExceptionAction)
  36. * @see AccessController#doPrivileged(PrivilegedExceptionAction,AccessControlContext)
  37. */
  38. T run() throws Exception;
  39. }