jdk/src/share/classes/java/security/DomainCombiner.java
author juh
Fri, 28 Jun 2013 10:48:02 -0700
changeset 18579 b678846778ad
parent 5506 202f599c92aa
permissions -rw-r--r--
8019360: Cleanup of the javadoc <code> tag in java.security.* Summary: Convert to {@code ...} tags. convert package.html to package-info.java. Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    29
 * A {@code DomainCombiner} provides a means to dynamically
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * update the ProtectionDomains associated with the current
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    31
 * {@code AccessControlContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    33
 * <p> A {@code DomainCombiner} is passed as a parameter to the
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    34
 * appropriate constructor for {@code AccessControlContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * The newly constructed context is then passed to the
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    36
 * {@code AccessController.doPrivileged(..., context)} method
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    37
 * to bind the provided context (and associated {@code DomainCombiner})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * with the current execution Thread.  Subsequent calls to
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    39
 * {@code AccessController.getContext} or
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    40
 * {@code AccessController.checkPermission}
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    41
 * cause the {@code DomainCombiner.combine} to get invoked.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p> The combine method takes two arguments.  The first argument represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * an array of ProtectionDomains from the current execution Thread,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    45
 * since the most recent call to {@code AccessController.doPrivileged}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * If no call to doPrivileged was made, then the first argument will contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * all the ProtectionDomains from the current execution Thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * The second argument represents an array of inherited ProtectionDomains,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    49
 * which may be {@code null}.  ProtectionDomains may be inherited
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * from a parent Thread, or from a privileged context.  If no call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * doPrivileged was made, then the second argument will contain the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * ProtectionDomains inherited from the parent Thread.  If one or more calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * to doPrivileged were made, and the most recent call was to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * doPrivileged(action, context), then the second argument will contain the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * ProtectionDomains from the privileged context.  If the most recent call
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * was to doPrivileged(action), then there is no privileged context,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    57
 * and the second argument will be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    59
 * <p> The {@code combine} method investigates the two input arrays
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * of ProtectionDomains and returns a single array containing the updated
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    61
 * ProtectionDomains.  In the simplest case, the {@code combine}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * method merges the two stacks into one.  In more complex cases,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    63
 * the {@code combine} method returns a modified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * stack of ProtectionDomains.  The modification may have added new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * ProtectionDomains, removed certain ProtectionDomains, or simply
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * updated existing ProtectionDomains.  Re-ordering and other optimizations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * to the ProtectionDomains are also permitted.  Typically the
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    68
 * {@code combine} method bases its updates on the information
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    69
 * encapsulated in the {@code DomainCombiner}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    71
 * <p> After the {@code AccessController.getContext} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * receives the combined stack of ProtectionDomains back from
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    73
 * the {@code DomainCombiner}, it returns a new
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * AccessControlContext that has both the combined ProtectionDomains
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    75
 * as well as the {@code DomainCombiner}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * @see AccessController
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @see AccessControlContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
public interface DomainCombiner {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Modify or update the provided ProtectionDomains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * ProtectionDomains may be added to or removed from the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * ProtectionDomains.  The ProtectionDomains may be re-ordered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Individual ProtectionDomains may be modified (with a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * set of Permissions, for example).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param currentDomains the ProtectionDomains associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *          current execution Thread, up to the most recent
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    94
     *          privileged {@code ProtectionDomain}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *          The ProtectionDomains are are listed in order of execution,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    96
     *          with the most recently executing {@code ProtectionDomain}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *          residing at the beginning of the array. This parameter may
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    98
     *          be {@code null} if the current execution Thread
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *          has no associated ProtectionDomains.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param assignedDomains an array of inherited ProtectionDomains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *          ProtectionDomains may be inherited from a parent Thread,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   103
     *          or from a privileged {@code AccessControlContext}.
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   104
     *          This parameter may be {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *          if there are no inherited ProtectionDomains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @return a new array consisting of the updated ProtectionDomains,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   108
     *          or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    ProtectionDomain[] combine(ProtectionDomain[] currentDomains,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                ProtectionDomain[] assignedDomains);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
}