src/java.base/share/classes/javax/security/auth/AuthPermission.java
author darcy
Thu, 29 Aug 2019 10:52:21 -0700
changeset 57950 4612a3cfb927
parent 49150 a4a816f88e58
permissions -rw-r--r--
8229999: Apply java.io.Serial annotations to security types in java.base Reviewed-by: rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
57950
4612a3cfb927 8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents: 49150
diff changeset
     2
 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.security.auth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
32107
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
    29
 * This class is for authentication permissions. An {@code AuthPermission}
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
    30
 * contains a name (also referred to as a "target name") but no actions
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
    31
 * list; you either have the named permission or you don't.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p> The target name is the name of a security configuration parameter
32107
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
    34
 * (see below).  Currently the {@code AuthPermission} object is used to
49150
a4a816f88e58 8191139: Remove deprecated javax.security.auth.Policy API
weijun
parents: 47216
diff changeset
    35
 * guard access to the {@link Subject},
32107
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
    36
 * {@link javax.security.auth.login.LoginContext}, and
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
    37
 * {@link javax.security.auth.login.Configuration} objects.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
32107
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
    39
 * <p> The standard target names for an Authentication Permission are:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *      doAs -                  allow the caller to invoke the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    43
 *                              {@code Subject.doAs} methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      doAsPrivileged -        allow the caller to invoke the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    46
 *                              {@code Subject.doAsPrivileged} methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *      getSubject -            allow for the retrieval of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *                              Subject(s) associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *                              current Thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *      getSubjectFromDomainCombiner -  allow for the retrieval of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *                              Subject associated with the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    54
 *                              a {@code SubjectDomainCombiner}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *      setReadOnly -           allow the caller to set a Subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *                              to be read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    59
 *      modifyPrincipals -      allow the caller to modify the {@code Set}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *                              of Principals associated with a
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    61
 *                              {@code Subject}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *      modifyPublicCredentials - allow the caller to modify the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    64
 *                              {@code Set} of public credentials
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    65
 *                              associated with a {@code Subject}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *      modifyPrivateCredentials - allow the caller to modify the
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    68
 *                              {@code Set} of private credentials
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    69
 *                              associated with a {@code Subject}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    71
 *      refreshCredential -     allow code to invoke the {@code refresh}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *                              method on a credential which implements
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    73
 *                              the {@code Refreshable} interface.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    75
 *      destroyCredential -     allow code to invoke the {@code destroy}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    76
 *                              method on a credential {@code object}
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    77
 *                              which implements the {@code Destroyable}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *                              interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *      createLoginContext.{name} -  allow code to instantiate a
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    81
 *                              {@code LoginContext} with the
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
    82
 *                              specified {@code name}.  {@code name}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *                              is used as the index into the installed login
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    84
 *                              {@code Configuration}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *                              (that returned by
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    86
 *                              {@code Configuration.getConfiguration()}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *                              <i>name</i> can be wildcarded (set to '*')
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *                              to allow for any name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *      getLoginConfiguration - allow for the retrieval of the system-wide
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *                              login Configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *      createLoginConfiguration.{type} - allow code to obtain a Configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *                              object via
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
    95
 *                              {@code Configuration.getInstance}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *      setLoginConfiguration - allow for the setting of the system-wide
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *                              login Configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *      refreshLoginConfiguration - allow for the refreshing of the system-wide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *                              login Configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *
33282
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   104
 * <p>Please note that granting this permission with the "modifyPrincipals",
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   105
 * "modifyPublicCredentials" or "modifyPrivateCredentials" target allows
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   106
 * a JAAS login module to populate principal or credential objects into
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   107
 * the Subject. Although reading information inside the private credentials
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   108
 * set requires a {@link PrivateCredentialPermission} of the credential type to
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   109
 * be granted, reading information inside the principals set and the public
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   110
 * credentials set requires no additional permission. These objects can contain
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   111
 * potentially sensitive information. For example, login modules that read
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   112
 * local user information or perform a Kerberos login are able to add
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   113
 * potentially sensitive information such as user ids, groups and domain names
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   114
 * to the principals set.
00f3c40fd3af 8048030: Expectations should be consistent
weijun
parents: 32107
diff changeset
   115
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * <p> The following target name has been deprecated in favor of
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   117
 * {@code createLoginContext.{name}}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 *      createLoginContext -    allow code to instantiate a
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   121
 *                              {@code LoginContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *
32107
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
   124
 * @implNote
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
   125
 * Implementations may define additional target names, but should use naming
67aa4920495c 8077055: Allow other named SecurityPermissions, RuntimePermissions, and AuthPermissions to be used
mullan
parents: 29492
diff changeset
   126
 * conventions such as reverse domain name notation to avoid name clashes.
45434
4582657c7260 8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents: 33282
diff changeset
   127
 * @since 1.4
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
public final class AuthPermission extends
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
java.security.BasicPermission {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
57950
4612a3cfb927 8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents: 49150
diff changeset
   132
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    private static final long serialVersionUID = 5806031445061587174L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Creates a new AuthPermission with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * The name is the symbolic name of the AuthPermission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @param name the name of the AuthPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   141
     * @throws NullPointerException if {@code name} is {@code null}.
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   142
     * @throws IllegalArgumentException if {@code name} is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public AuthPermission(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        // for backwards compatibility --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // createLoginContext is deprecated in favor of createLoginContext.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        super("createLoginContext".equals(name) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                "createLoginContext.*" : name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Creates a new AuthPermission object with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * The name is the symbolic name of the AuthPermission, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * actions String is currently unused and should be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
29492
a4bf9a570035 8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents: 25859
diff changeset
   156
     * @param name the name of the AuthPermission
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @param actions should be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
18830
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   160
     * @throws NullPointerException if {@code name} is {@code null}.
90956ead732f 8020557: javadoc cleanup in javax.security
juh
parents: 5506
diff changeset
   161
     * @throws IllegalArgumentException if {@code name} is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public AuthPermission(String name, String actions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        // for backwards compatibility --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        // createLoginContext is deprecated in favor of createLoginContext.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        super("createLoginContext".equals(name) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                "createLoginContext.*" : name, actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
}