Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/security/PolicySpi.java
38829 views
/*1* Copyright (c) 2005, 2013, 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*/242526package java.security;2728/**29* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)30* for the {@code Policy} class.31* All the abstract methods in this class must be implemented by each32* service provider who wishes to supply a Policy implementation.33*34* <p> Subclass implementations of this abstract class must provide35* a public constructor that takes a {@code Policy.Parameters}36* object as an input parameter. This constructor also must throw37* an IllegalArgumentException if it does not understand the38* {@code Policy.Parameters} input.39*40*41* @since 1.642*/4344public abstract class PolicySpi {4546/**47* Check whether the policy has granted a Permission to a ProtectionDomain.48*49* @param domain the ProtectionDomain to check.50*51* @param permission check whether this permission is granted to the52* specified domain.53*54* @return boolean true if the permission is granted to the domain.55*/56protected abstract boolean engineImplies57(ProtectionDomain domain, Permission permission);5859/**60* Refreshes/reloads the policy configuration. The behavior of this method61* depends on the implementation. For example, calling {@code refresh}62* on a file-based policy will cause the file to be re-read.63*64* <p> The default implementation of this method does nothing.65* This method should be overridden if a refresh operation is supported66* by the policy implementation.67*/68protected void engineRefresh() { }6970/**71* Return a PermissionCollection object containing the set of72* permissions granted to the specified CodeSource.73*74* <p> The default implementation of this method returns75* Policy.UNSUPPORTED_EMPTY_COLLECTION object. This method can be76* overridden if the policy implementation can return a set of77* permissions granted to a CodeSource.78*79* @param codesource the CodeSource to which the returned80* PermissionCollection has been granted.81*82* @return a set of permissions granted to the specified CodeSource.83* If this operation is supported, the returned84* set of permissions must be a new mutable instance85* and it must support heterogeneous Permission types.86* If this operation is not supported,87* Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.88*/89protected PermissionCollection engineGetPermissions90(CodeSource codesource) {91return Policy.UNSUPPORTED_EMPTY_COLLECTION;92}9394/**95* Return a PermissionCollection object containing the set of96* permissions granted to the specified ProtectionDomain.97*98* <p> The default implementation of this method returns99* Policy.UNSUPPORTED_EMPTY_COLLECTION object. This method can be100* overridden if the policy implementation can return a set of101* permissions granted to a ProtectionDomain.102*103* @param domain the ProtectionDomain to which the returned104* PermissionCollection has been granted.105*106* @return a set of permissions granted to the specified ProtectionDomain.107* If this operation is supported, the returned108* set of permissions must be a new mutable instance109* and it must support heterogeneous Permission types.110* If this operation is not supported,111* Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.112*/113protected PermissionCollection engineGetPermissions114(ProtectionDomain domain) {115return Policy.UNSUPPORTED_EMPTY_COLLECTION;116}117}118119120