--- /dev/null 2017-11-09 09:38:01.297999907 +0100 +++ new/src/jdk.jfr/share/classes/jdk/jfr/FlightRecorderPermission.java 2018-04-09 15:38:10.822579622 +0200 @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import jdk.jfr.internal.PlatformEventType; +import jdk.jfr.internal.PlatformRecording; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.Utils; + +/** + * Permission for controlling access to Flight Recorder. + *
+ * The following table provides a summary description of what the permission + * allows, and discusses the risks of granting code the permission. + * + *
Permission Target Name | + *What the Permission Allows | + *Risks of Allowing this Permission | + *
---|---|---|
accessFlightRecorder | + *Ability to create a Flight Recorder instance, register callbacks to + * monitor Flight Recorder's life cycle and control an already existing instance + * of Flight Recorder, which can record and dump runtime information, such as + * stack traces, class names and data in user defined events. | + *A malicious user may be able to extract sensitive information stored in + * events and interrupt Flight Recorder by installing listeners or hooks that + * never finishes. | + *
registerEvent | + *Ability to register events, write data to the Flight Recorder buffers + * and execute code in a callback function for periodic events. + * + * | A malicious user may be able to write sensitive information to Flight + * Recorder buffers. | + *
+ * Programmers do not normally create {@code FlightRecorderPermission} objects
+ * directly. Instead they are created by the security policy code based on
+ * reading the security policy file.
+ *
+ * @since 9
+ *
+ * @see java.security.BasicPermission
+ * @see java.security.Permission
+ * @see java.security.Permissions
+ * @see java.security.PermissionCollection
+ * @see java.lang.SecurityManager
+ *
+ */
+@SuppressWarnings("serial")
+public final class FlightRecorderPermission extends java.security.BasicPermission {
+
+ // Purpose of InternalAccess is to give classes in jdk.jfr.internal
+ // access to package private methods in this package (jdk.jfr).
+ //
+ // The initialization could be done in any class in this package,
+ // but this one was chosen because it is light weight and
+ // lacks dependencies on other public classes.
+ static {
+ PrivateAccess.setPrivateAccess(new InternalAccess());
+ }
+
+ private final static class InternalAccess extends PrivateAccess {
+
+ @Override
+ public Type getType(Object o) {
+ if (o instanceof AnnotationElement) {
+ return ((AnnotationElement) o).getType();
+ }
+ if (o instanceof EventType) {
+ return ((EventType) o).getType();
+ }
+ if (o instanceof ValueDescriptor) {
+ return ((ValueDescriptor) o).getType();
+ }
+ if (o instanceof SettingDescriptor) {
+ return ((SettingDescriptor) o).getType();
+ }
+ throw new Error("Unknown type " + o.getClass());
+ }
+
+ @Override
+ public Configuration newConfiguration(String name, String label, String description, String provider, Map