jdk/src/java.base/share/classes/java/security/UnresolvedPermissionCollection.java
author mullan
Tue, 09 Jun 2015 09:18:07 -0400
changeset 31080 00a25f4c4d44
parent 30033 b9c86c17164a
child 45434 4582657c7260
permissions -rw-r--r--
8056179: Store permissions in concurrent collections in PermissionCollection subclasses 8065942: Store PermissionCollection entries in a ConcurrentHashMap instead of a HashMap in Permissions class Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    28
import java.io.IOException;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    29
import java.io.ObjectInputStream;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.ObjectOutputStream;
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    31
import java.io.ObjectStreamField;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    32
import java.util.*;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    33
import java.util.concurrent.ConcurrentHashMap;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    34
import java.util.concurrent.CopyOnWriteArrayList;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * A UnresolvedPermissionCollection stores a collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * of UnresolvedPermission permissions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @see java.security.Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @see java.security.Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see java.security.UnresolvedPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author Roland Schemers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @serial include
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
final class UnresolvedPermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
extends PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
implements java.io.Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Key is permission type, value is a list of the UnresolvedPermissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * of the same type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Not serialized; see serialization section at end of class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    59
    private transient ConcurrentHashMap<String, List<UnresolvedPermission>> perms;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Create an empty UnresolvedPermissionCollection object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public UnresolvedPermissionCollection() {
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    66
        perms = new ConcurrentHashMap<>(11);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Adds a permission to this UnresolvedPermissionCollection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * The key for the hash is the unresolved permission's type (class) name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @param permission the Permission object to add.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    75
    @Override
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    76
    public void add(Permission permission) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        if (! (permission instanceof UnresolvedPermission))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            throw new IllegalArgumentException("invalid permission: "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                               permission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        UnresolvedPermission up = (UnresolvedPermission) permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    82
        // Add permission to map. NOTE: cannot use lambda for
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    83
        // remappingFunction parameter until JDK-8076596 is fixed.
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    84
        perms.compute(up.getName(),
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    85
            new java.util.function.BiFunction<>() {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    86
                @Override
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    87
                public List<UnresolvedPermission> apply(String key,
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    88
                                        List<UnresolvedPermission> oldValue) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    89
                    if (oldValue == null) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    90
                        List<UnresolvedPermission> v =
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    91
                            new CopyOnWriteArrayList<>();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    92
                        v.add(up);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    93
                        return v;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    94
                    } else {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    95
                        oldValue.add(up);
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    96
                        return oldValue;
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    97
                    }
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
    98
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            }
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   100
        );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * get any unresolved permissions of the same type as p,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * and return the List containing them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    List<UnresolvedPermission> getUnresolvedPermissions(Permission p) {
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   108
        return perms.get(p.getClass().getName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * always returns false for unresolved permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   115
    @Override
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   116
    public boolean implies(Permission permission) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Returns an enumeration of all the UnresolvedPermission lists in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * container.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @return an enumeration of all the UnresolvedPermission objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   126
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public Enumeration<Permission> elements() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        List<Permission> results =
7970
af1579474d16 7008728: diamond conversion of basic security, permissions, authentication
smarks
parents: 5506
diff changeset
   129
            new ArrayList<>(); // where results are stored
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        // Get iterator of Map values (which are lists of permissions)
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   132
        for (List<UnresolvedPermission> l : perms.values()) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   133
            results.addAll(l);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        return Collections.enumeration(results);
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 static final long serialVersionUID = -7176153071733132400L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    // Need to maintain serialization interoperability with earlier releases,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    // which had the serializable field:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    // private Hashtable permissions; // keyed on type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @serialField permissions java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *     A table of the UnresolvedPermissions keyed on type, value is Vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *     of permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private static final ObjectStreamField[] serialPersistentFields = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        new ObjectStreamField("permissions", Hashtable.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @serialData Default field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * Writes the contents of the perms field out as a Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * in which the values are Vectors for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * serialization compatibility with earlier releases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    private void writeObject(ObjectOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        // Don't call out.defaultWriteObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        // Copy perms into a Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        Hashtable<String, Vector<UnresolvedPermission>> permissions =
7970
af1579474d16 7008728: diamond conversion of basic security, permissions, authentication
smarks
parents: 5506
diff changeset
   167
            new Hashtable<>(perms.size()*2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        // Convert each entry (List) into a Vector
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   170
        Set<Map.Entry<String, List<UnresolvedPermission>>> set = perms.entrySet();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   171
        for (Map.Entry<String, List<UnresolvedPermission>> e : set) {
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   172
            // Convert list into Vector
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   173
            List<UnresolvedPermission> list = e.getValue();
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   174
            Vector<UnresolvedPermission> vec = new Vector<>(list);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   176
            // Add to Hashtable being serialized
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   177
            permissions.put(e.getKey(), vec);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // Write out serializable fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        ObjectOutputStream.PutField pfields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        pfields.put("permissions", permissions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Reads in a Hashtable in which the values are Vectors of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * UnresolvedPermissions and saves them in the perms field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    private void readObject(ObjectInputStream in) throws IOException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        // Don't call defaultReadObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        // Read in serialized fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        ObjectInputStream.GetField gfields = in.readFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        // Get permissions
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9035
diff changeset
   198
        @SuppressWarnings("unchecked")
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9035
diff changeset
   199
        // writeObject writes a Hashtable<String, Vector<UnresolvedPermission>>
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9035
diff changeset
   200
        // for the permissions key, so this cast is safe, unless the data is corrupt.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        Hashtable<String, Vector<UnresolvedPermission>> permissions =
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9035
diff changeset
   202
                (Hashtable<String, Vector<UnresolvedPermission>>)
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9035
diff changeset
   203
                gfields.get("permissions", null);
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   204
        perms = new ConcurrentHashMap<>(permissions.size()*2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        // Convert each entry (Vector) into a List
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        Set<Map.Entry<String, Vector<UnresolvedPermission>>> set = permissions.entrySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        for (Map.Entry<String, Vector<UnresolvedPermission>> e : set) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            // Convert Vector into ArrayList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            Vector<UnresolvedPermission> vec = e.getValue();
31080
00a25f4c4d44 8056179: Store permissions in concurrent collections in PermissionCollection subclasses
mullan
parents: 30033
diff changeset
   211
            List<UnresolvedPermission> list = new CopyOnWriteArrayList<>(vec);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            // Add to Hashtable being serialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            perms.put(e.getKey(), list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
}