1. /*
  2. * @(#)DomainCombiner.java 1.6 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security;
  8. /**
  9. * A <code>DomainCombiner</code> provides a means to dynamically
  10. * update the ProtectionDomains associated with the current
  11. * <code>AccessControlContext</code>.
  12. *
  13. * <p> A <code>DomainCombiner</code> is passed as a parameter to the
  14. * appropriate constructor for <code>AccessControlContext</code>.
  15. * The newly constructed context is then passed to the
  16. * <code>AccessController.doPrivileged(..., context)</code> method
  17. * to bind the provided context (and associated <code>DomainCombiner</code>)
  18. * with the current execution Thread. Subsequent calls to
  19. * <code>AccessController.getContext</code> or
  20. * <code>AccessController.checkPermission</code>
  21. * cause the <code>DomainCombiner.combine</code> to get invoked.
  22. *
  23. * <p> The combine method takes two arguments. The first argument represents
  24. * an array of ProtectionDomains from the current execution Thread,
  25. * since the most recent call to <code>AccessController.doPrivileged</code>.
  26. * If no call to doPrivileged was made, then the first argument will contain
  27. * all the ProtectionDomains from the current execution Thread.
  28. * The second argument represents an array of inherited ProtectionDomains,
  29. * which may be <code>null</code>. ProtectionDomains may be inherited
  30. * from a parent Thread, or from a privileged context. If no call to
  31. * doPrivileged was made, then the second argument will contain the
  32. * ProtectionDomains inherited from the parent Thread. If one or more calls
  33. * to doPrivileged were made, and the most recent call was to
  34. * doPrivileged(action, context), then the second argument will contain the
  35. * ProtectionDomains from the privileged context. If the most recent call
  36. * was to doPrivileged(action), then there is no privileged context,
  37. * and the second argument will be <code>null</code>.
  38. *
  39. * <p> The <code>combine</code> method investigates the two input arrays
  40. * of ProtectionDomains and returns a single array containing the updated
  41. * ProtectionDomains. In the simplest case, the <code>combine</code>
  42. * method merges the two stacks into one. In more complex cases,
  43. * the <code>combine</code> method returns a modified
  44. * stack of ProtectionDomains. The modification may have added new
  45. * ProtectionDomains, removed certain ProtectionDomains, or simply
  46. * updated existing ProtectionDomains. Re-ordering and other optimizations
  47. * to the ProtectionDomains are also permitted. Typically the
  48. * <code>combine</code> method bases its updates on the information
  49. * encapsulated in the <code>DomainCombiner</code>.
  50. *
  51. * <p> After the <code>AccessController.getContext</code> method
  52. * receives the combined stack of ProtectionDomains back from
  53. * the <code>DomainCombiner</code>, it returns a new
  54. * AccessControlContext that has both the combined ProtectionDomains
  55. * as well as the <code>DomainCombiner</code>.
  56. *
  57. * @see AccessController
  58. * @see AccessControlContext
  59. * @version 1.6, 01/23/03
  60. */
  61. public interface DomainCombiner {
  62. /**
  63. * Modify or update the provided ProtectionDomains.
  64. * ProtectionDomains may be added to or removed from the given
  65. * ProtectionDomains. The ProtectionDomains may be re-ordered.
  66. * Individual ProtectionDomains may be may be modified (with a new
  67. * set of Permissions, for example).
  68. *
  69. * <p>
  70. *
  71. * @param currentDomains the ProtectionDomains associated with the
  72. * current execution Thread, up to the most recent
  73. * privileged <code>ProtectionDomain</code>.
  74. * The ProtectionDomains are are listed in order of execution,
  75. * with the most recently executing <code>ProtectionDomain</code>
  76. * residing at the beginning of the array. This parameter may
  77. * be <code>null</code> if the current execution Thread
  78. * has no associated ProtectionDomains.<p>
  79. *
  80. * @param assignedDomains an array of inherited ProtectionDomains.
  81. * ProtectionDomains may be inherited from a parent Thread,
  82. * or from a privileged <code>AccessControlContext</code>.
  83. * This parameter may be <code>null</code>
  84. * if there are no inherited ProtectionDomains.
  85. *
  86. * @return a new array consisting of the updated ProtectionDomains,
  87. * or <code>null</code>.
  88. */
  89. ProtectionDomain[] combine(ProtectionDomain[] currentDomains,
  90. ProtectionDomain[] assignedDomains);
  91. }