src/java.base/share/classes/java/util/PropertyPermission.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58659 4113f16d5109
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 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 java.util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
    28
import java.io.IOException;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
    29
import java.io.ObjectInputStream;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
    30
import java.io.ObjectOutputStream;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
    31
import java.io.ObjectStreamField;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Hashtable;
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
    36
import java.util.concurrent.ConcurrentHashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.security.util.SecurityConstants;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * This class is for property permissions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * The name is the name of the property ("java.home",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * "os.name", etc). The naming
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * convention follows the  hierarchical property naming convention.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Also, an asterisk
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * may appear at the end of the name, following a ".", or by itself, to
14667
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents: 14014
diff changeset
    48
 * signify a wildcard match. For example: "java.*" and "*" signify a wildcard
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents: 14014
diff changeset
    49
 * match, while "*java" and "a*b" do not.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * The actions to be granted are passed to the constructor in a string containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * a list of one or more comma-separated keywords. The possible keywords are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * "read" and "write". Their meaning is defined as follows:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 14668
diff changeset
    54
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <DL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *    <DT> read
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    57
 *    <DD> read permission. Allows {@code System.getProperty} to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *         be called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *    <DT> write
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    60
 *    <DD> write permission. Allows {@code System.setProperty} to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *         be called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * </DL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * The actions string is converted to lowercase before processing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * Care should be taken before granting code permission to access
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * certain system properties.  For example, granting permission to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * access the "java.home" system property gives potentially malevolent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * code sensitive information about the system environment (the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * installation directory).  Also, granting permission to access
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * the "user.name" and "user.home" system properties gives potentially
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * malevolent code sensitive information about the user environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * (the user's account name and home directory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * @see java.security.BasicPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @see java.security.Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * @see java.security.Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @see java.security.PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * @see java.lang.SecurityManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * @author Roland Schemers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * @serial exclude
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
public final class PropertyPermission extends BasicPermission {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Read action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31080
diff changeset
    93
    private static final int READ    = 0x1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Write action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31080
diff changeset
    98
    private static final int WRITE   = 0x2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * All actions (read,write);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31080
diff changeset
   102
    private static final int ALL     = READ|WRITE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * No actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31080
diff changeset
   106
    private static final int NONE    = 0x0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * The actions mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private transient int mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * The actions string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private String actions; // Left null as long as possible, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                            // created and re-used in the getAction function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * initialize a PropertyPermission object. Common to all constructors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Also called during de-serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param mask the actions mask to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   129
    private void init(int mask) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        if ((mask & ALL) != mask)
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   131
            throw new IllegalArgumentException("invalid actions mask");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        if (mask == NONE)
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   134
            throw new IllegalArgumentException("invalid actions mask");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (getName() == null)
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   137
            throw new NullPointerException("name can't be null");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        this.mask = mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Creates a new PropertyPermission object with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * The name is the name of the system property, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <i>actions</i> contains a comma-separated list of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * desired actions granted on the property. Possible actions are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * "read" and "write".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param name the name of the PropertyPermission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param actions the actions string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   152
     * @throws NullPointerException if {@code name} is {@code null}.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   153
     * @throws IllegalArgumentException if {@code name} is empty or if
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   154
     * {@code actions} is invalid.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   156
    public PropertyPermission(String name, String actions) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        super(name,actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        init(getMask(actions));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   162
     * Creates a PropertyPermission object with the specified name and
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   163
     * a pre-calculated mask. Avoids the overhead of re-computing the mask.
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   164
     * Called by PropertyPermissionCollection.
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   165
     */
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   166
    PropertyPermission(String name, int mask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   167
        super(name, getActions(mask));
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   168
        this.mask = mask;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   169
    }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   170
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   171
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Checks if this PropertyPermission object "implies" the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <P>
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 14668
diff changeset
   175
     * More specifically, this method returns true if:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * <ul>
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 14668
diff changeset
   177
     * <li> <i>p</i> is an instanceof PropertyPermission,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * <li> <i>p</i>'s actions are a subset of this
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 14668
diff changeset
   179
     * object's actions, and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * <li> <i>p</i>'s name is implied by this object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *      name. For example, "java.*" implies "java.home".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @param p the permission to check against.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @return true if the specified permission is implied by this object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * false if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   188
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public boolean implies(Permission p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        if (!(p instanceof PropertyPermission))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        PropertyPermission that = (PropertyPermission) p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        // we get the effective mask. i.e., the "and" of this and that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        // They must be equal to that.mask for implies to return true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return ((this.mask & that.mask) == that.mask) && super.implies(that);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * Checks two PropertyPermission objects for equality. Checks that <i>obj</i> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * a PropertyPermission, and has the same name and actions as this object.
24196
61c9885d76e2 8029451: Tidy warnings cleanup for java.util package; minor changes in java.nio, java.sql
yan
parents: 23010
diff changeset
   204
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @param obj the object we are testing for equality with this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @return true if obj is a PropertyPermission, and has the same name and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * actions as this PropertyPermission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   209
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if (obj == this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (! (obj instanceof PropertyPermission))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        PropertyPermission that = (PropertyPermission) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return (this.mask == that.mask) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            (this.getName().equals(that.getName()));
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
     * Returns the hash code value for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * The hash code used is the hash code of this permissions name, that is,
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   226
     * {@code getName().hashCode()}, where {@code getName} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * from the Permission superclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @return a hash code value for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   231
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return this.getName().hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Converts an actions String to an actions mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   239
     * @param actions the action string.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @return the actions mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    private static int getMask(String actions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        int mask = NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (actions == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
13795
73850c397272 7193406: Clean-up JDK Build Warnings in java.util, java.io
dxu
parents: 12448
diff changeset
   250
        // Use object identity comparison against known-interned strings for
73850c397272 7193406: Clean-up JDK Build Warnings in java.util, java.io
dxu
parents: 12448
diff changeset
   251
        // performance benefit (these values are used heavily within the JDK).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if (actions == SecurityConstants.PROPERTY_READ_ACTION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            return READ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        } if (actions == SecurityConstants.PROPERTY_WRITE_ACTION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            return WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        } else if (actions == SecurityConstants.PROPERTY_RW_ACTION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            return READ|WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        char[] a = actions.toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        int i = a.length - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (i < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            return mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        while (i != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            char c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            // skip whitespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            while ((i!=-1) && ((c = a[i]) == ' ' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                               c == '\r' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                               c == '\n' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                               c == '\f' ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                               c == '\t'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                i--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            // check for the known strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            int matchlen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            if (i >= 3 && (a[i-3] == 'r' || a[i-3] == 'R') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                          (a[i-2] == 'e' || a[i-2] == 'E') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                          (a[i-1] == 'a' || a[i-1] == 'A') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                          (a[i] == 'd' || a[i] == 'D'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                matchlen = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                mask |= READ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            } else if (i >= 4 && (a[i-4] == 'w' || a[i-4] == 'W') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                                 (a[i-3] == 'r' || a[i-3] == 'R') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                                 (a[i-2] == 'i' || a[i-2] == 'I') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                                 (a[i-1] == 't' || a[i-1] == 'T') &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                                 (a[i] == 'e' || a[i] == 'E'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                matchlen = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                mask |= WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                // parse error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                throw new IllegalArgumentException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                        "invalid permission: " + actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            // make sure we didn't just match the tail of a word
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            // like "ackbarfaccept".  Also, skip to the comma.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            boolean seencomma = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            while (i >= matchlen && !seencomma) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                switch(a[i-matchlen]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                case ',':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                    seencomma = true;
11139
db0c2ff5e1ea 7116997: fix warnings in java.util.PropertyPermission
smarks
parents: 5506
diff changeset
   310
                    break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                case ' ': case '\r': case '\n':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                case '\f': case '\t':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                    throw new IllegalArgumentException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                            "invalid permission: " + actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                i--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            // point i at the location of the comma minus one (or -1).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            i -= matchlen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * Return the canonical string representation of the actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Always returns present actions in the following order:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * read, write.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @return the canonical string representation of the actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   336
    static String getActions(int mask) {
26219
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   337
        switch (mask & (READ|WRITE)) {
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   338
            case READ:
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   339
                return SecurityConstants.PROPERTY_READ_ACTION;
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   340
            case WRITE:
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   341
                return SecurityConstants.PROPERTY_WRITE_ACTION;
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   342
            case READ|WRITE:
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   343
                return SecurityConstants.PROPERTY_RW_ACTION;
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   344
            default:
1a19360ff122 8054714: Use StringJoiner where it makes the code cleaner
igerasim
parents: 25859
diff changeset
   345
                return "";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Returns the "canonical string representation" of the actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * That is, this method always returns present actions in the following order:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * read, write. For example, if this PropertyPermission object
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   353
     * allows both write and read actions, a call to {@code getActions}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * will return the string "read,write".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @return the canonical string representation of the actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   358
    @Override
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   359
    public String getActions() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        if (actions == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            actions = getActions(this.mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        return actions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * Return the current action mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * Used by the PropertyPermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @return the actions mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    int getMask() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Returns a new PermissionCollection object for storing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * PropertyPermission objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @return a new PermissionCollection object suitable for storing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * PropertyPermissions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   383
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    public PermissionCollection newPermissionCollection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        return new PropertyPermissionCollection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
   388
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    private static final long serialVersionUID = 885438825399942851L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * WriteObject is called to save the state of the PropertyPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * to a stream. The actions are serialized, and the superclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * takes care of the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     */
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
   396
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    private synchronized void writeObject(java.io.ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        // Write out the actions. The superclass takes care of the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        // call getActions to make sure actions field is initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        if (actions == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            getActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * readObject is called to restore the state of the PropertyPermission from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * a stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     */
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
   411
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    private synchronized void readObject(java.io.ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
         throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        // Read in the action, then initialize the rest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        init(getMask(actions));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
 * A PropertyPermissionCollection stores a set of PropertyPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
 * permissions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
 * @see java.security.Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
 * @see java.security.Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
 * @see java.security.PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
 * @author Roland Schemers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
 * @serial include
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
final class PropertyPermissionCollection extends PermissionCollection
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   435
    implements Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * Key is property name; value is PropertyPermission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * Not serialized; see serialization section at end of class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   442
    private transient ConcurrentHashMap<String, PropertyPermission> perms;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * Boolean saying if "*" is in the collection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @see #serialPersistentFields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    // No sync access; OK for this to be stale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    private boolean all_allowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    /**
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   453
     * Create an empty PropertyPermissionCollection object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    public PropertyPermissionCollection() {
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   456
        perms = new ConcurrentHashMap<>(32);     // Capacity for default policy
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        all_allowed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * Adds a permission to the PropertyPermissions. The key for the hash is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @param permission the Permission object to add.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *
58659
4113f16d5109 8231859: Extra dash after the exception name in @throws clause of javadoc
igerasim
parents: 58288
diff changeset
   466
     * @throws    IllegalArgumentException   if the permission is not a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *                                       PropertyPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *
58659
4113f16d5109 8231859: Extra dash after the exception name in @throws clause of javadoc
igerasim
parents: 58288
diff changeset
   469
     * @throws    SecurityException   if this PropertyPermissionCollection
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *                                object has been marked readonly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   472
    @Override
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   473
    public void add(Permission permission) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        if (! (permission instanceof PropertyPermission))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            throw new IllegalArgumentException("invalid permission: "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                                               permission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        if (isReadOnly())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            throw new SecurityException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                "attempt to add a Permission to a readonly PermissionCollection");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        PropertyPermission pp = (PropertyPermission) permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        String propName = pp.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   484
        // Add permission to map if it is absent, or replace with new
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   485
        // permission if applicable. NOTE: cannot use lambda for
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   486
        // remappingFunction parameter until JDK-8076596 is fixed.
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   487
        perms.merge(propName, pp,
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   488
            new java.util.function.BiFunction<>() {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   489
                @Override
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   490
                public PropertyPermission apply(PropertyPermission existingVal,
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   491
                                                PropertyPermission newVal) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   493
                    int oldMask = existingVal.getMask();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   494
                    int newMask = newVal.getMask();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   495
                    if (oldMask != newMask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   496
                        int effective = oldMask | newMask;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   497
                        if (effective == newMask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   498
                            return newVal;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   499
                        }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   500
                        if (effective != oldMask) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   501
                            return new PropertyPermission(propName, effective);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   502
                        }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   503
                    }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   504
                    return existingVal;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            }
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   507
        );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        if (!all_allowed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            if (propName.equals("*"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                all_allowed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * Check and see if this set of permissions implies the permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * expressed in "permission".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   519
     * @param permission the Permission object to compare
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @return true if "permission" is a proper subset of a permission in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * the set, false if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   524
    @Override
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   525
    public boolean implies(Permission permission) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if (! (permission instanceof PropertyPermission))
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   527
            return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        PropertyPermission pp = (PropertyPermission) permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        PropertyPermission x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        int desired = pp.getMask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        int effective = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        // short circuit if the "*" Permission was added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        if (all_allowed) {
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   537
            x = perms.get("*");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            if (x != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                effective |= x.getMask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                if ((effective & desired) == desired)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        // strategy:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        // Check for full match first. Then work our way up the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        // name looking for matches on a.b.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        String name = pp.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        //System.out.println("check "+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   552
        x = perms.get(name);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        if (x != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            // we have a direct hit!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            effective |= x.getMask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            if ((effective & desired) == desired)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        // work our way up the tree...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        int last, offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        offset = name.length()-1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
24685
215fa91e1b4c 8044461: Cleanup new Boolean and single character strings
rriggs
parents: 24196
diff changeset
   566
        while ((last = name.lastIndexOf('.', offset)) != -1) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            name = name.substring(0, last+1) + "*";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            //System.out.println("check "+name);
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   570
            x = perms.get(name);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            if (x != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                effective |= x.getMask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                if ((effective & desired) == desired)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            offset = last -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        // we don't have to check for "*" as it was already checked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        // at the top (all_allowed), so we just return false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * Returns an enumeration of all the PropertyPermission objects in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * container.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @return an enumeration of all the PropertyPermission objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   591
    @Override
12448
b95438b17098 7157893: Warnings Cleanup in java.util.*
khazra
parents: 11139
diff changeset
   592
    @SuppressWarnings("unchecked")
11139
db0c2ff5e1ea 7116997: fix warnings in java.util.PropertyPermission
smarks
parents: 5506
diff changeset
   593
    public Enumeration<Permission> elements() {
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   594
        /**
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   595
         * Casting to rawtype since Enumeration<PropertyPermission>
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   596
         * cannot be directly cast to Enumeration<Permission>
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   597
         */
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   598
        return (Enumeration)perms.elements();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
   601
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    private static final long serialVersionUID = 7015263904581634791L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    // Need to maintain serialization interoperability with earlier releases,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    // which had the serializable field:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    // Table of permissions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    // @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    // private Hashtable permissions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * @serialField permissions java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *     A table of the PropertyPermissions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @serialField all_allowed boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *     boolean saying if "*" is in the collection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    private static final ObjectStreamField[] serialPersistentFields = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        new ObjectStreamField("permissions", Hashtable.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        new ObjectStreamField("all_allowed", Boolean.TYPE),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * @serialData Default fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * Writes the contents of the perms field out as a Hashtable for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * serialization compatibility with earlier releases. all_allowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     */
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
   631
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    private void writeObject(ObjectOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        // Don't call out.defaultWriteObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        // Copy perms into a Hashtable
12448
b95438b17098 7157893: Warnings Cleanup in java.util.*
khazra
parents: 11139
diff changeset
   636
        Hashtable<String, Permission> permissions =
b95438b17098 7157893: Warnings Cleanup in java.util.*
khazra
parents: 11139
diff changeset
   637
            new Hashtable<>(perms.size()*2);
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   638
        permissions.putAll(perms);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        // Write out serializable fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        ObjectOutputStream.PutField pfields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        pfields.put("all_allowed", all_allowed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        pfields.put("permissions", permissions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * Reads in a Hashtable of PropertyPermissions and saves them in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * perms field. Reads in all_allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     */
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 47216
diff changeset
   651
    @java.io.Serial
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   652
    private void readObject(ObjectInputStream in)
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   653
        throws IOException, ClassNotFoundException
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 13795
diff changeset
   654
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        // Don't call defaultReadObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        // Read in serialized fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        ObjectInputStream.GetField gfields = in.readFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        // Get all_allowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        all_allowed = gfields.get("all_allowed", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        // Get permissions
11139
db0c2ff5e1ea 7116997: fix warnings in java.util.PropertyPermission
smarks
parents: 5506
diff changeset
   664
        @SuppressWarnings("unchecked")
12448
b95438b17098 7157893: Warnings Cleanup in java.util.*
khazra
parents: 11139
diff changeset
   665
        Hashtable<String, PropertyPermission> permissions =
b95438b17098 7157893: Warnings Cleanup in java.util.*
khazra
parents: 11139
diff changeset
   666
            (Hashtable<String, PropertyPermission>)gfields.get("permissions", null);
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 26219
diff changeset
   667
        perms = new ConcurrentHashMap<>(permissions.size()*2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        perms.putAll(permissions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
}