src/java.security.jgss/share/classes/javax/security/auth/kerberos/ServicePermission.java
author weijun
Tue, 29 Oct 2019 09:34:23 +0800
changeset 58831 b026a43e1809
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231365: ServicePermission::equals doesn't comply to the spec 8231196: DelegationPermission allows to create an instance that thows NPE on ::equals call Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58831
b026a43e1809 8231365: ServicePermission::equals doesn't comply to the spec
weijun
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2019, 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 javax.security.auth.kerberos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
    28
import java.io.IOException;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
    29
import java.io.ObjectInputStream;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
    30
import java.io.ObjectOutputStream;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
    31
import java.io.ObjectStreamField;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.Permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.PermissionCollection;
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
    34
import java.util.*;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
    35
import java.util.concurrent.ConcurrentHashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This class is used to protect Kerberos services and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * credentials necessary to access those services. There is a one to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * one mapping of a service principal and the credentials necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * to access the service. Therefore granting access to a service
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * principal implicitly grants access to the credential necessary to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * establish a security context with the service principal. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * applies regardless of whether the credentials are in a cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * or acquired via an exchange with the KDC. The credential can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * be either a ticket granting ticket, a service ticket or a secret
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * key from a key table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * A ServicePermission contains a service principal name and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * a list of actions which specify the context the credential can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * used within.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * The service principal name is the canonical name of the
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
    54
 * {@code KerberosPrincipal} supplying the service, that is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * the KerberosPrincipal represents a Kerberos service
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * principal. This name is treated in a case sensitive manner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * An asterisk may appear by itself, to signify any service principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * Granting this permission implies that the caller can use a cached
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * credential (TGT, service ticket or secret key) within the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * designated by the action. In the case of the TGT, granting this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * permission also implies that the TGT can be obtained by an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * Authentication Service exchange.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <p>
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
    65
 * Granting this permission also implies creating {@link KerberosPrincipal}
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
    66
 * or {@link org.ietf.jgss.GSSName GSSName} without providing a Kerberos
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
    67
 * realm, as long as the permission's service principal is in this realm.
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
    68
 * <p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * The possible actions are:
21955
abc02575919c 8029475: Fix more doclint issues in javax.security
darcy
parents: 18830
diff changeset
    70
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *    initiate -              allow the caller to use the credential to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *                            initiate a security context with a service
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *                            principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *    accept -                allow the caller to use the credential to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *                            accept security context as a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *                            principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * For example, to specify the permission to access to the TGT to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * initiate a security context the permission is constructed as follows:
21955
abc02575919c 8029475: Fix more doclint issues in javax.security
darcy
parents: 18830
diff changeset
    83
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *     ServicePermission("krbtgt/EXAMPLE.COM@EXAMPLE.COM", "initiate");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * To obtain a service ticket to initiate a context with the "host"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * service the permission is constructed as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *     ServicePermission("host/foo.example.com@EXAMPLE.COM", "initiate");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * For a Kerberized server the action is "accept". For example, the permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * necessary to access and use the secret key of the  Kerberized "host"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * service (telnet and the likes)  would be constructed as follows:
21955
abc02575919c 8029475: Fix more doclint issues in javax.security
darcy
parents: 18830
diff changeset
    97
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *     ServicePermission("host/foo.example.com@EXAMPLE.COM", "accept");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
public final class ServicePermission extends Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    private static final long serialVersionUID = -1227585031618624935L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Initiate a security context to the specified service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    private final static int INITIATE   = 0x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * Accept a security context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private final static int ACCEPT     = 0x2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * All actions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private final static int ALL        = INITIATE|ACCEPT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * No actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    private final static int NONE    = 0x0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    // the actions mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    private transient int mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * the actions string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private String actions; // Left null as long as possible, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                            // created and re-used in the getAction function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   143
     * Create a new {@code ServicePermission}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   144
     * with the specified {@code servicePrincipal}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 14342
diff changeset
   145
     * and {@code action}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param servicePrincipal the name of the service principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * An asterisk may appear by itself, to signify any service principal.
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   149
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param action the action string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public ServicePermission(String servicePrincipal, String action) {
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   153
        // Note: servicePrincipal can be "@REALM" which means any principal in
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   154
        // this realm implies it. action can be "-" which means any
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   155
        // action implies it.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        super(servicePrincipal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        init(servicePrincipal, getMask(action));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   160
    /**
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   161
     * Creates a ServicePermission object with the specified servicePrincipal
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   162
     * and a pre-calculated mask. Avoids the overhead of re-computing the mask.
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   163
     * Called by ServicePermissionCollection.
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   164
     */
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   165
    ServicePermission(String servicePrincipal, int mask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   166
        super(servicePrincipal);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   167
        init(servicePrincipal, mask);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   168
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Initialize the ServicePermission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    private void init(String servicePrincipal, int mask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (servicePrincipal == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                throw new NullPointerException("service principal can't be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if ((mask & ALL) != mask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            throw new IllegalArgumentException("invalid actions mask");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        this.mask = mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Checks if this Kerberos service permission object "implies" the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * specified permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <P>
32424
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   189
     * More specifically, this method returns true if all of the following
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   190
     * are true (and returns false if any of them are not):
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   191
     * <ul>
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   192
     * <li> <i>p</i> is an instanceof {@code ServicePermission},
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   193
     * <li> <i>p</i>'s actions are a proper subset of this
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   194
     * {@code ServicePermission}'s actions,
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   195
     * <li> <i>p</i>'s name is equal to this {@code ServicePermission}'s name
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   196
     * or this {@code ServicePermission}'s name is "*".
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   197
     * </ul>
2d9d66d0519f 8129789: implies() of ServicePermission and DelegationPermission underspecified
weijun
parents: 31538
diff changeset
   198
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @param p the permission to check against.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @return true if the specified permission is implied by this object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * false if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   204
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public boolean implies(Permission p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        if (!(p instanceof ServicePermission))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        ServicePermission that = (ServicePermission) p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        return ((this.mask & that.mask) == that.mask) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            impliesIgnoreMask(that);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    boolean impliesIgnoreMask(ServicePermission p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        return ((this.getName().equals("*")) ||
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   218
                this.getName().equals(p.getName()) ||
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   219
                (p.getName().startsWith("@") &&
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   220
                        this.getName().endsWith(p.getName())));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Checks two ServicePermission objects for equality.
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   225
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param obj the object to test for equality with this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   228
     * @return true if {@code obj} is a ServicePermission, and has the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *  same service principal, and actions as this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * ServicePermission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   232
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (obj == this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        if (! (obj instanceof ServicePermission))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        ServicePermission that = (ServicePermission) obj;
58831
b026a43e1809 8231365: ServicePermission::equals doesn't comply to the spec
weijun
parents: 47216
diff changeset
   241
        return (this.mask == that.mask) &&
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            this.getName().equals(that.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * Returns the hash code value for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @return a hash code value for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   252
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return (getName().hashCode() ^ mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Returns the "canonical string representation" of the actions in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * specified mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Always returns present actions in the following order:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * initiate, accept.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @param mask a specific integer action mask to translate into a string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @return the canonical string representation of the actions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   267
    static String getActions(int mask)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        StringBuilder sb = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        boolean comma = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        if ((mask & INITIATE) == INITIATE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            if (comma) sb.append(',');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            else comma = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            sb.append("initiate");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if ((mask & ACCEPT) == ACCEPT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            if (comma) sb.append(',');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            else comma = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            sb.append("accept");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Returns the canonical string representation of the actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Always returns present actions in the following order:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * initiate, accept.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   292
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public String getActions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        if (actions == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            actions = getActions(this.mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        return actions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Returns a PermissionCollection object for storing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * ServicePermission objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * ServicePermission objects must be stored in a manner that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * allows them to be inserted into the collection in any order, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * that also enables the PermissionCollection implies method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * be implemented in an efficient (and consistent) manner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @return a new PermissionCollection object suitable for storing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * ServicePermissions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   313
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    public PermissionCollection newPermissionCollection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        return new KrbServicePermissionCollection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * Return the current action mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * @return the actions mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    int getMask() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        return mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * Convert an action string to an integer actions mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   330
     * Note: if action is "-", action will be NONE, which means any
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   331
     * action implies it.
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   332
     *
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   333
     * @param action the action string.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @return the action mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    private static int getMask(String action) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        if (action == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            throw new NullPointerException("action can't be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        if (action.equals("")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            throw new IllegalArgumentException("action can't be empty");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        int mask = NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        char[] a = action.toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   350
        if (a.length == 1 && a[0] == '-') {
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   351
            return mask;
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   352
        }
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   353
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        int i = a.length - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        while (i != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            char c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            // skip whitespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            while ((i!=-1) && ((c = a[i]) == ' ' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                               c == '\r' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                               c == '\n' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                               c == '\f' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                               c == '\t'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                i--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            // check for the known strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            int matchlen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            if (i >= 7 && (a[i-7] == 'i' || a[i-7] == 'I') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                          (a[i-6] == 'n' || a[i-6] == 'N') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                          (a[i-5] == 'i' || a[i-5] == 'I') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                          (a[i-4] == 't' || a[i-4] == 'T') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                          (a[i-3] == 'i' || a[i-3] == 'I') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                          (a[i-2] == 'a' || a[i-2] == 'A') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                          (a[i-1] == 't' || a[i-1] == 'T') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                          (a[i] == 'e' || a[i] == 'E'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                matchlen = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                mask |= INITIATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            } else if (i >= 5 && (a[i-5] == 'a' || a[i-5] == 'A') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                                 (a[i-4] == 'c' || a[i-4] == 'C') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                                 (a[i-3] == 'c' || a[i-3] == 'C') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                                 (a[i-2] == 'e' || a[i-2] == 'E') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                                 (a[i-1] == 'p' || a[i-1] == 'P') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                                 (a[i] == 't' || a[i] == 'T'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                matchlen = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                mask |= ACCEPT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                // parse error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                throw new IllegalArgumentException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                        "invalid permission: " + action);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            // make sure we didn't just match the tail of a word
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            // like "ackbarfaccept".  Also, skip to the comma.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            boolean seencomma = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            while (i >= matchlen && !seencomma) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                switch(a[i-matchlen]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                case ',':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                    seencomma = true;
11131
27747ee5a62a 7116857: Warnings in javax.security and some sun.misc
weijun
parents: 10709
diff changeset
   405
                    break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                case ' ': case '\r': case '\n':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                case '\f': case '\t':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                    throw new IllegalArgumentException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                            "invalid permission: " + action);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                i--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            // point i at the location of the comma minus one (or -1).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            i -= matchlen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        return mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * WriteObject is called to save the state of the ServicePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * to a stream. The actions are serialized, and the superclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * takes care of the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    private void writeObject(java.io.ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        // Write out the actions. The superclass takes care of the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        // call getActions to make sure actions field is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        if (actions == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            getActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * readObject is called to restore the state of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * ServicePermission from a stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    private void readObject(java.io.ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
         throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        // Read in the action, then initialize the rest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        init(getName(),getMask(actions));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    /*
31538
0981099a3e54 8130022: Use Java-style array declarations consistently
igerasim
parents: 31080
diff changeset
   453
      public static void main(String[] args) throws Exception {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
      ServicePermission this_ =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
      new ServicePermission(args[0], "accept");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
      ServicePermission that_ =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
      new ServicePermission(args[1], "accept,initiate");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
      System.out.println("-----\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
      System.out.println("this.implies(that) = " + this_.implies(that_));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
      System.out.println("-----\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
      System.out.println("this = "+this_);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
      System.out.println("-----\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
      System.out.println("that = "+that_);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
      System.out.println("-----\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
      KrbServicePermissionCollection nps =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
      new KrbServicePermissionCollection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
      nps.add(this_);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
      nps.add(new ServicePermission("nfs/example.com@EXAMPLE.COM",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
      "accept"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
      nps.add(new ServicePermission("host/example.com@EXAMPLE.COM",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
      "initiate"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
      System.out.println("nps.implies(that) = " + nps.implies(that_));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
      System.out.println("-----\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
      Enumeration e = nps.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
      while (e.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
      ServicePermission x =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
      (ServicePermission) e.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
      System.out.println("nps.e = " + x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
final class KrbServicePermissionCollection extends PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   493
    // Key is the service principal, value is the ServicePermission.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    // Not serialized; see serialization section at end of class
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   495
    private transient ConcurrentHashMap<String, Permission> perms;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public KrbServicePermissionCollection() {
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   498
        perms = new ConcurrentHashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * Check and see if this collection of permissions implies the permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * expressed in "permission".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 11131
diff changeset
   505
     * @param permission the Permission object to compare
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * @return true if "permission" is a proper subset of a permission in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * the collection, false if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   510
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    public boolean implies(Permission permission) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        if (! (permission instanceof ServicePermission))
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   513
            return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        ServicePermission np = (ServicePermission) permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        int desired = np.getMask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   518
        if (desired == 0) {
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   519
            for (Permission p: perms.values()) {
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   520
                ServicePermission sp = (ServicePermission)p;
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   521
                if (sp.impliesIgnoreMask(np)) {
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   522
                    return true;
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   523
                }
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   524
            }
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   525
            return false;
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   526
        }
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   527
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32424
diff changeset
   528
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   529
        // first, check for wildcard principal
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   530
        ServicePermission x = (ServicePermission)perms.get("*");
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   531
        if (x != null) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   532
            if ((x.getMask() & desired) == desired) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   533
                return true;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   534
            }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   535
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   537
        // otherwise, check for match on principal
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   538
        x = (ServicePermission)perms.get(np.getName());
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   539
        if (x != null) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   540
            //System.out.println("  trying "+x);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   541
            if ((x.getMask() & desired) == desired) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   542
                return true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * Adds a permission to the ServicePermissions. The key for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * the hash is the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * @param permission the Permission object to add.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @exception IllegalArgumentException - if the permission is not a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *                                       ServicePermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @exception SecurityException - if this PermissionCollection object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *                                has been marked readonly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   560
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    public void add(Permission permission) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        if (! (permission instanceof ServicePermission))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            throw new IllegalArgumentException("invalid permission: "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                                               permission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        if (isReadOnly())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   568
        ServicePermission sp = (ServicePermission)permission;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   569
        String princName = sp.getName();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   570
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   571
        // Add permission to map if it is absent, or replace with new
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   572
        // permission if applicable. NOTE: cannot use lambda for
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   573
        // remappingFunction parameter until JDK-8076596 is fixed.
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   574
        perms.merge(princName, sp,
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   575
            new java.util.function.BiFunction<>() {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   576
                @Override
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   577
                public Permission apply(Permission existingVal,
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   578
                                        Permission newVal) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   579
                    int oldMask = ((ServicePermission)existingVal).getMask();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   580
                    int newMask = ((ServicePermission)newVal).getMask();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   581
                    if (oldMask != newMask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   582
                        int effective = oldMask | newMask;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   583
                        if (effective == newMask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   584
                            return newVal;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   585
                        }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   586
                        if (effective != oldMask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   587
                            return new ServicePermission(princName, effective);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   588
                        }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   589
                    }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   590
                    return existingVal;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   591
                }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   592
            }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   593
        );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * Returns an enumeration of all the ServicePermission objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * in the container.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @return an enumeration of all the ServicePermission objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   602
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    public Enumeration<Permission> elements() {
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   604
        return perms.elements();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    private static final long serialVersionUID = -4118834211490102011L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    // Need to maintain serialization interoperability with earlier releases,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    // which had the serializable field:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    // private Vector permissions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * @serialField permissions java.util.Vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     *     A list of ServicePermission objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    private static final ObjectStreamField[] serialPersistentFields = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        new ObjectStreamField("permissions", Vector.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @serialData "permissions" field (a Vector containing the ServicePermissions).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * Writes the contents of the perms field out as a Vector for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * serialization compatibility with earlier releases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    private void writeObject(ObjectOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        // Don't call out.defaultWriteObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        // Write out Vector
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   632
        Vector<Permission> permissions = new Vector<>(perms.values());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        ObjectOutputStream.PutField pfields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        pfields.put("permissions", permissions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * Reads in a Vector of ServicePermissions and saves them in the perms field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     */
10709
d865c9f21240 7092375: Security Libraries don't build with javac -Werror
xuelei
parents: 9035
diff changeset
   642
    @SuppressWarnings("unchecked")
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 11131
diff changeset
   643
    private void readObject(ObjectInputStream in)
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 11131
diff changeset
   644
        throws IOException, ClassNotFoundException
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 11131
diff changeset
   645
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        // Don't call defaultReadObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        // Read in serialized fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        ObjectInputStream.GetField gfields = in.readFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        // Get the one we want
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        Vector<Permission> permissions =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                (Vector<Permission>)gfields.get("permissions", null);
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   654
        perms = new ConcurrentHashMap<>(permissions.size());
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   655
        for (Permission perm : permissions) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   656
            perms.put(perm.getName(), perm);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 29492
diff changeset
   657
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
}