test/jdk/java/security/Permissions/DeserializeInvalidPermissions.java
author jboes
Fri, 08 Nov 2019 11:15:16 +0000
changeset 59029 3786a0962570
parent 54472 89295131e353
permissions -rw-r--r--
8232853: AuthenticationFilter.Cache::remove may throw ConcurrentModificationException Summary: Change implementation to use iterator instead of plain LinkedList Reviewed-by: dfuchs, vtewari
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54472
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     1
/*
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     4
 *
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     8
 *
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    13
 * accompanied this code).
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    14
 *
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    18
 *
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    21
 * questions.
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    22
 */
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    23
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    24
/*
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    25
 * @test
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    26
 * @bug 8020637
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    27
 * @summary Deserialize a serialized Permissions object with incorrect Class to
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    28
 *          Permission mappings
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    29
 */
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    30
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    31
import java.io.ByteArrayInputStream;
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    32
import java.io.InvalidObjectException;
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    33
import java.io.ObjectInputStream;
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    34
import java.security.Permissions;
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    35
import java.util.Base64;
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    36
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    37
public class DeserializeInvalidPermissions {
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    38
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    39
    private static final String BASE = System.getProperty("test.src", ".");
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    40
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    41
    /**
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    42
     * A base64 encoded serialized Permissions object. This contains two
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    43
     * Permissions, SecurityPermission("foo") and FilePermission("bar", "read").
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    44
     * However, the Hashtable mappings have been switched, such that
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    45
     * FilePermission.class maps to BasicPermissionCollection (which contains
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    46
     * the SecurityPermission) and SecurityPermission.class maps to
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    47
     * FilePermissionCollection.
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    48
     */
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    49
    private static String INVALID_PERMISSIONS =
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    50
        "rO0ABXNyABlqYXZhLnNlY3VyaXR5LlBlcm1pc3Npb25zQ21LTdLID1ADAAJMAA1hbGxQ" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    51
        "ZXJtaXNzaW9udAAkTGphdmEvc2VjdXJpdHkvUGVybWlzc2lvbkNvbGxlY3Rpb247TAAF" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    52
        "cGVybXN0ABVMamF2YS91dGlsL0hhc2h0YWJsZTt4cgAiamF2YS5zZWN1cml0eS5QZXJt" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    53
        "aXNzaW9uQ29sbGVjdGlvbqKk2tZqGAkpAgABWgAIcmVhZE9ubHl4cABwc3IAE2phdmEu" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    54
        "dXRpbC5IYXNodGFibGUTuw8lIUrkuAMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    55
        "cD9AAAAAAAADdwgAAAAEAAAAAnZyABZqYXZhLmlvLkZpbGVQZXJtaXNzaW9ubg+fk/TA" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    56
        "qbsDAAFMAAdhY3Rpb25zdAASTGphdmEvbGFuZy9TdHJpbmc7eHIAGGphdmEuc2VjdXJp" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    57
        "dHkuUGVybWlzc2lvbrHG4T8oV1F+AgABTAAEbmFtZXEAfgAIeHBzcgAnamF2YS5zZWN1" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    58
        "cml0eS5CYXNpY1Blcm1pc3Npb25Db2xsZWN0aW9uCkKHBI3t48cDAANaAAthbGxfYWxs" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    59
        "b3dlZEwACXBlcm1DbGFzc3QAEUxqYXZhL2xhbmcvQ2xhc3M7TAALcGVybWlzc2lvbnNx" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    60
        "AH4AAnhxAH4AAwAAdnIAIGphdmEuc2VjdXJpdHkuU2VjdXJpdHlQZXJtaXNzaW9uSKpm" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    61
        "PrGHHSYCAAB4cgAdamF2YS5zZWN1cml0eS5CYXNpY1Blcm1pc3Npb25XJQvcz06megIA" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    62
        "AHhxAH4ACXNxAH4ABT9AAAAAAAABdwgAAAACAAAAAXQAA2Zvb3NxAH4ADnEAfgASeHhx" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    63
        "AH4AEHNyACBqYXZhLmlvLkZpbGVQZXJtaXNzaW9uQ29sbGVjdGlvbh6SeX3UjlWpAwAB" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    64
        "TAALcGVybWlzc2lvbnN0ABJMamF2YS91dGlsL1ZlY3Rvcjt4cQB+AAMAc3IAEGphdmEu" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    65
        "dXRpbC5WZWN0b3LZl31bgDuvAQMAA0kAEWNhcGFjaXR5SW5jcmVtZW50SQAMZWxlbWVu" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    66
        "dENvdW50WwALZWxlbWVudERhdGF0ABNbTGphdmEvbGFuZy9PYmplY3Q7eHAAAAAAAAAA" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    67
        "AXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAFzcQB+AAd0AANi" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    68
        "YXJ0AARyZWFkeHh4eHg=";
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    69
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    70
    /**
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    71
     * A base64 encoded serialized PermissionsHash object, which is an internal
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    72
     * class used to store Permissions that do not implement their own
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    73
     * PermissionCollection. This contains one Permission,
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    74
     * PrivateCredentialPermission("a.b.PrivateCredential a.b.Principal
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    75
     *                              \"duke\"", "read")
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    76
     * However, the Hashtable entry has been modified to map the
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    77
     * PrivateCredentialPermission to SecurityPermission("foo") instead of
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    78
     * itself.
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    79
     */
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    80
    private static String INVALID_PERMISSIONS_HASH =
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    81
        "rO0ABXNyABlqYXZhLnNlY3VyaXR5LlBlcm1pc3Npb25zQ21LTdLID1ADAAJMAA1hbGxQ" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    82
        "ZXJtaXNzaW9udAAkTGphdmEvc2VjdXJpdHkvUGVybWlzc2lvbkNvbGxlY3Rpb247TAAF" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    83
        "cGVybXN0ABVMamF2YS91dGlsL0hhc2h0YWJsZTt4cgAiamF2YS5zZWN1cml0eS5QZXJt" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    84
        "aXNzaW9uQ29sbGVjdGlvbqKk2tZqGAkpAgABWgAIcmVhZE9ubHl4cAFwc3IAE2phdmEu" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    85
        "dXRpbC5IYXNodGFibGUTuw8lIUrkuAMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    86
        "cD9AAAAAAAAEdwgAAAAGAAAAA3ZyABZqYXZhLmlvLkZpbGVQZXJtaXNzaW9ubg+fk/TA" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    87
        "qbsDAAFMAAdhY3Rpb25zdAASTGphdmEvbGFuZy9TdHJpbmc7eHIAGGphdmEuc2VjdXJp" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    88
        "dHkuUGVybWlzc2lvbrHG4T8oV1F+AgABTAAEbmFtZXEAfgAIeHBzcgAgamF2YS5pby5G" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    89
        "aWxlUGVybWlzc2lvbkNvbGxlY3Rpb24eknl91I5VqQMAAUwAC3Blcm1pc3Npb25zdAAS" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    90
        "TGphdmEvdXRpbC9WZWN0b3I7eHEAfgADAHNyABBqYXZhLnV0aWwuVmVjdG9y2Zd9W4A7" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    91
        "rwEDAANJABFjYXBhY2l0eUluY3JlbWVudEkADGVsZW1lbnRDb3VudFsAC2VsZW1lbnRE" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    92
        "YXRhdAATW0xqYXZhL2xhbmcvT2JqZWN0O3hwAAAAAAAAAAF1cgATW0xqYXZhLmxhbmcu" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    93
        "T2JqZWN0O5DOWJ8QcylsAgAAeHAAAAABc3EAfgAHdAADYmFydAAEcmVhZHh4eHZyAC9q" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    94
        "YXZheC5zZWN1cml0eS5hdXRoLlByaXZhdGVDcmVkZW50aWFsUGVybWlzc2lvbklV3Hd7" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    95
        "UH9MAgADWgAHdGVzdGluZ0wAD2NyZWRlbnRpYWxDbGFzc3EAfgAITAAKcHJpbmNpcGFs" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    96
        "c3QAD0xqYXZhL3V0aWwvU2V0O3hxAH4ACXNyAB1qYXZhLnNlY3VyaXR5LlBlcm1pc3Np" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    97
        "b25zSGFzaIomZbSmPV1AAwABTAAFcGVybXNxAH4AAnhxAH4AAwBzcQB+AAU/QAAAAAAA" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    98
        "AXcIAAAAAgAAAAFzcQB+ABZ0ACphLmIuUHJpdmF0ZUNyZWRlbnRpYWwgYS5iLlByaW5j" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
    99
        "aXBhbCAiZHVrZSIAdAAVYS5iLlByaXZhdGVDcmVkZW50aWFscHNyACBqYXZhLnNlY3Vy" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   100
        "aXR5LlNlY3VyaXR5UGVybWlzc2lvbkiqZj6xhx0mAgAAeHIAHWphdmEuc2VjdXJpdHku" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   101
        "QmFzaWNQZXJtaXNzaW9uVyUL3M9OpnoCAAB4cQB+AAl0AANmb294eHZxAH4AH3NyACdq" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   102
        "YXZhLnNlY3VyaXR5LkJhc2ljUGVybWlzc2lvbkNvbGxlY3Rpb24KQocEje3jxwMAA1oA" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   103
        "C2FsbF9hbGxvd2VkTAAJcGVybUNsYXNzdAARTGphdmEvbGFuZy9DbGFzcztMAAtwZXJt" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   104
        "aXNzaW9uc3EAfgACeHEAfgADAABxAH4AI3NxAH4ABT9AAAAAAAABdwgAAAACAAAAAXEA" +
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   105
        "fgAic3EAfgAfcQB+ACJ4eHh4";
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   106
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   107
    public static void main(String[] args) throws Exception {
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   108
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   109
        Base64.Decoder decoder = Base64.getDecoder();
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   110
        deserialize(decoder.decode(INVALID_PERMISSIONS));
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   111
        deserialize(decoder.decode(INVALID_PERMISSIONS_HASH));
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   112
    }
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   113
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   114
    private static void deserialize(byte[] serialBytes) throws Exception {
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   115
        try (ObjectInputStream ois =
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   116
                new ObjectInputStream(new ByteArrayInputStream(serialBytes))) {
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   117
            try {
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   118
                Permissions p = (Permissions) ois.readObject();
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   119
                throw new Exception("expected InvalidObjectException");
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   120
            } catch (InvalidObjectException ioe) {
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   121
                // test passed
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   122
            }
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   123
        }
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   124
    }
89295131e353 8020637: Permissions.readObject doesn't enforce proper Class to PermissionCollection mappings
mullan
parents:
diff changeset
   125
}