Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/security/provider/PolicySpiFile.java
38830 views
/*1* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.security.provider;2627import java.security.CodeSource;28import java.security.Permission;29import java.security.PermissionCollection;30import java.security.Policy;31import java.security.PolicySpi;32import java.security.ProtectionDomain;33import java.security.URIParameter;3435import java.net.MalformedURLException;3637/**38* This class wraps the PolicyFile subclass implementation of Policy39* inside a PolicySpi implementation that is available from the SUN provider40* via the Policy.getInstance calls.41*42*/43public final class PolicySpiFile extends PolicySpi {4445private PolicyFile pf;4647public PolicySpiFile(Policy.Parameters params) {4849if (params == null) {50pf = new PolicyFile();51} else {52if (!(params instanceof URIParameter)) {53throw new IllegalArgumentException54("Unrecognized policy parameter: " + params);55}56URIParameter uriParam = (URIParameter)params;57try {58pf = new PolicyFile(uriParam.getURI().toURL());59} catch (MalformedURLException mue) {60throw new IllegalArgumentException("Invalid URIParameter", mue);61}62}63}6465protected PermissionCollection engineGetPermissions(CodeSource codesource) {66return pf.getPermissions(codesource);67}6869protected PermissionCollection engineGetPermissions(ProtectionDomain d) {70return pf.getPermissions(d);71}7273protected boolean engineImplies(ProtectionDomain d, Permission p) {74return pf.implies(d, p);75}7677protected void engineRefresh() {78pf.refresh();79}80}818283