mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8266459: Implement JEP 411: Deprecate the Security Manager for Removal
Co-authored-by: Sean Mullan <mullan@openjdk.org> Co-authored-by: Lance Andersen <lancea@openjdk.org> Co-authored-by: Weijun Wang <weijun@openjdk.org> Reviewed-by: erikj, darcy, chegar, naoto, joehw, alanb, mchung, kcr, prr, lancea
This commit is contained in:
parent
19450b9951
commit
6765f90250
826 changed files with 2734 additions and 757 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2021, 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
|
||||
|
@ -585,6 +585,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
/**
|
||||
* Gets an InputStream for this socket.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
protected synchronized InputStream getInputStream() throws IOException {
|
||||
synchronized (fdLock) {
|
||||
if (isClosedOrPending())
|
||||
|
@ -610,6 +611,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
/**
|
||||
* Gets an OutputStream for this socket.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
protected synchronized OutputStream getOutputStream() throws IOException {
|
||||
synchronized (fdLock) {
|
||||
if (isClosedOrPending())
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
|
@ -128,6 +128,7 @@ class Authenticator {
|
|||
* @see java.net.NetPermission
|
||||
*/
|
||||
public static synchronized void setDefault(Authenticator a) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission setDefaultPermission
|
||||
|
@ -158,6 +159,7 @@ class Authenticator {
|
|||
* @see java.net.NetPermission
|
||||
*/
|
||||
public static Authenticator getDefault() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission requestPermission
|
||||
|
@ -201,6 +203,7 @@ class Authenticator {
|
|||
String prompt,
|
||||
String scheme) {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission requestPermission
|
||||
|
@ -263,6 +266,7 @@ class Authenticator {
|
|||
String prompt,
|
||||
String scheme) {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission requestPermission
|
||||
|
@ -330,6 +334,7 @@ class Authenticator {
|
|||
URL url,
|
||||
RequestorType reqType) {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission requestPermission
|
||||
|
@ -403,6 +408,7 @@ class Authenticator {
|
|||
URL url,
|
||||
RequestorType reqType) {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission requestPermission
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, 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
|
||||
|
@ -75,6 +75,7 @@ public abstract class CookieHandler {
|
|||
* @see #setDefault(CookieHandler)
|
||||
*/
|
||||
public static synchronized CookieHandler getDefault() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.GET_COOKIEHANDLER_PERMISSION);
|
||||
|
@ -95,6 +96,7 @@ public abstract class CookieHandler {
|
|||
* @see #getDefault()
|
||||
*/
|
||||
public static synchronized void setDefault(CookieHandler cHandler) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.SET_COOKIEHANDLER_PERMISSION);
|
||||
|
|
|
@ -1151,6 +1151,7 @@ public class DatagramSocket implements java.io.Closeable {
|
|||
if (factory != null) {
|
||||
throw new SocketException("factory already defined");
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkSetFactory();
|
||||
|
@ -1341,6 +1342,7 @@ public class DatagramSocket implements java.io.Closeable {
|
|||
|
||||
private static boolean usePlainDatagramSocketImpl() {
|
||||
PrivilegedAction<String> pa = () -> NetProperties.get("jdk.net.usePlainDatagramSocketImpl");
|
||||
@SuppressWarnings("removal")
|
||||
String s = AccessController.doPrivileged(pa);
|
||||
return (s != null) && (s.isEmpty() || s.equalsIgnoreCase("true"));
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import java.util.Set;
|
|||
* @since 1.8
|
||||
*/
|
||||
|
||||
/*package*/ class HttpConnectSocketImpl extends DelegatingSocketImpl {
|
||||
/*package*/ @SuppressWarnings("removal") class HttpConnectSocketImpl extends DelegatingSocketImpl {
|
||||
|
||||
private static final String httpURLClazzStr =
|
||||
"sun.net.www.protocol.http.HttpURLConnection";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2021, 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
|
||||
|
@ -388,6 +388,7 @@ public abstract class HttpURLConnection extends URLConnection {
|
|||
* @see #getFollowRedirects()
|
||||
*/
|
||||
public static void setFollowRedirects(boolean set) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
// seems to be the best check here...
|
||||
|
@ -475,6 +476,7 @@ public abstract class HttpURLConnection extends URLConnection {
|
|||
for (int i = 0; i < methods.length; i++) {
|
||||
if (methods[i].equals(method)) {
|
||||
if (method.equals("TRACE")) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null) {
|
||||
s.checkPermission(new NetPermission("allowHttpTrace"));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2021, 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
|
||||
|
@ -72,6 +72,7 @@ import jdk.internal.icu.text.UCharacterIterator;
|
|||
* @since 1.6
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public final class IDN {
|
||||
/**
|
||||
* Flag to allow processing of unassigned code points
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2021, 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
|
||||
|
@ -665,6 +665,7 @@ public class InetAddress implements java.io.Serializable {
|
|||
* the hostname for this IP address, ie, connect to the host
|
||||
*/
|
||||
if (check) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
sec.checkConnect(host, -1);
|
||||
|
@ -1450,6 +1451,7 @@ public class InetAddress implements java.io.Serializable {
|
|||
* give out a hostname
|
||||
*/
|
||||
if (check) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkConnect(host, -1);
|
||||
|
@ -1611,6 +1613,7 @@ public class InetAddress implements java.io.Serializable {
|
|||
*/
|
||||
public static InetAddress getLocalHost() throws UnknownHostException {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
try {
|
||||
// is cached data still valid?
|
||||
|
|
|
@ -118,6 +118,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
checkAddress(address, "connect");
|
||||
if (isClosed())
|
||||
return;
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
if (address.isMulticastAddress()) {
|
||||
|
@ -168,6 +169,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
* Return true if the given DatagramSocketImpl is an "old" impl. An old impl
|
||||
* is one that doesn't implement the abstract methods added in Java SE 1.4.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static boolean checkOldImpl(DatagramSocketImpl impl) {
|
||||
// DatagramSocketImpl.peekData() is a protected method, therefore we need to use
|
||||
// getDeclaredMethod, therefore we need permission to access the member
|
||||
|
@ -223,6 +225,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
InetAddress iaddr = epoint.getAddress();
|
||||
int port = epoint.getPort();
|
||||
checkAddress(iaddr, "bind");
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
sec.checkListen(port);
|
||||
|
@ -331,6 +334,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
if (packetPort < 0 || packetPort > 0xFFFF)
|
||||
throw new IllegalArgumentException("port out of range: " + packetPort);
|
||||
// check the address is ok with the security manager on every send.
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
|
||||
// The reason you want to synchronize on datagram packet
|
||||
|
@ -375,6 +379,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
bind(new InetSocketAddress(0));
|
||||
if (connectState == ST_NOT_CONNECTED) {
|
||||
// check the address is ok with the security manager before every recv.
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
while (true) {
|
||||
|
@ -480,6 +485,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
if (in.isAnyLocalAddress()) {
|
||||
in = InetAddress.anyLocalAddress();
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null) {
|
||||
s.checkConnect(in.getHostAddress(), -1);
|
||||
|
@ -751,6 +757,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
}
|
||||
|
||||
checkAddress(mcastaddr, "joinGroup");
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkMulticast(mcastaddr);
|
||||
|
@ -781,6 +788,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
}
|
||||
|
||||
checkAddress(mcastaddr, "leaveGroup");
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkMulticast(mcastaddr);
|
||||
|
@ -806,6 +814,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
throw new UnsupportedOperationException();
|
||||
|
||||
checkAddress(addr.getAddress(), "joinGroup");
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkMulticast(addr.getAddress());
|
||||
|
@ -831,6 +840,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
throw new UnsupportedOperationException();
|
||||
|
||||
checkAddress(addr.getAddress(), "leaveGroup");
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkMulticast(addr.getAddress());
|
||||
|
@ -945,6 +955,7 @@ final class NetMulticastSocket extends MulticastSocket {
|
|||
return ((Boolean)getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP)).booleanValue();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated
|
||||
@Override
|
||||
public void send(DatagramPacket p, byte ttl)
|
||||
|
|
|
@ -133,6 +133,7 @@ public final class NetworkInterface {
|
|||
InetAddress[] local_addrs = new InetAddress[addrs.length];
|
||||
boolean trusted = true;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
try {
|
||||
|
@ -169,6 +170,7 @@ public final class NetworkInterface {
|
|||
public java.util.List<InterfaceAddress> getInterfaceAddresses() {
|
||||
java.util.List<InterfaceAddress> lst = new java.util.ArrayList<>(1);
|
||||
if (bindings != null) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
for (int j=0; j<bindings.length; j++) {
|
||||
try {
|
||||
|
@ -512,6 +514,7 @@ public final class NetworkInterface {
|
|||
* @since 1.6
|
||||
*/
|
||||
public byte[] getHardwareAddress() throws SocketException {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
if (sec != null) {
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, 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
|
||||
|
@ -96,6 +96,7 @@ public abstract class ProxySelector {
|
|||
* @since 1.5
|
||||
*/
|
||||
public static ProxySelector getDefault() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION);
|
||||
|
@ -119,6 +120,7 @@ public abstract class ProxySelector {
|
|||
* @since 1.5
|
||||
*/
|
||||
public static void setDefault(ProxySelector ps) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.SET_PROXYSELECTOR_PERMISSION);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, 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
|
||||
|
@ -86,6 +86,7 @@ public abstract class ResponseCache {
|
|||
* @since 1.5
|
||||
*/
|
||||
public static synchronized ResponseCache getDefault() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.GET_RESPONSECACHE_PERMISSION);
|
||||
|
@ -109,6 +110,7 @@ public abstract class ResponseCache {
|
|||
* @since 1.5
|
||||
*/
|
||||
public static synchronized void setDefault(ResponseCache responseCache) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.SET_RESPONSECACHE_PERMISSION);
|
||||
|
|
|
@ -109,6 +109,7 @@ public class ServerSocket implements java.io.Closeable {
|
|||
}
|
||||
|
||||
private static Void checkPermission() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
|
||||
|
@ -380,6 +381,7 @@ public class ServerSocket implements java.io.Closeable {
|
|||
if (backlog < 1)
|
||||
backlog = 50;
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null)
|
||||
security.checkListen(epoint.getPort());
|
||||
|
@ -418,6 +420,7 @@ public class ServerSocket implements java.io.Closeable {
|
|||
return null;
|
||||
try {
|
||||
InetAddress in = getImpl().getInetAddress();
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkConnect(in.getHostAddress(), -1);
|
||||
|
@ -672,6 +675,7 @@ public class ServerSocket implements java.io.Closeable {
|
|||
impl.accept(si);
|
||||
|
||||
// check permission, close SocketImpl/connection if denied
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
try {
|
||||
|
@ -879,6 +883,7 @@ public class ServerSocket implements java.io.Closeable {
|
|||
*
|
||||
* @return a string representation of this socket.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public String toString() {
|
||||
if (!isBound())
|
||||
return "ServerSocket[unbound]";
|
||||
|
@ -935,6 +940,7 @@ public class ServerSocket implements java.io.Closeable {
|
|||
if (factory != null) {
|
||||
throw new SocketException("factory already defined");
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkSetFactory();
|
||||
|
|
|
@ -180,6 +180,7 @@ public class Socket implements java.io.Closeable {
|
|||
: sun.net.ApplicationProxy.create(proxy);
|
||||
Proxy.Type type = p.type();
|
||||
if (type == Proxy.Type.SOCKS || type == Proxy.Type.HTTP) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
InetSocketAddress epoint = (InetSocketAddress) p.address();
|
||||
if (epoint.getAddress() != null) {
|
||||
|
@ -237,6 +238,7 @@ public class Socket implements java.io.Closeable {
|
|||
if (impl == null) {
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
|
||||
|
@ -618,6 +620,7 @@ public class Socket implements java.io.Closeable {
|
|||
int port = epoint.getPort();
|
||||
checkAddress(addr, "connect");
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
if (epoint.isUnresolved())
|
||||
|
@ -671,6 +674,7 @@ public class Socket implements java.io.Closeable {
|
|||
InetAddress addr = epoint.getAddress();
|
||||
int port = epoint.getPort();
|
||||
checkAddress (addr, "bind");
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkListen(port);
|
||||
|
@ -739,6 +743,7 @@ public class Socket implements java.io.Closeable {
|
|||
InetAddress in = null;
|
||||
try {
|
||||
in = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkConnect(in.getHostAddress(), -1);
|
||||
|
@ -1763,6 +1768,7 @@ public class Socket implements java.io.Closeable {
|
|||
if (factory != null) {
|
||||
throw new SocketException("factory already defined");
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkSetFactory();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2021, 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
|
||||
|
@ -67,6 +67,7 @@ public abstract class SocketImpl implements SocketOptions {
|
|||
|
||||
private static boolean usePlainSocketImpl() {
|
||||
PrivilegedAction<String> pa = () -> NetProperties.get("jdk.net.usePlainSocketImpl");
|
||||
@SuppressWarnings("removal")
|
||||
String s = AccessController.doPrivileged(pa);
|
||||
return (s != null) && !s.equalsIgnoreCase("false");
|
||||
}
|
||||
|
|
|
@ -245,6 +245,7 @@ public final class SocketPermission extends Permission
|
|||
};
|
||||
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
Boolean tmp = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetBooleanAction("sun.net.trustNameService"));
|
||||
trustNameService = tmp.booleanValue();
|
||||
|
@ -1224,6 +1225,7 @@ public final class SocketPermission extends Permission
|
|||
* Check the system/security property for the ephemeral port range
|
||||
* for this system. The suffix is either "high" or "low"
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static int initEphemeralPorts(String suffix, int defval) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<>(){
|
||||
|
|
|
@ -73,6 +73,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
|
|||
return DefaultProxySelector.socksProxyVersion() == 4;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private synchronized void privilegedConnect(final String host,
|
||||
final int port,
|
||||
final int timeout)
|
||||
|
@ -148,6 +149,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
|
|||
String userName;
|
||||
String password = null;
|
||||
final InetAddress addr = InetAddress.getByName(server);
|
||||
@SuppressWarnings("removal")
|
||||
PasswordAuthentication pw =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<>() {
|
||||
|
@ -270,6 +272,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
|
|||
deadlineMillis = finish < 0 ? Long.MAX_VALUE : finish;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (!(endpoint instanceof InetSocketAddress epoint))
|
||||
throw new IllegalArgumentException("Unsupported address type");
|
||||
|
@ -285,6 +288,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
|
|||
// This is the general case
|
||||
// server is not null only when the socket was created with a
|
||||
// specified proxy in which case it does bypass the ProxySelector
|
||||
@SuppressWarnings("removal")
|
||||
ProxySelector sel = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<>() {
|
||||
public ProxySelector run() {
|
||||
|
|
|
@ -431,6 +431,7 @@ public final class URL implements java.io.Serializable {
|
|||
public URL(String protocol, String host, int port, String file,
|
||||
URLStreamHandler handler) throws MalformedURLException {
|
||||
if (handler != null) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
// check for permission to specify a handler
|
||||
|
@ -602,6 +603,7 @@ public final class URL implements java.io.Serializable {
|
|||
|
||||
// Check for permission to specify a handler
|
||||
if (handler != null) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
checkSpecifyHandler(sm);
|
||||
|
@ -770,7 +772,7 @@ public final class URL implements java.io.Serializable {
|
|||
/*
|
||||
* Checks for permission to specify a stream handler.
|
||||
*/
|
||||
private void checkSpecifyHandler(SecurityManager sm) {
|
||||
private void checkSpecifyHandler(@SuppressWarnings("removal") SecurityManager sm) {
|
||||
sm.checkPermission(SecurityConstants.SPECIFY_HANDLER_PERMISSION);
|
||||
}
|
||||
|
||||
|
@ -1129,6 +1131,7 @@ public final class URL implements java.io.Serializable {
|
|||
|
||||
// Create a copy of Proxy as a security measure
|
||||
Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : sun.net.ApplicationProxy.create(proxy);
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (p.type() != Proxy.Type.DIRECT && sm != null) {
|
||||
InetSocketAddress epoint = (InetSocketAddress) p.address();
|
||||
|
@ -1224,6 +1227,7 @@ public final class URL implements java.io.Serializable {
|
|||
if (factory != null) {
|
||||
throw new Error("factory already defined");
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkSetFactory();
|
||||
|
@ -1341,6 +1345,7 @@ public final class URL implements java.io.Serializable {
|
|||
// Thread-local gate to prevent recursive provider lookups
|
||||
private static ThreadLocal<Object> gate = new ThreadLocal<>();
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static URLStreamHandler lookupViaProviders(final String protocol) {
|
||||
if (gate.get() != null)
|
||||
throw new Error("Circular loading of URL stream handler providers detected");
|
||||
|
|
|
@ -84,6 +84,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
private final URLClassPath ucp;
|
||||
|
||||
/* The context to be used when loading classes and resources */
|
||||
@SuppressWarnings("removal")
|
||||
private final AccessControlContext acc;
|
||||
|
||||
/**
|
||||
|
@ -108,6 +109,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
* elements is {@code null}.
|
||||
* @see SecurityManager#checkCreateClassLoader
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public URLClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(parent);
|
||||
this.acc = AccessController.getContext();
|
||||
|
@ -115,7 +117,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
}
|
||||
|
||||
URLClassLoader(String name, URL[] urls, ClassLoader parent,
|
||||
AccessControlContext acc) {
|
||||
@SuppressWarnings("removal") AccessControlContext acc) {
|
||||
super(name, parent);
|
||||
this.acc = acc;
|
||||
this.ucp = new URLClassPath(urls, acc);
|
||||
|
@ -143,13 +145,14 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
* elements is {@code null}.
|
||||
* @see SecurityManager#checkCreateClassLoader
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public URLClassLoader(URL[] urls) {
|
||||
super();
|
||||
this.acc = AccessController.getContext();
|
||||
this.ucp = new URLClassPath(urls, acc);
|
||||
}
|
||||
|
||||
URLClassLoader(URL[] urls, AccessControlContext acc) {
|
||||
URLClassLoader(URL[] urls, @SuppressWarnings("removal") AccessControlContext acc) {
|
||||
super();
|
||||
this.acc = acc;
|
||||
this.ucp = new URLClassPath(urls, acc);
|
||||
|
@ -177,6 +180,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
* elements is {@code null}.
|
||||
* @see SecurityManager#checkCreateClassLoader
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public URLClassLoader(URL[] urls, ClassLoader parent,
|
||||
URLStreamHandlerFactory factory) {
|
||||
super(parent);
|
||||
|
@ -207,6 +211,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
*
|
||||
* @since 9
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public URLClassLoader(String name,
|
||||
URL[] urls,
|
||||
ClassLoader parent) {
|
||||
|
@ -237,6 +242,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
*
|
||||
* @since 9
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public URLClassLoader(String name, URL[] urls, ClassLoader parent,
|
||||
URLStreamHandlerFactory factory) {
|
||||
super(name, parent);
|
||||
|
@ -335,6 +341,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
* @since 1.7
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(new RuntimePermission("closeClassLoader"));
|
||||
|
@ -404,6 +411,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
* or if the loader is closed.
|
||||
* @throws NullPointerException if {@code name} is {@code null}.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
protected Class<?> findClass(final String name)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
|
@ -609,6 +617,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
/*
|
||||
* The same restriction to finding classes applies to resources
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
URL url = AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
public URL run() {
|
||||
|
@ -641,6 +650,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
return true;
|
||||
}
|
||||
do {
|
||||
@SuppressWarnings("removal")
|
||||
URL u = AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
public URL run() {
|
||||
|
@ -695,6 +705,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
* @throws NullPointerException if {@code codesource} is {@code null}.
|
||||
* @return the permissions granted to the codesource
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
protected PermissionCollection getPermissions(CodeSource codesource)
|
||||
{
|
||||
PermissionCollection perms = super.getPermissions(codesource);
|
||||
|
@ -779,8 +790,10 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
public static URLClassLoader newInstance(final URL[] urls,
|
||||
final ClassLoader parent) {
|
||||
// Save the caller's context
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext acc = AccessController.getContext();
|
||||
// Need a privileged block to create the class loader
|
||||
@SuppressWarnings("removal")
|
||||
URLClassLoader ucl = AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
public URLClassLoader run() {
|
||||
|
@ -805,8 +818,10 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
*/
|
||||
public static URLClassLoader newInstance(final URL[] urls) {
|
||||
// Save the caller's context
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext acc = AccessController.getContext();
|
||||
// Need a privileged block to create the class loader
|
||||
@SuppressWarnings("removal")
|
||||
URLClassLoader ucl = AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
public URLClassLoader run() {
|
||||
|
@ -828,11 +843,11 @@ final class FactoryURLClassLoader extends URLClassLoader {
|
|||
}
|
||||
|
||||
FactoryURLClassLoader(String name, URL[] urls, ClassLoader parent,
|
||||
AccessControlContext acc) {
|
||||
@SuppressWarnings("removal") AccessControlContext acc) {
|
||||
super(name, urls, parent, acc);
|
||||
}
|
||||
|
||||
FactoryURLClassLoader(URL[] urls, AccessControlContext acc) {
|
||||
FactoryURLClassLoader(URL[] urls, @SuppressWarnings("removal") AccessControlContext acc) {
|
||||
super(urls, acc);
|
||||
}
|
||||
|
||||
|
@ -841,6 +856,7 @@ final class FactoryURLClassLoader extends URLClassLoader {
|
|||
{
|
||||
// First check if we have permission to access the package. This
|
||||
// should go away once we've added support for exported packages.
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
int i = name.lastIndexOf('.');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2021, 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
|
||||
|
@ -334,6 +334,7 @@ public abstract class URLConnection {
|
|||
* @since 1.2
|
||||
*/
|
||||
public static void setFileNameMap(FileNameMap map) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) sm.checkSetFactory();
|
||||
fileNameMap = map;
|
||||
|
@ -1264,6 +1265,7 @@ public abstract class URLConnection {
|
|||
if (factory != null) {
|
||||
throw new Error("factory already defined");
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkSetFactory();
|
||||
|
@ -1377,6 +1379,7 @@ public abstract class URLConnection {
|
|||
return UnknownContentHandler.INSTANCE;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private ContentHandler lookupContentHandlerViaProvider(String contentType) {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, 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
|
||||
|
@ -50,6 +50,7 @@ public abstract class URLStreamHandlerProvider
|
|||
implements URLStreamHandlerFactory
|
||||
{
|
||||
private static Void checkPermission() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new RuntimePermission("setFactory"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue