diff --git a/src/java.base/macosx/classes/java/net/DefaultInterface.java b/src/java.base/macosx/classes/java/net/DefaultInterface.java index b46de34a7cc..3bc629b26af 100644 --- a/src/java.base/macosx/classes/java/net/DefaultInterface.java +++ b/src/java.base/macosx/classes/java/net/DefaultInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -25,8 +25,6 @@ package java.net; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Enumeration; import java.io.IOException; @@ -105,9 +103,7 @@ class DefaultInterface { continue; boolean ip4 = false, ip6 = false, isNonLinkLocal = false; - PrivilegedAction> pa = ni::getInetAddresses; - @SuppressWarnings("removal") - Enumeration addrs = AccessController.doPrivileged(pa); + Enumeration addrs = ni.getInetAddresses(); while (addrs.hasMoreElements()) { InetAddress addr = addrs.nextElement(); if (!addr.isAnyLocalAddress()) { diff --git a/src/java.base/share/classes/java/net/SocketPermission.java b/src/java.base/share/classes/java/net/SocketPermission.java index 0c49e6cafef..e3a85bbf856 100644 --- a/src/java.base/share/classes/java/net/SocketPermission.java +++ b/src/java.base/share/classes/java/net/SocketPermission.java @@ -42,7 +42,6 @@ import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import sun.net.util.IPAddressUtil; import sun.net.PortConfig; -import sun.security.action.GetBooleanAction; import sun.security.util.RegisteredDomain; import sun.security.util.SecurityConstants; import sun.security.util.Debug; @@ -211,7 +210,8 @@ public final class SocketPermission extends Permission private transient boolean trusted; // true if the sun.net.trustNameService system property is set - private static final boolean trustNameService = GetBooleanAction.privilegedGetProperty("sun.net.trustNameService"); + private static final boolean trustNameService = + Boolean.getBoolean("sun.net.trustNameService"); private static Debug debug = null; private static boolean debugInit = false; diff --git a/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java b/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java index bfc10028ae0..d5c9a3feb44 100644 --- a/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java +++ b/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java @@ -710,13 +710,13 @@ public class FtpClient extends sun.net.ftp.FtpClient { } else if (address.isLoopbackAddress() && s.startsWith("127.")) { // can be 127.0 return new InetSocketAddress(s, port); } else if (address.isLoopbackAddress()) { - if (privilegedLocalHost().getHostAddress().equals(s)) { + if (getLocalHost().getHostAddress().equals(s)) { return new InetSocketAddress(s, port); } else { throw new FtpProtocolException(ERROR_MSG); } } else if (s.startsWith("127.")) { - if (privilegedLocalHost().equals(address)) { + if (getLocalHost().equals(address)) { return new InetSocketAddress(s, port); } else { throw new FtpProtocolException(ERROR_MSG); @@ -724,7 +724,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { } String hostName = address.getHostName(); if (!(IPAddressUtil.isIPv4LiteralAddress(hostName) || IPAddressUtil.isIPv6LiteralAddress(hostName))) { - InetAddress[] names = privilegedGetAllByName(hostName); + InetAddress[] names = getAllByName(hostName); String resAddress = Arrays .stream(names) .map(InetAddress::getHostAddress) @@ -738,7 +738,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { throw new FtpProtocolException(ERROR_MSG); } - private static InetAddress privilegedLocalHost() throws FtpProtocolException { + private static InetAddress getLocalHost() throws FtpProtocolException { try { return InetAddress.getLocalHost(); } catch (Exception e) { @@ -748,7 +748,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { } } - private static InetAddress[] privilegedGetAllByName(String hostName) throws FtpProtocolException { + private static InetAddress[] getAllByName(String hostName) throws FtpProtocolException { try { return InetAddress.getAllByName(hostName); } catch (Exception e) { diff --git a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java index 6074d323fa5..a466331de93 100644 --- a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java +++ b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, 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 @@ -117,7 +117,6 @@ public final class ResolverConfigurationImpl // Load DNS configuration from OS - @SuppressWarnings("removal") private void loadConfig() { assert Thread.holdsLock(lock); @@ -130,15 +129,9 @@ public final class ResolverConfigurationImpl } // get the name servers from /etc/resolv.conf - nameservers = - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public ArrayList run() { - // typically MAXNS is 3 but we've picked 5 here - // to allow for additional servers if required. - return resolvconf("nameserver", 1, 5); - } /* run */ - }); + // typically MAXNS is 3 but we've picked 5 here + // to allow for additional servers if required. + nameservers = resolvconf("nameserver", 1, 5); // get the search list (or domain) searchlist = getSearchList(); @@ -149,54 +142,19 @@ public final class ResolverConfigurationImpl // obtain search list or local domain - - @SuppressWarnings("removal") private ArrayList getSearchList() { - ArrayList sl; - // first try the search keyword in /etc/resolv.conf - sl = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public ArrayList run() { - ArrayList ll; - - // first try search keyword (max 6 domains) - ll = resolvconf("search", 6, 1); - if (ll.size() > 0) { - return ll; - } - - return null; - - } /* run */ - - }); - if (sl != null) { - return sl; - } + // first try search keyword (max 6 domains) + ArrayList sl = resolvconf("search", 6, 1); + if (sl.size() > 0) return sl; // No search keyword so use local domain // try domain keyword in /etc/resolv.conf - - sl = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public ArrayList run() { - ArrayList ll; - - ll = resolvconf("domain", 1, 1); - if (ll.size() > 0) { - return ll; - } - return null; - - } /* run */ - }); - if (sl != null) { - return sl; - } + sl = resolvconf("domain", 1, 1); + if (sl.size() > 0) return sl; // no local domain so try fallback (RPC) domain or // hostName diff --git a/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java b/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java index f9530cf7797..9c1b6b6ef9a 100644 --- a/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java +++ b/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java @@ -35,8 +35,6 @@ import java.io.FileDescriptor; import java.io.IOException; import java.io.PrintStream; -import sun.security.action.GetPropertyAction; - /** * A NetHooks provider that converts sockets from the TCP to SDP protocol prior * to binding or connecting. @@ -54,7 +52,7 @@ public class SdpProvider extends NetHooks.Provider { private PrintStream log; public SdpProvider() { - Properties props = GetPropertyAction.privilegedGetProperties(); + Properties props = System.getProperties(); // if this property is not defined then there is nothing to do. String file = props.getProperty("com.sun.sdp.conf"); if (file == null) { diff --git a/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java index c034cd4dcd7..dc56abb86df 100644 --- a/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java +++ b/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java @@ -41,7 +41,6 @@ import sun.net.www.HeaderParser; import sun.net.www.protocol.http.AuthenticationInfo; import sun.net.www.protocol.http.AuthScheme; import sun.net.www.protocol.http.HttpURLConnection; -import sun.security.action.GetPropertyAction; /** * NTLMAuthentication: @@ -72,21 +71,21 @@ import sun.security.action.GetPropertyAction; public final class NTLMAuthentication extends AuthenticationInfo { private static final NTLMAuthenticationCallback NTLMAuthCallback = - NTLMAuthenticationCallback.getNTLMAuthenticationCallback(); + NTLMAuthenticationCallback.getNTLMAuthenticationCallback(); private String hostname; /* Domain to use if not specified by user */ private static final String defaultDomain; /* Whether cache is enabled for NTLM */ private static final boolean ntlmCache; + static { - Properties props = GetPropertyAction.privilegedGetProperties(); - defaultDomain = props.getProperty("http.auth.ntlm.domain", ""); - String ntlmCacheProp = props.getProperty("jdk.ntlm.cache", "true"); + defaultDomain = System.getProperty("http.auth.ntlm.domain", ""); + String ntlmCacheProp = System.getProperty("jdk.ntlm.cache", "true"); ntlmCache = Boolean.parseBoolean(ntlmCacheProp); } - public static boolean supportsTransparentAuth () { + public static boolean supportsTransparentAuth() { return false; } @@ -101,23 +100,6 @@ public final class NTLMAuthentication extends AuthenticationInfo { return false; } - @SuppressWarnings("removal") - private void init0() { - - hostname = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public String run() { - String localhost; - try { - localhost = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException e) { - localhost = "localhost"; - } - return localhost; - } - }); - }; - PasswordAuthentication pw; Client client; @@ -150,9 +132,13 @@ public final class NTLMAuthentication extends AuthenticationInfo { username = s.substring (i+1); } password = pw.getPassword(); - init0(); try { - String version = GetPropertyAction.privilegedGetProperty("ntlm.version"); + hostname = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e) { + hostname = "localhost"; + } + try { + String version = System.getProperty("ntlm.version"); client = new Client(version, hostname, username, ntdomain, password); } catch (NTLMException ne) { try {