Path: blob/master/src/java.base/share/classes/java/security/AccessControlException.java
41152 views
/*1* Copyright (c) 1997, 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 java.security;2627/**28* <p> This exception is thrown by the AccessController to indicate29* that a requested access (to a critical system resource such as the30* file system or the network) is denied.31*32* <p> The reason to deny access can vary. For example, the requested33* permission might be of an incorrect type, contain an invalid34* value, or request access that is not allowed according to the35* security policy. Such information should be given whenever36* possible at the time the exception is thrown.37*38* @author Li Gong39* @author Roland Schemers40* @since 1.241* @deprecated This class is only useful in conjunction with42* {@linkplain SecurityManager the Security Manager}, which is deprecated43* and subject to removal in a future release. Consequently, this class44* is also deprecated and subject to removal. There is no replacement for45* the Security Manager or this class.46*/4748@Deprecated(since="17", forRemoval=true)49public class AccessControlException extends SecurityException {5051@java.io.Serial52private static final long serialVersionUID = 5138225684096988535L;5354/**55* The permission that caused the exception to be thrown.56*/57private Permission perm;5859/**60* Constructs an {@code AccessControlException} with the61* specified, detailed message.62*63* @param s the detail message.64*/65public AccessControlException(String s) {66super(s);67}6869/**70* Constructs an {@code AccessControlException} with the71* specified, detailed message, and the requested permission that caused72* the exception.73*74* @param s the detail message.75* @param p the permission that caused the exception.76*/77public AccessControlException(String s, Permission p) {78super(s);79perm = p;80}8182/**83* Gets the Permission object associated with this exception, or84* null if there was no corresponding Permission object.85*86* @return the Permission object.87*/88public Permission getPermission() {89return perm;90}91}929394