src/java.base/share/classes/java/security/Permission.java
author darcy
Thu, 29 Aug 2019 10:52:21 -0700
changeset 57950 4612a3cfb927
parent 53018 8bf9268df0e2
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: 53018
diff changeset
     2
 * Copyright (c) 1997, 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: 2172
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: 2172
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: 2172
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2172
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2172
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 java.security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * Abstract class for representing access to a system resource.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * All permissions have a name (whose interpretation depends on the subclass),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * as well as abstract functions for defining the semantics of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * particular Permission subclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>Most Permission objects also include an "actions" list that tells the actions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * that are permitted for the object.  For example,
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    36
 * for a {@code java.io.FilePermission} object, the permission name is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * the pathname of a file (or directory), and the actions list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * (such as "read, write") specifies which actions are granted for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * specified file (or for files in the specified directory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * The actions list is optional for Permission objects, such as
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    41
 * {@code java.lang.RuntimePermission},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * that don't need such a list; you either have the named permission (such
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * as "system.exit") or you don't.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>An important method that must be implemented by each subclass is
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    46
 * the {@code implies} method to compare Permissions. Basically,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * "permission p1 implies permission p2" means that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * if one is granted permission p1, one is naturally granted permission p2.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Thus, this is not an equality test, but rather more of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * subset test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <P> Permission objects are similar to String objects in that they
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * are immutable once they have been created. Subclasses should not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * provide methods that can change the state of a permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * once it has been created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @see Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @see PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @author Marianne Mueller
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @author Roland Schemers
45434
4582657c7260 8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents: 25859
diff changeset
    63
 * @since 1.2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
public abstract class Permission implements Guard, java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
57950
4612a3cfb927 8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents: 53018
diff changeset
    68
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private static final long serialVersionUID = -5636570222231596674L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Constructs a permission with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param name name of the Permission object being created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public Permission(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Implements the guard interface for a permission. The
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    86
     * {@code SecurityManager.checkPermission} method is called,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * passing this permission object as the permission to check.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Returns silently if access is granted. Otherwise, throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param object the object being guarded (currently ignored).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *        if a security manager exists and its
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    95
     *        {@code checkPermission} method doesn't allow access.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @see Guard
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @see GuardedObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @see SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public void checkGuard(Object object) throws SecurityException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        SecurityManager sm = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        if (sm != null) sm.checkPermission(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Checks if the specified permission's actions are "implied by"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * this object's actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * This must be implemented by subclasses of Permission, as they are the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * only ones that can impose semantics on a Permission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   114
     * <p>The {@code implies} method is used by the AccessController to determine
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * whether or not a requested permission is implied by another permission that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * is known to be valid in the current execution context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @param permission the permission to check against.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @return true if the specified permission is implied by this object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * false if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public abstract boolean implies(Permission permission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Checks two Permission objects for equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <P>
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   129
     * Do not use the {@code equals} method for making access control
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   130
     * decisions; use the {@code implies} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param obj the object we are testing for equality with this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @return true if both Permission objects are equivalent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public abstract boolean equals(Object obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Returns the hash code value for this Permission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * <P>
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   142
     * The required {@code hashCode} behavior for Permission Objects is
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 18579
diff changeset
   143
     * the following:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <li>Whenever it is invoked on the same Permission object more than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *     once during an execution of a Java application, the
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   147
     *     {@code hashCode} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *     must consistently return the same integer. This integer need not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *     remain consistent from one execution of an application to another
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 18579
diff changeset
   150
     *     execution of the same application.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <li>If two Permission objects are equal according to the
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   152
     *     {@code equals}
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   153
     *     method, then calling the {@code hashCode} method on each of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *     two Permission objects must produce the same integer result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @return a hash code value for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public abstract int hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * Returns the name of this Permission.
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   164
     * For example, in the case of a {@code java.io.FilePermission},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * the name will be a pathname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @return the name of this Permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public final String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Returns the actions as a String. This is abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * so subclasses can defer creating a String representation until
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * one is needed. Subclasses should always return actions in what they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * consider to be their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * canonical form. For example, two FilePermission objects created via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *   perm1 = new FilePermission(p1,"read,write");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *   perm2 = new FilePermission(p2,"write,read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * both return
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   189
     * "read,write" when the {@code getActions} method is invoked.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @return the actions of this Permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public abstract String getActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Returns an empty PermissionCollection for a given Permission object, or null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * one is not defined. Subclasses of class Permission should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * override this if they need to store their permissions in a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * PermissionCollection object in order to provide the correct semantics
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   202
     * when the {@code PermissionCollection.implies} method is called.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * If null is returned,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * then the caller of this method is free to store permissions of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * type in any PermissionCollection they choose (one that uses a Hashtable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * one that uses a Vector, etc).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @return a new PermissionCollection object for this type of Permission, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * null if one is not defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public PermissionCollection newPermissionCollection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * Returns a string describing this Permission.  The convention is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * specify the class name, the permission name, and the actions in
2172
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   219
     * the following format: '("ClassName" "name" "actions")', or
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   220
     * '("ClassName" "name")' if actions list is null or empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @return information about this Permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        String actions = getActions();
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 47216
diff changeset
   226
        if (actions == null || actions.isEmpty()) { // OPTIONAL
2172
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   227
            return "(\"" + getClass().getName() + "\" \"" + name + "\")";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        } else {
2172
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   229
            return "(\"" + getClass().getName() + "\" \"" + name +
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   230
                 "\" \"" + actions + "\")";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
}