8155775: Re-examine naming of privileged methods to access System properties

Reviewed-by: mullan
This commit is contained in:
Claes Redestad 2016-05-03 15:50:54 +02:00
parent 44790114ee
commit e8cd76568d
80 changed files with 164 additions and 152 deletions

View File

@ -102,7 +102,7 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
@Override @Override
FileTypeDetector getFileTypeDetector() { FileTypeDetector getFileTypeDetector() {
String userHome = GetPropertyAction.getProperty("user.home"); String userHome = GetPropertyAction.privilegedGetProperty("user.home");
Path userMimeTypes = Paths.get(userHome, ".mime.types"); Path userMimeTypes = Paths.get(userHome, ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types"); Path etcMimeTypes = Paths.get("/etc/mime.types");

View File

@ -84,7 +84,8 @@ class KQueueArrayWrapper {
static { static {
IOUtil.load(); IOUtil.load();
initStructSizes(); initStructSizes();
String datamodel = GetPropertyAction.getProperty("sun.arch.data.model"); String datamodel =
GetPropertyAction.privilegedGetProperty("sun.arch.data.model");
is64bit = "64".equals(datamodel); is64bit = "64".equals(datamodel);
} }

View File

@ -29,8 +29,6 @@ import java.nio.file.*;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
import static sun.nio.fs.MacOSXNativeDispatcher.*; import static sun.nio.fs.MacOSXNativeDispatcher.*;

View File

@ -46,8 +46,8 @@ public class MacOSXFileSystemProvider extends BsdFileSystemProvider {
@Override @Override
FileTypeDetector getFileTypeDetector() { FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get( Path userMimeTypes = Paths.get(GetPropertyAction
GetPropertyAction.getProperty("user.home"), ".mime.types"); .privilegedGetProperty("user.home"), ".mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes), return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new UTIFileTypeDetector()); new UTIFileTypeDetector());

View File

@ -1896,7 +1896,7 @@ public class File
// temporary directory location // temporary directory location
private static final File tmpdir = new File( private static final File tmpdir = new File(
GetPropertyAction.getProperty("java.io.tmpdir")); GetPropertyAction.privilegedGetProperty("java.io.tmpdir"));
static File location() { static File location() {
return tmpdir; return tmpdir;
} }

View File

@ -468,7 +468,7 @@ public final class ProcessBuilder
*/ */
public abstract static class Redirect { public abstract static class Redirect {
private static final File NULL_FILE = new File( private static final File NULL_FILE = new File(
(GetPropertyAction.getProperty("os.name") (GetPropertyAction.privilegedGetProperty("os.name")
.startsWith("Windows") ? "NUL" : "/dev/null") .startsWith("Windows") ? "NUL" : "/dev/null")
); );

View File

@ -78,7 +78,8 @@ final class StackStreamFactory {
* Performance work and extensive testing is needed to replace the * Performance work and extensive testing is needed to replace the
* VM built-in backtrace filled in Throwable with the StackWalker. * VM built-in backtrace filled in Throwable with the StackWalker.
*/ */
final static boolean isDebug = getProperty("stackwalk.debug", false); final static boolean isDebug =
"true".equals(GetPropertyAction.privilegedGetProperty("stackwalk.debug"));
static <T> StackFrameTraverser<T> static <T> StackFrameTraverser<T>
makeStackTraverser(StackWalker walker, Function<? super Stream<StackFrame>, ? extends T> function) makeStackTraverser(StackWalker walker, Function<? super Stream<StackFrame>, ? extends T> function)
@ -988,11 +989,4 @@ final class StackStreamFactory {
c.getName().startsWith("java.lang.invoke.LambdaForm"); c.getName().startsWith("java.lang.invoke.LambdaForm");
} }
private static boolean getProperty(String key, boolean value) {
String s = GetPropertyAction.getProperty(key);
if (s != null) {
return Boolean.parseBoolean(s);
}
return value;
}
} }

View File

@ -88,7 +88,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
static { static {
final String key = "jdk.internal.lambda.dumpProxyClasses"; final String key = "jdk.internal.lambda.dumpProxyClasses";
String path = GetPropertyAction.getProperty(key); String path = GetPropertyAction.privilegedGetProperty(key);
dumper = (null == path) ? null : ProxyClassesDumper.getInstance(path); dumper = (null == path) ? null : ProxyClassesDumper.getInstance(path);
} }

View File

@ -53,7 +53,7 @@ import sun.security.action.GetPropertyAction;
static final boolean VAR_HANDLE_GUARDS; static final boolean VAR_HANDLE_GUARDS;
static { static {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
DEBUG_METHOD_HANDLE_NAMES = Boolean.parseBoolean( DEBUG_METHOD_HANDLE_NAMES = Boolean.parseBoolean(
props.getProperty("java.lang.invoke.MethodHandle.DEBUG_NAMES")); props.getProperty("java.lang.invoke.MethodHandle.DEBUG_NAMES"));
DUMP_CLASS_FILES = Boolean.parseBoolean( DUMP_CLASS_FILES = Boolean.parseBoolean(

View File

@ -197,7 +197,7 @@ public final class StringConcatFactory {
// DEBUG = false; // implied // DEBUG = false; // implied
// DUMPER = null; // implied // DUMPER = null; // implied
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
final String strategy = final String strategy =
props.getProperty("java.lang.invoke.stringConcat"); props.getProperty("java.lang.invoke.stringConcat");
CACHE_ENABLE = Boolean.parseBoolean( CACHE_ENABLE = Boolean.parseBoolean(

View File

@ -582,7 +582,7 @@ public class Proxy implements java.io.Serializable {
} }
private static final String DEBUG = private static final String DEBUG =
GetPropertyAction.getProperty("jdk.proxy.debug", ""); GetPropertyAction.privilegedGetProperty("jdk.proxy.debug", "");
private static boolean isDebug() { private static boolean isDebug() {
return !DEBUG.isEmpty(); return !DEBUG.isEmpty();

View File

@ -52,7 +52,8 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
protected InetAddress connectedAddress = null; protected InetAddress connectedAddress = null;
private int connectedPort = -1; private int connectedPort = -1;
private static final String os = GetPropertyAction.getProperty("os.name"); private static final String os =
GetPropertyAction.privilegedGetProperty("os.name");
/** /**
* flag set if the native connect() call not to be used * flag set if the native connect() call not to be used

View File

@ -1124,7 +1124,7 @@ class InetAddress implements java.io.Serializable {
private static NameService createNameService() { private static NameService createNameService() {
String hostsFileName = String hostsFileName =
GetPropertyAction.getProperty("jdk.net.hosts.file"); GetPropertyAction.privilegedGetProperty("jdk.net.hosts.file");
NameService theNameService; NameService theNameService;
if (hostsFileName != null) { if (hostsFileName != null) {
theNameService = new HostsFileNameService(hostsFileName); theNameService = new HostsFileNameService(hostsFileName);
@ -1643,7 +1643,7 @@ class InetAddress implements java.io.Serializable {
* property can vary across implementations of the java. * property can vary across implementations of the java.
* classes. The default is an empty String "". * classes. The default is an empty String "".
*/ */
String prefix = GetPropertyAction.getProperty("impl.prefix", ""); String prefix = GetPropertyAction.privilegedGetProperty("impl.prefix", "");
try { try {
impl = Class.forName("java.net." + prefix + implName).newInstance(); impl = Class.forName("java.net." + prefix + implName).newInstance();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {

View File

@ -178,7 +178,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
userName = pw.getUserName(); userName = pw.getUserName();
password = new String(pw.getPassword()); password = new String(pw.getPassword());
} else { } else {
userName = GetPropertyAction.getProperty("user.name"); userName = GetPropertyAction.privilegedGetProperty("user.name");
} }
if (userName == null) if (userName == null)
return false; return false;
@ -1088,7 +1088,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
userName = System.getProperty("user.name"); userName = System.getProperty("user.name");
} catch (SecurityException se) { /* swallow Exception */ } } catch (SecurityException se) { /* swallow Exception */ }
} else { } else {
userName = GetPropertyAction.getProperty("user.name"); userName = GetPropertyAction.privilegedGetProperty("user.name");
} }
return userName; return userName;
} }

View File

@ -1212,7 +1212,7 @@ public final class URL implements java.io.Serializable {
private static URLStreamHandler lookupViaProperty(String protocol) { private static URLStreamHandler lookupViaProperty(String protocol) {
String packagePrefixList = String packagePrefixList =
GetPropertyAction.getProperty(protocolPathProp); GetPropertyAction.privilegedGetProperty(protocolPathProp);
if (packagePrefixList == null) { if (packagePrefixList == null) {
// not set // not set
return null; return null;

View File

@ -1397,7 +1397,7 @@ public abstract class URLConnection {
*/ */
private String getContentHandlerPkgPrefixes() { private String getContentHandlerPkgPrefixes() {
String packagePrefixList = String packagePrefixList =
GetPropertyAction.getProperty(contentPathProp, ""); GetPropertyAction.privilegedGetProperty(contentPathProp, "");
if (packagePrefixList != "") { if (packagePrefixList != "") {
packagePrefixList += "|"; packagePrefixList += "|";

View File

@ -133,7 +133,7 @@ public class URLEncoder {
dontNeedEncoding.set('.'); dontNeedEncoding.set('.');
dontNeedEncoding.set('*'); dontNeedEncoding.set('*');
dfltEncName = GetPropertyAction.getProperty("file.encoding"); dfltEncName = GetPropertyAction.privilegedGetProperty("file.encoding");
} }
/** /**

View File

@ -283,8 +283,8 @@ public abstract class Charset
if (level == null) { if (level == null) {
if (!VM.isBooted()) if (!VM.isBooted())
return false; return false;
bugLevel = level = bugLevel = level = GetPropertyAction
GetPropertyAction.getProperty("sun.nio.cs.bugLevel", ""); .privilegedGetProperty("sun.nio.cs.bugLevel", "");
} }
return level.equals(bl); return level.equals(bl);
} }
@ -609,7 +609,8 @@ public abstract class Charset
public static Charset defaultCharset() { public static Charset defaultCharset() {
if (defaultCharset == null) { if (defaultCharset == null) {
synchronized (Charset.class) { synchronized (Charset.class) {
String csn = GetPropertyAction.getProperty("file.encoding"); String csn = GetPropertyAction
.privilegedGetProperty("file.encoding");
Charset cs = lookup(csn); Charset cs = lookup(csn);
if (cs != null) if (cs != null)
defaultCharset = cs; defaultCharset = cs;

View File

@ -46,7 +46,7 @@ class TempFileHelper {
// temporary directory location // temporary directory location
private static final Path tmpdir = private static final Path tmpdir =
Paths.get(GetPropertyAction.getProperty("java.io.tmpdir")); Paths.get(GetPropertyAction.privilegedGetProperty("java.io.tmpdir"));
private static final boolean isPosix = private static final boolean isPosix =
FileSystems.getDefault().supportedFileAttributeViews().contains("posix"); FileSystems.getDefault().supportedFileAttributeViews().contains("posix");

View File

@ -858,7 +858,7 @@ public final class Locale implements Cloneable, Serializable {
private static Locale initDefault() { private static Locale initDefault() {
String language, region, script, country, variant; String language, region, script, country, variant;
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
language = props.getProperty("user.language", "en"); language = props.getProperty("user.language", "en");
// for compatibility, check for old user.region property // for compatibility, check for old user.region property
region = props.getProperty("user.region"); region = props.getProperty("user.region");
@ -883,7 +883,7 @@ public final class Locale implements Cloneable, Serializable {
} }
private static Locale initDefault(Locale.Category category) { private static Locale initDefault(Locale.Category category) {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
return getInstance( return getInstance(
props.getProperty(category.languageKey, props.getProperty(category.languageKey,
defaultLocale.getLanguage()), defaultLocale.getLanguage()),

View File

@ -140,9 +140,8 @@ public class PropertyResourceBundle extends ResourceBundle {
// Check whether the strict encoding is specified. // Check whether the strict encoding is specified.
// The possible encoding is either "ISO-8859-1" or "UTF-8". // The possible encoding is either "ISO-8859-1" or "UTF-8".
private static final String encoding = private static final String encoding = GetPropertyAction
GetPropertyAction .privilegedGetProperty("java.util.PropertyResourceBundle.encoding", "")
.getProperty("java.util.PropertyResourceBundle.encoding", "")
.toUpperCase(Locale.ROOT); .toUpperCase(Locale.ROOT);
/** /**

View File

@ -42,6 +42,7 @@ import java.io.Serializable;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Properties;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
import sun.util.calendar.ZoneInfo; import sun.util.calendar.ZoneInfo;
import sun.util.calendar.ZoneInfoFile; import sun.util.calendar.ZoneInfoFile;
@ -660,12 +661,13 @@ public abstract class TimeZone implements Serializable, Cloneable {
private static synchronized TimeZone setDefaultZone() { private static synchronized TimeZone setDefaultZone() {
TimeZone tz; TimeZone tz;
// get the time zone ID from the system properties // get the time zone ID from the system properties
String zoneID = GetPropertyAction.getProperty("user.timezone"); Properties props = GetPropertyAction.privilegedGetProperties();
String zoneID = props.getProperty("user.timezone");
// if the time zone ID is not set (yet), perform the // if the time zone ID is not set (yet), perform the
// platform to Java time zone ID mapping. // platform to Java time zone ID mapping.
if (zoneID == null || zoneID.isEmpty()) { if (zoneID == null || zoneID.isEmpty()) {
String javaHome = GetPropertyAction.getProperty("java.home"); String javaHome = props.getProperty("java.home");
try { try {
zoneID = getSystemTimeZoneID(javaHome); zoneID = getSystemTimeZoneID(javaHome);
if (zoneID == null) { if (zoneID == null) {
@ -693,13 +695,7 @@ public abstract class TimeZone implements Serializable, Cloneable {
assert tz != null; assert tz != null;
final String id = zoneID; final String id = zoneID;
AccessController.doPrivileged(new PrivilegedAction<>() { props.setProperty("user.timezone", id);
@Override
public Void run() {
System.setProperty("user.timezone", id);
return null;
}
});
defaultTimeZone = tz; defaultTimeZone = tz;
return tz; return tz;

View File

@ -155,7 +155,7 @@ class JarFile extends ZipFile {
BASE_VERSION = 8; // one less than lowest version for versioned entries BASE_VERSION = 8; // one less than lowest version for versioned entries
int runtimeVersion = jdk.Version.current().major(); int runtimeVersion = jdk.Version.current().major();
String jarVersion = String jarVersion =
GetPropertyAction.getProperty("jdk.util.jar.version"); GetPropertyAction.privilegedGetProperty("jdk.util.jar.version");
if (jarVersion != null) { if (jarVersion != null) {
int jarVer = Integer.parseInt(jarVersion); int jarVer = Integer.parseInt(jarVersion);
runtimeVersion = (jarVer > runtimeVersion) runtimeVersion = (jarVer > runtimeVersion)
@ -163,7 +163,7 @@ class JarFile extends ZipFile {
} }
RUNTIME_VERSION = runtimeVersion; RUNTIME_VERSION = runtimeVersion;
String enableMultiRelease = GetPropertyAction String enableMultiRelease = GetPropertyAction
.getProperty("jdk.util.jar.enableMultiRelease", "true"); .privilegedGetProperty("jdk.util.jar.enableMultiRelease", "true");
switch (enableMultiRelease) { switch (enableMultiRelease) {
case "true": case "true":
default: default:

View File

@ -695,7 +695,7 @@ public abstract class Pack200 {
Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl; Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
if (impl == null) { if (impl == null) {
// The first time, we must decide which class to use. // The first time, we must decide which class to use.
implName = GetPropertyAction.getProperty(prop,""); implName = GetPropertyAction.privilegedGetProperty(prop,"");
if (implName != null && !implName.equals("")) if (implName != null && !implName.equals(""))
impl = Class.forName(implName); impl = Class.forName(implName);
else if (PACK_PROVIDER.equals(prop)) else if (PACK_PROVIDER.equals(prop))

View File

@ -94,7 +94,7 @@ public class PatternSyntaxException
} }
private static final String nl = private static final String nl =
GetPropertyAction.getProperty("line.separator"); GetPropertyAction.privilegedGetProperty("line.separator");
/** /**
* Returns a multi-line string containing the description of the syntax * Returns a multi-line string containing the description of the syntax

View File

@ -55,7 +55,7 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
*/ */
private static final boolean inhibitZip64 = private static final boolean inhibitZip64 =
Boolean.parseBoolean( Boolean.parseBoolean(
GetPropertyAction.getProperty("jdk.util.zip.inhibitZip64")); GetPropertyAction.privilegedGetProperty("jdk.util.zip.inhibitZip64"));
private static class XEntry { private static class XEntry {
final ZipEntry entry; final ZipEntry entry;

View File

@ -51,7 +51,7 @@ public abstract class SSLSocketFactory extends SocketFactory
static final boolean DEBUG; static final boolean DEBUG;
static { static {
String s = GetPropertyAction.getProperty("javax.net.debug", "") String s = GetPropertyAction.privilegedGetProperty("javax.net.debug", "")
.toLowerCase(Locale.ENGLISH); .toLowerCase(Locale.ENGLISH);
DEBUG = s.contains("all") || s.contains("ssl"); DEBUG = s.contains("all") || s.contains("ssl");

View File

@ -273,7 +273,8 @@ public final class Version
*/ */
public static Version current() { public static Version current() {
if (current == null) { if (current == null) {
current = parse(GetPropertyAction.getProperty("java.version")); current = parse(
GetPropertyAction.privilegedGetProperty("java.version"));
} }
return current; return current;
} }

View File

@ -85,7 +85,7 @@ public class URLClassPath {
private static final boolean DISABLE_JAR_CHECKING; private static final boolean DISABLE_JAR_CHECKING;
static { static {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
JAVA_VERSION = props.getProperty("java.version"); JAVA_VERSION = props.getProperty("java.version");
DEBUG = (props.getProperty("sun.misc.URLClassPath.debug") != null); DEBUG = (props.getProperty("sun.misc.URLClassPath.debug") != null);
String p = props.getProperty("sun.misc.URLClassPath.disableJarChecking"); String p = props.getProperty("sun.misc.URLClassPath.disableJarChecking");

View File

@ -81,7 +81,7 @@ public final class LoggerFinderLoader {
// Get configuration error policy // Get configuration error policy
private static ErrorPolicy configurationErrorPolicy() { private static ErrorPolicy configurationErrorPolicy() {
String errorPolicy = String errorPolicy =
GetPropertyAction.getProperty("jdk.logger.finder.error"); GetPropertyAction.privilegedGetProperty("jdk.logger.finder.error");
if (errorPolicy == null || errorPolicy.isEmpty()) { if (errorPolicy == null || errorPolicy.isEmpty()) {
return ErrorPolicy.WARNING; return ErrorPolicy.WARNING;
} }
@ -96,7 +96,7 @@ public final class LoggerFinderLoader {
// This is further submitted to the configuration error policy. // This is further submitted to the configuration error policy.
private static boolean ensureSingletonProvider() { private static boolean ensureSingletonProvider() {
return Boolean.parseBoolean( return Boolean.parseBoolean(
GetPropertyAction.getProperty("jdk.logger.finder.singleton")); GetPropertyAction.privilegedGetProperty("jdk.logger.finder.singleton"));
} }
private static Iterator<System.LoggerFinder> findLoggerFinderProviders() { private static Iterator<System.LoggerFinder> findLoggerFinderProviders() {

View File

@ -56,7 +56,7 @@ public class SimpleConsoleLogger extends LoggerConfiguration
static Level getDefaultLevel() { static Level getDefaultLevel() {
String levelName = GetPropertyAction String levelName = GetPropertyAction
.getProperty("jdk.system.logger.level", "INFO"); .privilegedGetProperty("jdk.system.logger.level", "INFO");
try { try {
return Level.valueOf(levelName); return Level.valueOf(levelName);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
@ -426,7 +426,7 @@ public class SimpleConsoleLogger extends LoggerConfiguration
static private final String[] skips; static private final String[] skips;
static { static {
String additionalPkgs = String additionalPkgs =
GetPropertyAction.getProperty("jdk.logger.packages"); GetPropertyAction.privilegedGetProperty("jdk.logger.packages");
skips = additionalPkgs == null ? new String[0] : additionalPkgs.split(","); skips = additionalPkgs == null ? new String[0] : additionalPkgs.split(",");
} }
@ -485,7 +485,7 @@ public class SimpleConsoleLogger extends LoggerConfiguration
// jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java // jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java
// to fail - because that test has a testcase which somehow references // to fail - because that test has a testcase which somehow references
// PlatformLogger and counts the number of generated lambda classes. // PlatformLogger and counts the number of generated lambda classes.
String format = GetPropertyAction.getProperty(key); String format = GetPropertyAction.privilegedGetProperty(key);
if (format == null && defaultPropertyGetter != null) { if (format == null && defaultPropertyGetter != null) {
format = defaultPropertyGetter.apply(key); format = defaultPropertyGetter.apply(key);

View File

@ -343,8 +343,8 @@ public class Reflection {
private static void printStackTraceIfNeeded(Throwable e) { private static void printStackTraceIfNeeded(Throwable e) {
if (!printStackWhenAccessFailsSet && VM.initLevel() >= 1) { if (!printStackWhenAccessFailsSet && VM.initLevel() >= 1) {
String s = GetPropertyAction String s = GetPropertyAction.privilegedGetProperty(
.getProperty("sun.reflect.debugModuleAccessChecks"); "sun.reflect.debugModuleAccessChecks");
printStackWhenAccessFails = printStackWhenAccessFails =
(s != null && !s.equalsIgnoreCase("false")); (s != null && !s.equalsIgnoreCase("false"));
printStackWhenAccessFailsSet = true; printStackWhenAccessFailsSet = true;

View File

@ -398,7 +398,7 @@ public class ReflectionFactory {
return; return;
} }
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
String val = props.getProperty("sun.reflect.noInflation"); String val = props.getProperty("sun.reflect.noInflation");
if (val != null && val.equals("true")) { if (val != null && val.equals("true")) {
noInflation = true; noInflation = true;

View File

@ -53,8 +53,8 @@ public class ResourceManager {
private static final AtomicInteger numSockets; private static final AtomicInteger numSockets;
static { static {
String prop = String prop = GetPropertyAction
GetPropertyAction.getProperty("sun.net.maxDatagramSockets"); .privilegedGetProperty("sun.net.maxDatagramSockets");
int defmax = DEFAULT_MAX_SOCKETS; int defmax = DEFAULT_MAX_SOCKETS;
try { try {
if (prop != null) { if (prop != null) {

View File

@ -40,7 +40,7 @@ import sun.security.action.GetPropertyAction;
*/ */
public final class SdpSupport { public final class SdpSupport {
private static final String os = GetPropertyAction.getProperty("os.name"); private static final String os = GetPropertyAction.privilegedGetProperty("os.name");
private static final boolean isSupported = (os.equals("SunOS") || (os.equals("Linux"))); private static final boolean isSupported = (os.equals("SunOS") || (os.equals("Linux")));
private static final JavaIOFileDescriptorAccess fdAccess = private static final JavaIOFileDescriptorAccess fdAccess =
SharedSecrets.getJavaIOFileDescriptorAccess(); SharedSecrets.getJavaIOFileDescriptorAccess();

View File

@ -157,7 +157,7 @@ public class SmtpClient extends TransferProtocolClient {
} }
try { try {
String s; String s;
mailhost = GetPropertyAction.getProperty("mail.host"); mailhost = GetPropertyAction.privilegedGetProperty("mail.host");
if (mailhost != null) { if (mailhost != null) {
openServer(mailhost); openServer(mailhost);
return; return;
@ -183,7 +183,7 @@ public class SmtpClient extends TransferProtocolClient {
setConnectTimeout(to); setConnectTimeout(to);
try { try {
String s; String s;
mailhost = GetPropertyAction.getProperty("mail.host"); mailhost = GetPropertyAction.privilegedGetProperty("mail.host");
if (mailhost != null) { if (mailhost != null) {
openServer(mailhost); openServer(mailhost);
return; return;

View File

@ -183,7 +183,7 @@ class MimeLauncher extends Thread {
} }
String execPathList; String execPathList;
execPathList = GetPropertyAction.getProperty("exec.path"); execPathList = GetPropertyAction.privilegedGetProperty("exec.path");
if (execPathList == null) { if (execPathList == null) {
// exec.path property not set // exec.path property not set
return false; return false;

View File

@ -145,7 +145,7 @@ public class HttpClient extends NetworkClient {
} }
static { static {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
String keepAlive = props.getProperty("http.keepAlive"); String keepAlive = props.getProperty("http.keepAlive");
String retryPost = props.getProperty("sun.net.http.retryPost"); String retryPost = props.getProperty("sun.net.http.retryPost");

View File

@ -278,7 +278,7 @@ public class FtpURLConnection extends URLConnection {
if (user == null) { if (user == null) {
user = "anonymous"; user = "anonymous";
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
String vers = props.getProperty("java.version"); String vers = props.getProperty("java.version");
password = props.getProperty("ftp.protocol.user", password = props.getProperty("ftp.protocol.user",
"Java" + vers + "@"); "Java" + vers + "@");

View File

@ -94,7 +94,7 @@ public class AuthenticationHeader {
} }
static { static {
authPref = GetPropertyAction.getProperty("http.auth.preference"); authPref = GetPropertyAction.privilegedGetProperty("http.auth.preference");
// http.auth.preference can be set to SPNEGO or Kerberos. // http.auth.preference can be set to SPNEGO or Kerberos.
// In fact they means "Negotiate with SPNEGO" and "Negotiate with // In fact they means "Negotiate with SPNEGO" and "Negotiate with

View File

@ -207,9 +207,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
}; };
static { static {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
maxRedirects = GetIntegerAction.getProperty("http.maxRedirects", maxRedirects = GetIntegerAction.privilegedGetProperty(
defaultmaxRedirects); "http.maxRedirects", defaultmaxRedirects);
version = props.getProperty("java.version"); version = props.getProperty("java.version");
String agent = props.getProperty("http.agent"); String agent = props.getProperty("http.agent");
if (agent == null) { if (agent == null) {
@ -225,14 +225,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
enableESBuffer = Boolean.parseBoolean( enableESBuffer = Boolean.parseBoolean(
props.getProperty("sun.net.http.errorstream.enableBuffering")); props.getProperty("sun.net.http.errorstream.enableBuffering"));
timeout4ESBuffer = GetIntegerAction timeout4ESBuffer = GetIntegerAction.privilegedGetProperty(
.getProperty("sun.net.http.errorstream.timeout", 300); "sun.net.http.errorstream.timeout", 300);
if (timeout4ESBuffer <= 0) { if (timeout4ESBuffer <= 0) {
timeout4ESBuffer = 300; // use the default timeout4ESBuffer = 300; // use the default
} }
bufSize4ES = GetIntegerAction bufSize4ES = GetIntegerAction.privilegedGetProperty(
.getProperty("sun.net.http.errorstream.bufferSize", 4096); "sun.net.http.errorstream.bufferSize", 4096);
if (bufSize4ES <= 0) { if (bufSize4ES <= 0) {
bufSize4ES = 4096; // use the default bufSize4ES = 4096; // use the default
} }

View File

@ -139,7 +139,7 @@ final class HttpsClient extends HttpClient
// //
String ciphers []; String ciphers [];
String cipherString = String cipherString =
GetPropertyAction.getProperty("https.cipherSuites"); GetPropertyAction.privilegedGetProperty("https.cipherSuites");
if (cipherString == null || "".equals(cipherString)) { if (cipherString == null || "".equals(cipherString)) {
ciphers = null; ciphers = null;
@ -163,7 +163,7 @@ final class HttpsClient extends HttpClient
// //
String protocols []; String protocols [];
String protocolString = String protocolString =
GetPropertyAction.getProperty("https.protocols"); GetPropertyAction.privilegedGetProperty("https.protocols");
if (protocolString == null || "".equals(protocolString)) { if (protocolString == null || "".equals(protocolString)) {
protocols = null; protocols = null;
@ -183,7 +183,8 @@ final class HttpsClient extends HttpClient
} }
private String getUserAgent() { private String getUserAgent() {
String userAgent = GetPropertyAction.getProperty("https.agent"); String userAgent =
GetPropertyAction.privilegedGetProperty("https.agent");
if (userAgent == null || userAgent.length() == 0) { if (userAgent == null || userAgent.length() == 0) {
userAgent = "JSSE"; userAgent = "JSSE";
} }

View File

@ -161,7 +161,7 @@ public class JavaRuntimeURLConnection extends URLConnection {
public Permission getPermission() throws IOException { public Permission getPermission() throws IOException {
Permission p = permission; Permission p = permission;
if (p == null) { if (p == null) {
String home = GetPropertyAction.getProperty("java.home"); String home = GetPropertyAction.privilegedGetProperty("java.home");
p = new FilePermission(home + File.separator + "-", "read"); p = new FilePermission(home + File.separator + "-", "read");
permission = p; permission = p;
} }

View File

@ -56,9 +56,9 @@ public class Handler extends URLStreamHandler {
URL ru; URL ru;
boolean localonly = Boolean.parseBoolean( boolean localonly = Boolean.parseBoolean(
GetPropertyAction.getProperty("newdoc.localonly")); GetPropertyAction.privilegedGetProperty("newdoc.localonly"));
String docurl = GetPropertyAction.getProperty("doc.url"); String docurl = GetPropertyAction.privilegedGetProperty("doc.url");
String file = u.getFile(); String file = u.getFile();
if (!localonly) { if (!localonly) {

View File

@ -1019,7 +1019,7 @@ public class FileChannelImpl
if (!propertyChecked) { if (!propertyChecked) {
synchronized (FileChannelImpl.class) { synchronized (FileChannelImpl.class) {
if (!propertyChecked) { if (!propertyChecked) {
String value = GetPropertyAction.getProperty( String value = GetPropertyAction.privilegedGetProperty(
"sun.nio.ch.disableSystemWideOverlappingFileLockCheck"); "sun.nio.ch.disableSystemWideOverlappingFileLockCheck");
isSharedFileLockTable = ((value == null) || value.equals("false")); isSharedFileLockTable = ((value == null) || value.equals("false"));
propertyChecked = true; propertyChecked = true;

View File

@ -374,8 +374,8 @@ public class Net {
} }
public static boolean isFastTcpLoopbackRequested() { public static boolean isFastTcpLoopbackRequested() {
String loopbackProp = String loopbackProp = GetPropertyAction
GetPropertyAction.getProperty("jdk.net.useFastTcpLoopback"); .privilegedGetProperty("jdk.net.useFastTcpLoopback");
boolean enable; boolean enable;
if ("".equals(loopbackProp)) { if ("".equals(loopbackProp)) {
enable = true; enable = true;
@ -633,8 +633,8 @@ public class Net {
static { static {
int availLevel = isExclusiveBindAvailable(); int availLevel = isExclusiveBindAvailable();
if (availLevel >= 0) { if (availLevel >= 0) {
String exclBindProp = String exclBindProp = GetPropertyAction
GetPropertyAction.getProperty("sun.net.useExclusiveBind"); .privilegedGetProperty("sun.net.useExclusiveBind");
if (exclBindProp != null) { if (exclBindProp != null) {
exclusiveBind = exclBindProp.isEmpty() ? exclusiveBind = exclBindProp.isEmpty() ?
true : Boolean.parseBoolean(exclBindProp); true : Boolean.parseBoolean(exclBindProp);

View File

@ -64,7 +64,8 @@ public class Util {
* for potential future-proofing. * for potential future-proofing.
*/ */
private static long getMaxCachedBufferSize() { private static long getMaxCachedBufferSize() {
String s = GetPropertyAction.getProperty("jdk.nio.maxCachedBufferSize"); String s = GetPropertyAction
.privilegedGetProperty("jdk.nio.maxCachedBufferSize");
if (s != null) { if (s != null) {
try { try {
long m = Long.parseLong(s); long m = Long.parseLong(s);
@ -465,7 +466,8 @@ public class Util {
if (bugLevel == null) { if (bugLevel == null) {
if (!jdk.internal.misc.VM.isBooted()) if (!jdk.internal.misc.VM.isBooted())
return false; return false;
String value = GetPropertyAction.getProperty("sun.nio.ch.bugLevel"); String value = GetPropertyAction
.privilegedGetProperty("sun.nio.ch.bugLevel");
bugLevel = (value != null) ? value : ""; bugLevel = (value != null) ? value : "";
} }
return bugLevel.equals(bl); return bugLevel.equals(bl);

View File

@ -164,7 +164,7 @@ public class StandardCharsets extends CharsetProvider {
return; return;
initialized = true; initialized = true;
String map = getProperty("sun.nio.cs.map"); String map = GetPropertyAction.privilegedGetProperty("sun.nio.cs.map");
if (map != null) { if (map != null) {
String[] maps = map.split(","); String[] maps = map.split(",");
for (int i = 0; i < maps.length; i++) { for (int i = 0; i < maps.length; i++) {
@ -199,9 +199,4 @@ public class StandardCharsets extends CharsetProvider {
} }
} }
private static String getProperty(String key) {
return GetPropertyAction.getProperty(key);
}
} }

View File

@ -38,7 +38,7 @@ class Util {
private Util() { } private Util() { }
private static final Charset jnuEncoding = Charset.forName( private static final Charset jnuEncoding = Charset.forName(
GetPropertyAction.getProperty("sun.jnu.encoding")); GetPropertyAction.privilegedGetProperty("sun.jnu.encoding"));
/** /**
* Returns {@code Charset} corresponding to the sun.jnu.encoding property * Returns {@code Charset} corresponding to the sun.jnu.encoding property

View File

@ -118,9 +118,14 @@ public class GetIntegerAction
* if no security manager is present. This is unsafe for inclusion in a * if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated. * public API but allowable here since this class is now encapsulated.
* *
* Note that this method performs a privileged action using caller-provided
* inputs. The caller of this method should take care to ensure that the
* inputs are not tainted and the returned property is not made accessible
* to untrusted code if it contains sensitive information.
*
* @param theProp the name of the system property. * @param theProp the name of the system property.
*/ */
public static Integer getProperty(String theProp) { public static Integer privilegedGetProperty(String theProp) {
if (System.getSecurityManager() == null) { if (System.getSecurityManager() == null) {
return Integer.getInteger(theProp); return Integer.getInteger(theProp);
} else { } else {
@ -134,10 +139,16 @@ public class GetIntegerAction
* if no security manager is present. This is unsafe for inclusion in a * if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated. * public API but allowable here since this class is now encapsulated.
* *
* Note that this method performs a privileged action using caller-provided
* inputs. The caller of this method should take care to ensure that the
* inputs are not tainted and the returned property is not made accessible
* to untrusted code if it contains sensitive information.
*
* @param theProp the name of the system property. * @param theProp the name of the system property.
* @param defaultVal the default value. * @param defaultVal the default value.
*/ */
public static Integer getProperty(String theProp, int defaultVal) { public static Integer privilegedGetProperty(String theProp,
int defaultVal) {
Integer value; Integer value;
if (System.getSecurityManager() == null) { if (System.getSecurityManager() == null) {
value = Integer.getInteger(theProp); value = Integer.getInteger(theProp);

View File

@ -93,9 +93,14 @@ public class GetPropertyAction implements PrivilegedAction<String> {
* if no security manager is present. This is unsafe for inclusion in a * if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated. * public API but allowable here since this class is now encapsulated.
* *
* Note that this method performs a privileged action using caller-provided
* inputs. The caller of this method should take care to ensure that the
* inputs are not tainted and the returned property is not made accessible
* to untrusted code if it contains sensitive information.
*
* @param theProp the name of the system property. * @param theProp the name of the system property.
*/ */
public static String getProperty(String theProp) { public static String privilegedGetProperty(String theProp) {
if (System.getSecurityManager() == null) { if (System.getSecurityManager() == null) {
return System.getProperty(theProp); return System.getProperty(theProp);
} else { } else {
@ -109,10 +114,16 @@ public class GetPropertyAction implements PrivilegedAction<String> {
* if no security manager is present. This is unsafe for inclusion in a * if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated. * public API but allowable here since this class is now encapsulated.
* *
* Note that this method performs a privileged action using caller-provided
* inputs. The caller of this method should take care to ensure that the
* inputs are not tainted and the returned property is not made accessible
* to untrusted code if it contains sensitive information.
*
* @param theProp the name of the system property. * @param theProp the name of the system property.
* @param defaultVal the default value. * @param defaultVal the default value.
*/ */
public static String getProperty(String theProp, String defaultVal) { public static String privilegedGetProperty(String theProp,
String defaultVal) {
if (System.getSecurityManager() == null) { if (System.getSecurityManager() == null) {
return System.getProperty(theProp, defaultVal); return System.getProperty(theProp, defaultVal);
} else { } else {
@ -126,8 +137,13 @@ public class GetPropertyAction implements PrivilegedAction<String> {
* having to go through doPrivileged if no security manager is present. * having to go through doPrivileged if no security manager is present.
* This is unsafe for inclusion in a public API but allowable here since * This is unsafe for inclusion in a public API but allowable here since
* this class is now encapsulated. * this class is now encapsulated.
*
* Note that this method performs a privileged action, and callers of
* this method should take care to ensure that the returned properties
* are not made accessible to untrusted code since it may contain
* sensitive information.
*/ */
public static Properties getProperties() { public static Properties privilegedGetProperties() {
if (System.getSecurityManager() == null) { if (System.getSecurityManager() == null) {
return System.getProperties(); return System.getProperties();
} else { } else {

View File

@ -70,7 +70,7 @@ public class DSAKeyFactory extends KeyFactorySpi {
* By default this is false. * By default this is false.
* This incompatibility was introduced by 4532506. * This incompatibility was introduced by 4532506.
*/ */
String prop = GetPropertyAction.getProperty(SERIAL_PROP); String prop = GetPropertyAction.privilegedGetProperty(SERIAL_PROP);
SERIAL_INTEROP = "true".equalsIgnoreCase(prop); SERIAL_INTEROP = "true".equalsIgnoreCase(prop);
} }

View File

@ -43,7 +43,6 @@ import javax.security.auth.x500.X500Principal;
import static sun.security.provider.certpath.OCSP.*; import static sun.security.provider.certpath.OCSP.*;
import static sun.security.provider.certpath.PKIX.*; import static sun.security.provider.certpath.PKIX.*;
import sun.security.action.GetPropertyAction;
import sun.security.x509.*; import sun.security.x509.*;
import static sun.security.x509.PKIXExtensions.*; import static sun.security.x509.PKIXExtensions.*;
import sun.security.util.Debug; import sun.security.util.Debug;

View File

@ -84,7 +84,7 @@ public final class RSAKeyFactory extends KeyFactorySpi {
public static final int MAX_RESTRICTED_EXPLEN = 64; public static final int MAX_RESTRICTED_EXPLEN = 64;
private static final boolean restrictExpLen = private static final boolean restrictExpLen =
"true".equalsIgnoreCase(GetPropertyAction.getProperty( "true".equalsIgnoreCase(GetPropertyAction.privilegedGetProperty(
"sun.security.rsa.restrictRSAExponent", "true")); "sun.security.rsa.restrictRSAExponent", "true"));
// instance used for static translateKey(); // instance used for static translateKey();

View File

@ -50,7 +50,7 @@ public interface ClientKeyExchangeService {
providers = new HashMap<>(); providers = new HashMap<>();
static { static {
String path = GetPropertyAction.getProperty("java.home"); String path = GetPropertyAction.privilegedGetProperty("java.home");
ServiceLoader<ClientKeyExchangeService> sc = ServiceLoader<ClientKeyExchangeService> sc =
AccessController.doPrivileged( AccessController.doPrivileged(
(PrivilegedAction<ServiceLoader<ClientKeyExchangeService>>) (PrivilegedAction<ServiceLoader<ClientKeyExchangeService>>)

View File

@ -45,7 +45,7 @@ public class Debug {
private static String args; private static String args;
static { static {
args = GetPropertyAction.getProperty("javax.net.debug", ""); args = GetPropertyAction.privilegedGetProperty("javax.net.debug", "");
args = args.toLowerCase(Locale.ENGLISH); args = args.toLowerCase(Locale.ENGLISH);
if (args.equals("help")) { if (args.equals("help")) {
Help(); Help();
@ -178,11 +178,11 @@ public class Debug {
/** /**
* Return the value of the boolean System property propName. * Return the value of the boolean System property propName.
* *
* Note use of doPrivileged(). Do make accessible to applications. * Note use of privileged action. Do NOT make accessible to applications.
*/ */
static boolean getBooleanProperty(String propName, boolean defaultValue) { static boolean getBooleanProperty(String propName, boolean defaultValue) {
// if set, require value of either true or false // if set, require value of either true or false
String b = GetPropertyAction.getProperty(propName); String b = GetPropertyAction.privilegedGetProperty(propName);
if (b == null) { if (b == null) {
return defaultValue; return defaultValue;
} else if (b.equalsIgnoreCase("false")) { } else if (b.equalsIgnoreCase("false")) {

View File

@ -656,7 +656,8 @@ public abstract class SSLContextImpl extends SSLContextSpi {
// the provider service. Instead, please handle the initialization // the provider service. Instead, please handle the initialization
// exception in the caller's constructor. // exception in the caller's constructor.
static { static {
String property = GetPropertyAction.getProperty(PROPERTY_NAME); String property = GetPropertyAction
.privilegedGetProperty(PROPERTY_NAME);
if (property != null && property.length() != 0) { if (property != null && property.length() != 0) {
// remove double quote marks from beginning/end of the property // remove double quote marks from beginning/end of the property
if (property.length() > 1 && property.charAt(0) == '"' && if (property.length() > 1 && property.charAt(0) == '"' &&

View File

@ -119,8 +119,8 @@ final class ServerHandshaker extends Handshaker {
private long statusRespTimeout; private long statusRespTimeout;
static { static {
String property = String property = GetPropertyAction
GetPropertyAction.getProperty("jdk.tls.ephemeralDHKeySize"); .privilegedGetProperty("jdk.tls.ephemeralDHKeySize");
if (property == null || property.length() == 0) { if (property == null || property.length() == 0) {
useLegacyEphemeralDHKeys = false; useLegacyEphemeralDHKeys = false;
useSmartEphemeralDHKeys = false; useSmartEphemeralDHKeys = false;

View File

@ -73,8 +73,8 @@ final class StatusResponseManager {
DEFAULT_CACHE_LIFETIME)); DEFAULT_CACHE_LIFETIME));
cacheLifetime = life > 0 ? life : 0; cacheLifetime = life > 0 ? life : 0;
String uriStr = String uriStr = GetPropertyAction
GetPropertyAction.getProperty("jdk.tls.stapling.responderURI"); .privilegedGetProperty("jdk.tls.stapling.responderURI");
URI tmpURI; URI tmpURI;
try { try {
tmpURI = ((uriStr != null && !uriStr.isEmpty()) ? tmpURI = ((uriStr != null && !uriStr.isEmpty()) ?

View File

@ -43,10 +43,10 @@ public class Debug {
private static String args; private static String args;
static { static {
args = GetPropertyAction.getProperty("java.security.debug"); args = GetPropertyAction.privilegedGetProperty("java.security.debug");
String args2 = String args2 = GetPropertyAction
GetPropertyAction.getProperty("java.security.auth.debug"); .privilegedGetProperty("java.security.auth.debug");
if (args == null) { if (args == null) {
args = args2; args = args2;

View File

@ -144,7 +144,7 @@ public class LocalGregorianCalendar extends BaseCalendar {
// Append an era to the predefined eras if it's given by the property. // Append an era to the predefined eras if it's given by the property.
String prop = GetPropertyAction String prop = GetPropertyAction
.getProperty("jdk.calendar.japanese.supplemental.era"); .privilegedGetProperty("jdk.calendar.japanese.supplemental.era");
if (prop != null) { if (prop != null) {
Era era = parseEraEntry(prop); Era era = parseEraEntry(prop);
if (era != null) { if (era != null) {

View File

@ -246,7 +246,7 @@ public final class ZoneInfoFile {
static { static {
String oldmapping = GetPropertyAction String oldmapping = GetPropertyAction
.getProperty("sun.timezone.ids.oldmapping", "false") .privilegedGetProperty("sun.timezone.ids.oldmapping", "false")
.toLowerCase(Locale.ROOT); .toLowerCase(Locale.ROOT);
USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true")); USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
AccessController.doPrivileged(new PrivilegedAction<Void>() { AccessController.doPrivileged(new PrivilegedAction<Void>() {

View File

@ -116,7 +116,7 @@ public abstract class LocaleProviderAdapter {
adapterCache = new ConcurrentHashMap<>(); adapterCache = new ConcurrentHashMap<>();
static { static {
String order = GetPropertyAction.getProperty("java.locale.providers"); String order = GetPropertyAction.privilegedGetProperty("java.locale.providers");
List<Type> typeList = new ArrayList<>(); List<Type> typeList = new ArrayList<>();
// Check user specified adapter preference // Check user specified adapter preference

View File

@ -42,7 +42,7 @@ class SolarisFileSystem extends UnixFileSystem {
super(provider, dir); super(provider, dir);
// check os.version // check os.version
String osversion = GetPropertyAction.getProperty("os.version"); String osversion = GetPropertyAction.privilegedGetProperty("os.version");
String[] vers = Util.split(osversion, '.'); String[] vers = Util.split(osversion, '.');
assert vers.length >= 2; assert vers.length >= 2;
int majorVersion = Integer.parseInt(vers[0]); int majorVersion = Integer.parseInt(vers[0]);

View File

@ -85,7 +85,7 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
@Override @Override
FileTypeDetector getFileTypeDetector() { FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get( Path userMimeTypes = Paths.get(
GetPropertyAction.getProperty("user.home"), ".mime.types"); GetPropertyAction.privilegedGetProperty("user.home"), ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types"); Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GioFileTypeDetector(), return chain(new GioFileTypeDetector(),

View File

@ -36,7 +36,7 @@ class UnixFileSystem extends FileSystem {
private final String javaHome; private final String javaHome;
public UnixFileSystem() { public UnixFileSystem() {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
slash = props.getProperty("file.separator").charAt(0); slash = props.getProperty("file.separator").charAt(0);
colon = props.getProperty("path.separator").charAt(0); colon = props.getProperty("path.separator").charAt(0);
javaHome = props.getProperty("java.home"); javaHome = props.getProperty("java.home");

View File

@ -125,7 +125,7 @@ final class ProcessImpl extends Process {
} }
String helperPath() { String helperPath() {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
return helperPath(props.getProperty("java.home"), return helperPath(props.getProperty("java.home"),
props.getProperty("os.arch")); props.getProperty("os.arch"));
} }
@ -159,7 +159,7 @@ final class ProcessImpl extends Process {
} }
static Platform get() { static Platform get() {
String osName = GetPropertyAction.getProperty("os.name"); String osName = GetPropertyAction.privilegedGetProperty("os.name");
if (osName.equals("Linux")) { return LINUX; } if (osName.equals("Linux")) { return LINUX; }
if (osName.contains("OS X")) { return BSD; } if (osName.contains("OS X")) { return BSD; }

View File

@ -40,7 +40,7 @@ class DefaultDatagramSocketImplFactory {
static { static {
String prefix = null; String prefix = null;
try { try {
prefix = GetPropertyAction.getProperty("impl.prefix", null); prefix = GetPropertyAction.privilegedGetProperty("impl.prefix");
if (prefix != null) if (prefix != null)
prefixImplClass = Class.forName("java.net."+prefix+"DatagramSocketImpl"); prefixImplClass = Class.forName("java.net."+prefix+"DatagramSocketImpl");
} catch (Exception e) { } catch (Exception e) {

View File

@ -28,9 +28,6 @@ package sun.net;
import java.net.InetAddress; import java.net.InetAddress;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.IOException; import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.GetPropertyAction;
/** /**
* Defines static methods to be invoked prior to binding or connecting TCP sockets. * Defines static methods to be invoked prior to binding or connecting TCP sockets.

View File

@ -55,8 +55,9 @@ public class SdpProvider extends NetHooks.Provider {
private PrintStream log; private PrintStream log;
public SdpProvider() { public SdpProvider() {
Properties props = GetPropertyAction.privilegedGetProperties();
// if this property is not defined then there is nothing to do. // if this property is not defined then there is nothing to do.
String file = GetPropertyAction.getProperty("com.sun.sdp.conf"); String file = props.getProperty("com.sun.sdp.conf");
if (file == null) { if (file == null) {
this.enabled = false; this.enabled = false;
this.rules = null; this.rules = null;
@ -65,17 +66,15 @@ public class SdpProvider extends NetHooks.Provider {
// load configuration file // load configuration file
List<Rule> list = null; List<Rule> list = null;
if (file != null) { try {
try { list = loadRulesFromFile(file);
list = loadRulesFromFile(file); } catch (IOException e) {
} catch (IOException e) { fail("Error reading %s: %s", file, e.getMessage());
fail("Error reading %s: %s", file, e.getMessage());
}
} }
// check if debugging is enabled // check if debugging is enabled
PrintStream out = null; PrintStream out = null;
String logfile = GetPropertyAction.getProperty("com.sun.sdp.debug"); String logfile = props.getProperty("com.sun.sdp.debug");
if (logfile != null) { if (logfile != null) {
out = System.out; out = System.out;
if (logfile.length() > 0) { if (logfile.length() > 0) {

View File

@ -76,7 +76,7 @@ public class NTLMAuthentication extends AuthenticationInfo {
private String hostname; private String hostname;
/* Domain to use if not specified by user */ /* Domain to use if not specified by user */
private static String defaultDomain = private static String defaultDomain =
GetPropertyAction.getProperty("http.auth.ntlm.domain", ""); GetPropertyAction.privilegedGetProperty("http.auth.ntlm.domain", "");
public static boolean supportsTransparentAuth () { public static boolean supportsTransparentAuth () {
return false; return false;
@ -141,7 +141,7 @@ public class NTLMAuthentication extends AuthenticationInfo {
password = pw.getPassword(); password = pw.getPassword();
init0(); init0();
try { try {
String version = GetPropertyAction.getProperty("ntlm.version"); String version = GetPropertyAction.privilegedGetProperty("ntlm.version");
client = new Client(version, hostname, username, ntdomain, password); client = new Client(version, hostname, username, ntdomain, password);
} catch (NTLMException ne) { } catch (NTLMException ne) {
try { try {

View File

@ -59,7 +59,7 @@ public class DefaultAsynchronousChannelProvider {
* Returns the default AsynchronousChannelProvider. * Returns the default AsynchronousChannelProvider.
*/ */
public static AsynchronousChannelProvider create() { public static AsynchronousChannelProvider create() {
String osname = GetPropertyAction.getProperty("os.name"); String osname = GetPropertyAction.privilegedGetProperty("os.name");
if (osname.equals("SunOS")) if (osname.equals("SunOS"))
return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider"); return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
if (osname.equals("Linux")) if (osname.equals("Linux"))

View File

@ -46,8 +46,8 @@ class UnixAsynchronousSocketChannelImpl
private static final boolean disableSynchronousRead; private static final boolean disableSynchronousRead;
static { static {
String propValue = GetPropertyAction String propValue = GetPropertyAction.privilegedGetProperty(
.getProperty("sun.nio.ch.disableSynchronousRead", "false"); "sun.nio.ch.disableSynchronousRead", "false");
disableSynchronousRead = (propValue.length() == 0) ? disableSynchronousRead = (propValue.length() == 0) ?
true : Boolean.valueOf(propValue); true : Boolean.valueOf(propValue);
} }

View File

@ -54,7 +54,7 @@ public class DefaultFileSystemProvider {
* Returns the default FileSystemProvider. * Returns the default FileSystemProvider.
*/ */
public static FileSystemProvider create() { public static FileSystemProvider create() {
String osname = GetPropertyAction.getProperty("os.name"); String osname = GetPropertyAction.privilegedGetProperty("os.name");
if (osname.equals("SunOS")) if (osname.equals("SunOS"))
return createProvider("sun.nio.fs.SolarisFileSystemProvider"); return createProvider("sun.nio.fs.SolarisFileSystemProvider");
if (osname.equals("Linux")) if (osname.equals("Linux"))

View File

@ -57,7 +57,7 @@ abstract class UnixFileSystem
// process working directory then paths must be resolved against the // process working directory then paths must be resolved against the
// default directory. // default directory.
String propValue = GetPropertyAction String propValue = GetPropertyAction
.getProperty("sun.nio.fs.chdirAllowed", "false"); .privilegedGetProperty("sun.nio.fs.chdirAllowed", "false");
boolean chdirAllowed = (propValue.length() == 0) ? boolean chdirAllowed = (propValue.length() == 0) ?
true : Boolean.valueOf(propValue); true : Boolean.valueOf(propValue);
if (chdirAllowed) { if (chdirAllowed) {

View File

@ -42,7 +42,7 @@ class WinNTFileSystem extends FileSystem {
private final char semicolon; private final char semicolon;
public WinNTFileSystem() { public WinNTFileSystem() {
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
slash = props.getProperty("file.separator").charAt(0); slash = props.getProperty("file.separator").charAt(0);
semicolon = props.getProperty("path.separator").charAt(0); semicolon = props.getProperty("path.separator").charAt(0);
altSlash = (this.slash == '\\') ? '/' : '\\'; altSlash = (this.slash == '\\') ? '/' : '\\';

View File

@ -56,7 +56,7 @@ class DefaultDatagramSocketImplFactory
static { static {
Class<?> prefixImplClassLocal = null; Class<?> prefixImplClassLocal = null;
Properties props = GetPropertyAction.getProperties(); Properties props = GetPropertyAction.privilegedGetProperties();
preferIPv4Stack = Boolean.parseBoolean( preferIPv4Stack = Boolean.parseBoolean(
props.getProperty("java.net.preferIPv4Stack")); props.getProperty("java.net.preferIPv4Stack"));

View File

@ -53,8 +53,8 @@ public class NTLMAuthentication extends AuthenticationInfo {
private static String defaultDomain; /* Domain to use if not specified by user */ private static String defaultDomain; /* Domain to use if not specified by user */
static { static {
defaultDomain = GetPropertyAction.getProperty("http.auth.ntlm.domain", defaultDomain = GetPropertyAction
"domain"); .privilegedGetProperty("http.auth.ntlm.domain", "domain");
}; };
private void init0() { private void init0() {

View File

@ -120,7 +120,7 @@ class FileDispatcherImpl extends FileDispatcher {
static boolean isFastFileTransferRequested() { static boolean isFastFileTransferRequested() {
String fileTransferProp = GetPropertyAction String fileTransferProp = GetPropertyAction
.getProperty("jdk.nio.enableFastFileTransfer"); .privilegedGetProperty("jdk.nio.enableFastFileTransfer");
boolean enable; boolean enable;
if ("".equals(fileTransferProp)) { if ("".equals(fileTransferProp)) {
enable = true; enable = true;

View File

@ -114,8 +114,8 @@ class WindowsFileAttributes
// indicates if accurate metadata is required (interesting on NTFS only) // indicates if accurate metadata is required (interesting on NTFS only)
private static final boolean ensureAccurateMetadata; private static final boolean ensureAccurateMetadata;
static { static {
String propValue = GetPropertyAction String propValue = GetPropertyAction.privilegedGetProperty(
.getProperty("sun.nio.fs.ensureAccurateMetadata", "false"); "sun.nio.fs.ensureAccurateMetadata", "false");
ensureAccurateMetadata = (propValue.length() == 0) ? ensureAccurateMetadata = (propValue.length() == 0) ?
true : Boolean.valueOf(propValue); true : Boolean.valueOf(propValue);
} }