Path: blob/master/src/java.base/share/classes/javax/security/auth/AuthPermission.java
41159 views
/*1* Copyright (c) 1998, 2019, 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 javax.security.auth;2627/**28* This class is for authentication permissions. An {@code AuthPermission}29* contains a name (also referred to as a "target name") but no actions30* list; you either have the named permission or you don't.31*32* <p> The target name is the name of a security configuration parameter33* (see below). Currently the {@code AuthPermission} object is used to34* guard access to the {@link Subject},35* {@link javax.security.auth.login.LoginContext}, and36* {@link javax.security.auth.login.Configuration} objects.37*38* <p> The standard target names for an Authentication Permission are:39*40* <pre>41* doAs - allow the caller to invoke the42* {@code Subject.doAs} methods.43*44* doAsPrivileged - allow the caller to invoke the45* {@code Subject.doAsPrivileged} methods.46*47* getSubject - allow for the retrieval of the48* Subject(s) associated with the49* current Thread.50*51* getSubjectFromDomainCombiner - allow for the retrieval of the52* Subject associated with the53* a {@code SubjectDomainCombiner}.54*55* setReadOnly - allow the caller to set a Subject56* to be read-only.57*58* modifyPrincipals - allow the caller to modify the {@code Set}59* of Principals associated with a60* {@code Subject}61*62* modifyPublicCredentials - allow the caller to modify the63* {@code Set} of public credentials64* associated with a {@code Subject}65*66* modifyPrivateCredentials - allow the caller to modify the67* {@code Set} of private credentials68* associated with a {@code Subject}69*70* refreshCredential - allow code to invoke the {@code refresh}71* method on a credential which implements72* the {@code Refreshable} interface.73*74* destroyCredential - allow code to invoke the {@code destroy}75* method on a credential {@code object}76* which implements the {@code Destroyable}77* interface.78*79* createLoginContext.{name} - allow code to instantiate a80* {@code LoginContext} with the81* specified {@code name}. {@code name}82* is used as the index into the installed login83* {@code Configuration}84* (that returned by85* {@code Configuration.getConfiguration()}).86* <i>name</i> can be wildcarded (set to '*')87* to allow for any name.88*89* getLoginConfiguration - allow for the retrieval of the system-wide90* login Configuration.91*92* createLoginConfiguration.{type} - allow code to obtain a Configuration93* object via94* {@code Configuration.getInstance}.95*96* setLoginConfiguration - allow for the setting of the system-wide97* login Configuration.98*99* refreshLoginConfiguration - allow for the refreshing of the system-wide100* login Configuration.101* </pre>102*103* <p>Please note that granting this permission with the "modifyPrincipals",104* "modifyPublicCredentials" or "modifyPrivateCredentials" target allows105* a JAAS login module to populate principal or credential objects into106* the Subject. Although reading information inside the private credentials107* set requires a {@link PrivateCredentialPermission} of the credential type to108* be granted, reading information inside the principals set and the public109* credentials set requires no additional permission. These objects can contain110* potentially sensitive information. For example, login modules that read111* local user information or perform a Kerberos login are able to add112* potentially sensitive information such as user ids, groups and domain names113* to the principals set.114*115* <p> The following target name has been deprecated in favor of116* {@code createLoginContext.{name}}.117*118* <pre>119* createLoginContext - allow code to instantiate a120* {@code LoginContext}.121* </pre>122*123* @implNote124* Implementations may define additional target names, but should use naming125* conventions such as reverse domain name notation to avoid name clashes.126* @since 1.4127*/128public final class AuthPermission extends129java.security.BasicPermission {130131@java.io.Serial132private static final long serialVersionUID = 5806031445061587174L;133134/**135* Creates a new AuthPermission with the specified name.136* The name is the symbolic name of the AuthPermission.137*138* @param name the name of the AuthPermission139*140* @throws NullPointerException if {@code name} is {@code null}.141* @throws IllegalArgumentException if {@code name} is empty.142*/143public AuthPermission(String name) {144// for backwards compatibility --145// createLoginContext is deprecated in favor of createLoginContext.*146super("createLoginContext".equals(name) ?147"createLoginContext.*" : name);148}149150/**151* Creates a new AuthPermission object with the specified name.152* The name is the symbolic name of the AuthPermission, and the153* actions String is currently unused and should be null.154*155* @param name the name of the AuthPermission156*157* @param actions should be null.158*159* @throws NullPointerException if {@code name} is {@code null}.160* @throws IllegalArgumentException if {@code name} is empty.161*/162public AuthPermission(String name, String actions) {163// for backwards compatibility --164// createLoginContext is deprecated in favor of createLoginContext.*165super("createLoginContext".equals(name) ?166"createLoginContext.*" : name, actions);167}168}169170171