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