Path: blob/master/src/java.base/share/classes/sun/security/provider/PolicySpiFile.java
41159 views
/*1* Copyright (c) 2005, 2021, 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*/43@SuppressWarnings("removal")44public final class PolicySpiFile extends PolicySpi {4546private PolicyFile pf;4748public PolicySpiFile(Policy.Parameters params) {4950if (params == null) {51pf = new PolicyFile();52} else {53if (!(params instanceof URIParameter)) {54throw new IllegalArgumentException55("Unrecognized policy parameter: " + params);56}57URIParameter uriParam = (URIParameter)params;58try {59pf = new PolicyFile(uriParam.getURI().toURL());60} catch (MalformedURLException mue) {61throw new IllegalArgumentException("Invalid URIParameter", mue);62}63}64}6566protected PermissionCollection engineGetPermissions(CodeSource codesource) {67return pf.getPermissions(codesource);68}6970protected PermissionCollection engineGetPermissions(ProtectionDomain d) {71return pf.getPermissions(d);72}7374protected boolean engineImplies(ProtectionDomain d, Permission p) {75return pf.implies(d, p);76}7778protected void engineRefresh() {79pf.refresh();80}81}828384