Skip to content

Commit bf8342e

Browse files
committed
8289: Remove security manager related code
Reviewed-by: aptmac
1 parent fb4fb06 commit bf8342e

File tree

4 files changed

+2
-94
lines changed

4 files changed

+2
-94
lines changed

application/tests/org.openjdk.jmc.rjmx.test/src/test/java/org/openjdk/jmc/rjmx/test/testutil/JVMKeepAlive.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import java.io.IOException;
3636
import java.net.DatagramPacket;
3737
import java.net.DatagramSocket;
38-
import java.security.AccessController;
39-
import java.security.PrivilegedAction;
4038

4139
/**
4240
* Simple, small test class to make a JVM stay awake. Takes one optional argument, which is the
@@ -63,12 +61,7 @@ public class JVMKeepAlive {
6361
private static class JVMKeepAliveSlayer implements Runnable {
6462
@Override
6563
public void run() {
66-
String portStr = AccessController.doPrivileged(new PrivilegedAction<String>() {
67-
@Override
68-
public String run() {
69-
return System.getProperty(PROPERTY_KILL_PORT, String.valueOf(DEFAULT_KILL_PORT));
70-
}
71-
});
64+
String portStr = System.getProperty(PROPERTY_KILL_PORT, String.valueOf(DEFAULT_KILL_PORT));
7265

7366
int port = 0;
7467
try {

core/org.openjdk.jmc.common/src/main/java/org/openjdk/jmc/common/security/SecurityManagerFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public final class SecurityManagerFactory {
5252
try {
5353
if (className != null) {
5454
Class<? extends Object> c = Class.forName(className);
55-
instance = (ISecurityManager) c.newInstance();
55+
instance = (ISecurityManager) c.getDeclaredConstructor().newInstance();
5656
}
5757
} catch (Exception e) {
5858
LOGGER.log(Level.SEVERE, "Could not create Security manager for className. Using default! Exception was:", //$NON-NLS-1$

core/org.openjdk.jmc.flightrecorder.rules/src/main/java/org/openjdk/jmc/flightrecorder/rules/report/JfrReportPermission.java

-71
This file was deleted.

core/org.openjdk.jmc.flightrecorder.rules/src/main/java/org/openjdk/jmc/flightrecorder/rules/report/JfrRulesReport.java

-14
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,13 @@
8787
public class JfrRulesReport {
8888

8989
private static final Map<String, String> TRANSFORMS = new LinkedHashMap<>();
90-
private static final JfrReportPermission OVERRIDE_PERMISSION = new JfrReportPermission("override"); //$NON-NLS-1$
9190

9291
static {
9392
TRANSFORMS.put("html", "org/openjdk/jmc/flightrecorder/rules/report/html.xslt"); //$NON-NLS-1$ //$NON-NLS-2$
9493
TRANSFORMS.put("text", "org/openjdk/jmc/flightrecorder/rules/report/text.xslt"); //$NON-NLS-1$ //$NON-NLS-2$
9594
TRANSFORMS.put("json", "org/openjdk/jmc/flightrecorder/rules/report/json.xslt"); //$NON-NLS-1$ //$NON-NLS-2$
9695
}
9796

98-
private static void checkAccess(JfrReportPermission p) throws SecurityException {
99-
SecurityManager sm = System.getSecurityManager();
100-
if (sm != null) {
101-
sm.checkPermission(p);
102-
}
103-
}
104-
105-
private static void checkOverrideAccess() throws SecurityException {
106-
checkAccess(OVERRIDE_PERMISSION);
107-
}
108-
10997
public static void main(String[] args) throws ParserConfigurationException, TransformerException {
11098
if (args.length == 0) {
11199
System.out.println("Enter one or more JDK Flight Recorder file names as arguments to this program."); //$NON-NLS-1$
@@ -201,8 +189,6 @@ public static void printReport(
201189
String xsltResourceName = TRANSFORMS.get(formatName);
202190
if (xsltResourceName != null) {
203191
if (override) {
204-
// Must prevent unauthorized injection of potentially dangerous XSLTs.
205-
checkOverrideAccess();
206192
xsltResourceStream = Thread.currentThread().getContextClassLoader()
207193
.getResourceAsStream(xsltResourceName);
208194
} else {

0 commit comments

Comments
 (0)