Skip to content

Commit

Permalink
Further cleanup. Removed stray privilegedGetProperty. Updated issue t…
Browse files Browse the repository at this point in the history
…itle
  • Loading branch information
dfuch committed Nov 29, 2024
1 parent d2b262c commit c67ca55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/net/SocketPermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,21 +710,21 @@ private InetSocketAddress validatePasvAddress(int port, String s, InetAddress ad
} 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);
}
}
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)
Expand All @@ -738,7 +738,7 @@ private InetSocketAddress validatePasvAddress(int port, String s, InetAddress ad
throw new FtpProtocolException(ERROR_MSG);
}

private static InetAddress privilegedLocalHost() throws FtpProtocolException {
private static InetAddress getLocalHost() throws FtpProtocolException {
try {
return InetAddress.getLocalHost();
} catch (Exception e) {
Expand All @@ -748,7 +748,7 @@ private static InetAddress privilegedLocalHost() throws FtpProtocolException {
}
}

private static InetAddress[] privilegedGetAllByName(String hostName) throws FtpProtocolException {
private static InetAddress[] getAllByName(String hostName) throws FtpProtocolException {
try {
return InetAddress.getAllByName(hostName);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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:
Expand Down Expand Up @@ -81,9 +80,8 @@ public final class NTLMAuthentication extends AuthenticationInfo {
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);
}

Expand Down Expand Up @@ -140,7 +138,7 @@ private void init (PasswordAuthentication pw) {
hostname = "localhost";
}
try {
String version = GetPropertyAction.privilegedGetProperty("ntlm.version");
String version = System.getProperty("ntlm.version");
client = new Client(version, hostname, username, ntdomain, password);
} catch (NTLMException ne) {
try {
Expand Down

0 comments on commit c67ca55

Please sign in to comment.