1/* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/* 25 * @test 26 * @bug 8043252 27 * @summary Debug of access control is obfuscated - NullPointerException in 28 * ProtectionDomain 29 * @run main/othervm/java.security.policy=NullGetActions.policy NullGetActions 30 */ 31 32import java.net.*; 33import java.security.*; 34 35public class NullGetActions { 36 37 public static void main(String[] args) throws Exception { 38 Permissions permset = new Permissions(); 39 permset.add(new EvilPermission("java.let.me.do.stuff")); 40 41 Policy.getPolicy(); 42 ProtectionDomain protDom = new ProtectionDomain( 43 new CodeSource(new URL("http://bar"), 44 (java.security.cert.Certificate[])null), permset, 45 null, null); 46 47 System.out.println("Protection Domain:\n" + protDom); 48 } 49 50 public static class EvilPermission extends Permission { 51 public EvilPermission(String name) { 52 super(name); 53 } 54 55 @Override 56 public String getActions() { 57 return null; 58 } 59 60 @Override 61 public boolean equals(Object obj) { 62 return (obj == this); 63 } 64 65 @Override 66 public int hashCode() { 67 return 42; 68 } 69 70 @Override 71 public boolean implies(Permission permission) { 72 return false; 73 } 74 } 75} 76