jdk/src/java.base/share/classes/java/security/Permission.java
author mli
Wed, 31 May 2017 19:54:16 -0700
changeset 45434 4582657c7260
parent 25859 3317bb8137f4
permissions -rw-r--r--
8181082: class-level since tag issues in java.base & java.datatransfer module Reviewed-by: alanb, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
     2
 * Copyright (c) 1997, 2013, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private static final long serialVersionUID = -5636570222231596674L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Constructs a permission with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param name name of the Permission object being created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public Permission(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * 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
    85
     * {@code SecurityManager.checkPermission} method is called,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * passing this permission object as the permission to check.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Returns silently if access is granted. Otherwise, throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param object the object being guarded (currently ignored).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @throws SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *        if a security manager exists and its
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    94
     *        {@code checkPermission} method doesn't allow access.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see Guard
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @see GuardedObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @see SecurityManager#checkPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public void checkGuard(Object object) throws SecurityException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        SecurityManager sm = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (sm != null) sm.checkPermission(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Checks if the specified permission's actions are "implied by"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * this object's actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * This must be implemented by subclasses of Permission, as they are the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * only ones that can impose semantics on a Permission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   113
     * <p>The {@code implies} method is used by the AccessController to determine
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * whether or not a requested permission is implied by another permission that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * is known to be valid in the current execution context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @param permission the permission to check against.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @return true if the specified permission is implied by this object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * false if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public abstract boolean implies(Permission permission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Checks two Permission objects for equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * <P>
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   128
     * 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
   129
     * decisions; use the {@code implies} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param obj the object we are testing for equality with this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return true if both Permission objects are equivalent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public abstract boolean equals(Object obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * Returns the hash code value for this Permission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * <P>
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   141
     * The required {@code hashCode} behavior for Permission Objects is
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 18579
diff changeset
   142
     * the following:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <li>Whenever it is invoked on the same Permission object more than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *     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
   146
     *     {@code hashCode} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *     must consistently return the same integer. This integer need not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *     remain consistent from one execution of an application to another
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 18579
diff changeset
   149
     *     execution of the same application.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * <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
   151
     *     {@code equals}
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   152
     *     method, then calling the {@code hashCode} method on each of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *     two Permission objects must produce the same integer result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @return a hash code value for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public abstract int hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Returns the name of this Permission.
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   163
     * For example, in the case of a {@code java.io.FilePermission},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * the name will be a pathname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @return the name of this Permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public final String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Returns the actions as a String. This is abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * so subclasses can defer creating a String representation until
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * one is needed. Subclasses should always return actions in what they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * consider to be their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * canonical form. For example, two FilePermission objects created via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *   perm1 = new FilePermission(p1,"read,write");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *   perm2 = new FilePermission(p2,"write,read");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * both return
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   188
     * "read,write" when the {@code getActions} method is invoked.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @return the actions of this Permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public abstract String getActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * Returns an empty PermissionCollection for a given Permission object, or null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * one is not defined. Subclasses of class Permission should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * override this if they need to store their permissions in a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * 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
   201
     * when the {@code PermissionCollection.implies} method is called.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * If null is returned,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * then the caller of this method is free to store permissions of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * type in any PermissionCollection they choose (one that uses a Hashtable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * one that uses a Vector, etc).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @return a new PermissionCollection object for this type of Permission, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * null if one is not defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public PermissionCollection newPermissionCollection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Returns a string describing this Permission.  The convention is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * 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
   218
     * the following format: '("ClassName" "name" "actions")', or
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   219
     * '("ClassName" "name")' if actions list is null or empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @return information about this Permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        String actions = getActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if ((actions == null) || (actions.length() == 0)) { // OPTIONAL
2172
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   226
            return "(\"" + getClass().getName() + "\" \"" + name + "\")";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        } else {
2172
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   228
            return "(\"" + getClass().getName() + "\" \"" + name +
2e7377d894db 6549506: Specification of Permission.toString() method contradicts with JDK implementation
xuelei
parents: 2
diff changeset
   229
                 "\" \"" + actions + "\")";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
}