8344236: Revisit SecurityManager usage in jdk.net after JEP 486 integration
Reviewed-by: dfuchs
This commit is contained in:
parent
7105bb98cf
commit
10def484df
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -27,12 +27,10 @@ package jdk.net;
|
|||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.nio.file.attribute.UserPrincipal;
|
import java.nio.file.attribute.UserPrincipal;
|
||||||
import java.nio.file.attribute.GroupPrincipal;
|
import java.nio.file.attribute.GroupPrincipal;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
||||||
import sun.nio.fs.UnixUserPrincipals;
|
import sun.nio.fs.UnixUserPrincipals;
|
||||||
|
|
||||||
@SuppressWarnings({"removal", "restricted"})
|
@SuppressWarnings("restricted")
|
||||||
class AIXSocketOptions extends PlatformSocketOptions {
|
class AIXSocketOptions extends PlatformSocketOptions {
|
||||||
|
|
||||||
public AIXSocketOptions() {
|
public AIXSocketOptions() {
|
||||||
@ -131,13 +129,6 @@ class AIXSocketOptions extends PlatformSocketOptions {
|
|||||||
private static native boolean keepAliveOptionsSupported0();
|
private static native boolean keepAliveOptionsSupported0();
|
||||||
private static native boolean quickAckSupported0();
|
private static native boolean quickAckSupported0();
|
||||||
static {
|
static {
|
||||||
if (System.getSecurityManager() == null) {
|
|
||||||
System.loadLibrary("extnet");
|
System.loadLibrary("extnet");
|
||||||
} else {
|
|
||||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
|
||||||
System.loadLibrary("extnet");
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -27,12 +27,10 @@ package jdk.net;
|
|||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.nio.file.attribute.UserPrincipal;
|
import java.nio.file.attribute.UserPrincipal;
|
||||||
import java.nio.file.attribute.GroupPrincipal;
|
import java.nio.file.attribute.GroupPrincipal;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
||||||
import sun.nio.fs.UnixUserPrincipals;
|
import sun.nio.fs.UnixUserPrincipals;
|
||||||
|
|
||||||
@SuppressWarnings({"removal", "restricted"})
|
@SuppressWarnings("restricted")
|
||||||
class LinuxSocketOptions extends PlatformSocketOptions {
|
class LinuxSocketOptions extends PlatformSocketOptions {
|
||||||
|
|
||||||
public LinuxSocketOptions() {
|
public LinuxSocketOptions() {
|
||||||
@ -143,14 +141,7 @@ class LinuxSocketOptions extends PlatformSocketOptions {
|
|||||||
private static native boolean incomingNapiIdSupported0();
|
private static native boolean incomingNapiIdSupported0();
|
||||||
private static native int getIncomingNapiId0(int fd) throws SocketException;
|
private static native int getIncomingNapiId0(int fd) throws SocketException;
|
||||||
static {
|
static {
|
||||||
if (System.getSecurityManager() == null) {
|
|
||||||
System.loadLibrary("extnet");
|
System.loadLibrary("extnet");
|
||||||
} else {
|
|
||||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
|
||||||
System.loadLibrary("extnet");
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -27,12 +27,10 @@ package jdk.net;
|
|||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.nio.file.attribute.UserPrincipal;
|
import java.nio.file.attribute.UserPrincipal;
|
||||||
import java.nio.file.attribute.GroupPrincipal;
|
import java.nio.file.attribute.GroupPrincipal;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
||||||
import sun.nio.fs.UnixUserPrincipals;
|
import sun.nio.fs.UnixUserPrincipals;
|
||||||
|
|
||||||
@SuppressWarnings({"removal", "restricted"})
|
@SuppressWarnings("restricted")
|
||||||
class MacOSXSocketOptions extends PlatformSocketOptions {
|
class MacOSXSocketOptions extends PlatformSocketOptions {
|
||||||
|
|
||||||
public MacOSXSocketOptions() {
|
public MacOSXSocketOptions() {
|
||||||
@ -116,13 +114,6 @@ class MacOSXSocketOptions extends PlatformSocketOptions {
|
|||||||
private static native boolean ipDontFragmentSupported0();
|
private static native boolean ipDontFragmentSupported0();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (System.getSecurityManager() == null) {
|
|
||||||
System.loadLibrary("extnet");
|
System.loadLibrary("extnet");
|
||||||
} else {
|
|
||||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
|
||||||
System.loadLibrary("extnet");
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,13 +148,6 @@ public final class Channels {
|
|||||||
if (!fd.valid())
|
if (!fd.valid())
|
||||||
throw new IllegalArgumentException("file descriptor is not valid");
|
throw new IllegalArgumentException("file descriptor is not valid");
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
SecurityManager sm = System.getSecurityManager();
|
|
||||||
if (sm != null) {
|
|
||||||
sm.checkRead(fd);
|
|
||||||
sm.checkWrite(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectorProvider provider = SelectorProvider.provider();
|
SelectorProvider provider = SelectorProvider.provider();
|
||||||
if (!(provider instanceof SelectorProviderImpl))
|
if (!(provider instanceof SelectorProviderImpl))
|
||||||
throw new UnsupportedOperationException("custom SelectorProvider");
|
throw new UnsupportedOperationException("custom SelectorProvider");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,12 +25,10 @@
|
|||||||
package jdk.net;
|
package jdk.net;
|
||||||
|
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({"removal", "restricted"})
|
@SuppressWarnings("restricted")
|
||||||
class WindowsSocketOptions extends PlatformSocketOptions {
|
class WindowsSocketOptions extends PlatformSocketOptions {
|
||||||
|
|
||||||
public WindowsSocketOptions() {
|
public WindowsSocketOptions() {
|
||||||
@ -97,13 +95,6 @@ class WindowsSocketOptions extends PlatformSocketOptions {
|
|||||||
private static native int getTcpKeepAliveIntvl0(int fd) throws SocketException;
|
private static native int getTcpKeepAliveIntvl0(int fd) throws SocketException;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (System.getSecurityManager() == null) {
|
|
||||||
System.loadLibrary("extnet");
|
System.loadLibrary("extnet");
|
||||||
} else {
|
|
||||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
|
||||||
System.loadLibrary("extnet");
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user