JarURL.java revision 4288
4269N/A/*
4269N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4269N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4269N/A *
4269N/A * This code is free software; you can redistribute it and/or modify it
4269N/A * under the terms of the GNU General Public License version 2 only, as
4269N/A * published by the Free Software Foundation.
4269N/A *
4269N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4269N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4269N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4269N/A * version 2 for more details (a copy is included in the LICENSE file that
4269N/A * accompanied this code).
4269N/A *
4269N/A * You should have received a copy of the GNU General Public License version
4269N/A * 2 along with this work; if not, write to the Free Software Foundation,
4269N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4269N/A *
4269N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4269N/A * or visit www.oracle.com if you need additional information or have any
4269N/A * questions.
4269N/A */
4269N/A
4269N/A/*
4269N/A * @test
4288N/A * @bug 7044443 7050329
4288N/A * @run main/othervm/policy=JarURL.policy JarURL
4269N/A * @summary Permissions resolved incorrectly for jar protocol
4269N/A */
4269N/A
4269N/Aimport java.net.URL;
4288N/Aimport java.io.File;
4269N/Aimport java.security.AllPermission;
4269N/Aimport java.security.CodeSource;
4269N/Aimport java.security.PermissionCollection;
4269N/Aimport java.security.Policy;
4269N/Aimport java.security.cert.Certificate;
4269N/A
4269N/Apublic class JarURL {
4288N/A
4269N/A public static void main(String[] args) throws Exception {
4288N/A String userDir = System.getProperty("user.dir");
4288N/A String jarURL = "jar:file:" + userDir + File.separator + "foo.jar!/";
4288N/A URL codeSourceURL = new URL(jarURL);
4269N/A CodeSource cs = new CodeSource(codeSourceURL, new Certificate[0]);
4269N/A PermissionCollection perms = Policy.getPolicy().getPermissions(cs);
4269N/A if (!perms.implies(new AllPermission()))
4269N/A throw new Exception("FAILED: " + codeSourceURL
4269N/A + " not granted AllPermission");
4269N/A }
4269N/A}