src/jdk.jfr/share/classes/jdk/jfr/FlightRecorderPermission.java
author egahlin
Tue, 15 May 2018 20:24:34 +0200
changeset 50113 caf115bb98ad
child 50745 a390cbb82d47
permissions -rw-r--r--
8199712: Flight Recorder Reviewed-by: coleenp, ihse, erikj, dsamersoff, mseledtsov, egahlin, mgronlun Contributed-by: erik.gahlin@oracle.com, markus.gronlund@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     4
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    10
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    15
 * accompanied this code).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    16
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    20
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    23
 * questions.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    24
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    25
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    26
package jdk.jfr;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
import java.util.Collections;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
import java.util.List;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
import java.util.Map;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
import java.util.Objects;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
import jdk.jfr.internal.PlatformEventType;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
import jdk.jfr.internal.PlatformRecording;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
import jdk.jfr.internal.PrivateAccess;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    36
import jdk.jfr.internal.Type;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
import jdk.jfr.internal.Utils;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
/**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
 * Permission for controlling access to Flight Recorder.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    41
 * <p>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
 * The following table provides a summary of what the permission
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    43
 * allows, and the risks of granting code the permission.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
 * <table class="striped">
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    46
 * <caption style="display:none">Table shows permission target name,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
 *      what the permission allows, and associated risks</caption>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
 * <thead>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
 * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
 * <th scope="col">Permission Target Name</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
 * <th scope="col">What the Permission Allows</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
 * <th scope="col">Risks of Allowing this Permission</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
 * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
 * </thead>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    56
 * <tbody>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
 * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
 * <th scope="row">{@code accessFlightRecorder}</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    59
 * <td>Ability to create a Flight Recorder instance, register callbacks to
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
 * monitor the Flight Recorder life cycle, and control an existing instance
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
 * of Flight Recorder, which can record and dump runtime information, such as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
 * stack traces, class names, and data in user defined events.</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
 * <td>A malicious user may be able to extract sensitive information that is stored in
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
 * events and interrupt Flight Recorder by installing listeners or hooks that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
 * never finish.</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
 * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
 * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
 * <th scope="row">{@code registerEvent}</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
 * <td>Ability to register events, write data to the Flight Recorder buffers,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
 * and execute code in a callback function for periodic events.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
 * <td>A malicious user may be able to write sensitive information to Flight
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
 * Recorder buffers.</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
 * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
 * </tbody>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
 * </table>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
 * <p>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
 * Typically, programmers do not create {@code FlightRecorderPermission} objects
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
 * directly. Instead the objects are created by the security policy code that is based on
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
 * reading the security policy file.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
 * @since 9
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
 * @see java.security.BasicPermission
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
 * @see java.security.Permission
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
 * @see java.security.Permissions
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    88
 * @see java.security.PermissionCollection
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    89
 * @see java.lang.SecurityManager
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    92
@SuppressWarnings("serial")
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    93
public final class FlightRecorderPermission extends java.security.BasicPermission {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
    // Purpose of InternalAccess is to give classes in jdk.jfr.internal
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
    // access to package private methods in this package (jdk.jfr).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
    //
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
    // The initialization could be done in any class in this package,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    99
    // but this one was chosen because it is light weight and
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   100
    // lacks dependencies on other public classes.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   101
    static {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   102
        PrivateAccess.setPrivateAccess(new InternalAccess());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   103
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   104
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   105
    private final static class InternalAccess extends PrivateAccess {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   106
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   107
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   108
        public Type getType(Object o) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   109
            if (o instanceof AnnotationElement) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   110
                return ((AnnotationElement) o).getType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   111
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   112
            if (o instanceof EventType) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   113
                return ((EventType) o).getType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   114
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   115
            if (o instanceof ValueDescriptor) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   116
                return ((ValueDescriptor) o).getType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   117
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   118
            if (o instanceof SettingDescriptor) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   119
                return ((SettingDescriptor) o).getType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   120
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   121
            throw new Error("Unknown type " + o.getClass());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   122
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   123
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   124
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   125
        public Configuration newConfiguration(String name, String label, String description, String provider, Map<String, String> settings, String contents) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   126
            return new Configuration(name, label, description, provider, settings, contents);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   127
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   128
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   129
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   130
        public EventType newEventType(PlatformEventType platformEventType) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   131
            return new EventType(platformEventType);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   133
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   134
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   135
        public AnnotationElement newAnnotation(Type annotationType, List<Object> values, boolean boot) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   136
            return new AnnotationElement(annotationType, values, boot);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   137
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   138
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   139
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   140
        public ValueDescriptor newValueDescriptor(String name, Type fieldType, List<AnnotationElement> annos, int dimension, boolean constantPool, String fieldName) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   141
            return new ValueDescriptor(fieldType, name, annos, dimension, constantPool, fieldName);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   142
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   143
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   144
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   145
        public PlatformRecording getPlatformRecording(Recording r) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   146
            return r.getInternal();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   147
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   148
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   149
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   150
        public PlatformEventType getPlatformEventType(EventType eventType) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   151
            return eventType.getPlatformEventType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   152
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   153
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   154
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   155
        public boolean isConstantPool(ValueDescriptor v) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   156
            return v.isConstantPool();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   157
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   158
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   159
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   160
        public void setAnnotations(ValueDescriptor v, List<AnnotationElement> a) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   161
            v.setAnnotations(a);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   162
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   163
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   164
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   165
        public void setAnnotations(SettingDescriptor s, List<AnnotationElement> a) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   166
           s.setAnnotations(a);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   167
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   168
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   169
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   170
        public String getFieldName(ValueDescriptor v) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   171
            return v.getJavaFieldName();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   172
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   173
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   174
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   175
        public ValueDescriptor newValueDescriptor(Class<?> type, String name) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   176
            return new ValueDescriptor(type, name, Collections.emptyList(), true);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   177
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   178
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   179
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   180
        public SettingDescriptor newSettingDescriptor(Type type, String name, String defaultValue, List<AnnotationElement> annotations) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   181
            return new SettingDescriptor(type, name, defaultValue, annotations);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   182
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   183
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   184
        @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   185
        public boolean isUnsigned(ValueDescriptor v) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   186
            return v.isUnsigned();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   187
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   188
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   189
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   190
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   191
     * Constructs a {@code FlightRecorderPermission} with the specified name.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   192
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   193
     * @param name the permission name, must be either
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   194
     *        {@code "accessFlightRecorder"} or {@code "registerEvent"}, not
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   195
     *        {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   196
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   197
     * @throws IllegalArgumentException if {@code name} is empty or not valid
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   198
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   199
    public FlightRecorderPermission(String name) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   200
        super(Objects.requireNonNull(name));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   201
        if (!name.equals(Utils.ACCESS_FLIGHT_RECORDER) && !name.equals(Utils.REGISTER_EVENT)) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   202
            throw new IllegalArgumentException("name: " + name);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   203
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   204
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   205
}