Hi,
This is an update to
http://developer.classpath.org/pipermail/classpath-patches/2006-June/002635.html.
Replaces SystemProperties.getProperty with GetPropertyAction in an
AccessController.doPrivileged block. Since this idea has been approved
already, I will commit this tomorrow unless there are any objections in
the mean time.
Thanks,
Vivek
Changelog:
2006-07-10 Vivek Lakshmanan <[EMAIL PROTECTED]>
PR 27649:
* gnu/classpath/debug/Simple1LineFormatter.java: Use
AccessController.doPrivileged instead of SystemProperties.getProperty.
* gnu/classpath/debug/SystemLogger.java: Likewise.
* gnu/java/security/PolicyFile.java: Likewise and cut unnecessary
repeated getProperty calls for "file.seperator".
(refresh): Since already in privileged block, call System.getProperty
instead of SystemProperties.getProperty.
* gnu/java/security/key/dss/DSSKey.java
(toString): Use AccessController.doPrivileged instead of
SystemProperties.getProperty.
* gnu/java/security/key/dss/DSSPrivateKey.java
(toString): Likewise.
* gnu/java/security/key/dss/DSSPublicKey.java
(toString): Likewise.
* gnu/java/security/key/rsa/GnuRSAKey.java
(toString): Likewise.
* gnu/java/security/key/rsa/GnuRSAPrivateKey.java
(toString): Likewise.
* gnu/java/security/key/rsa/GnuRSAPublicKey.java
(toString): Likewise.
* gnu/javax/crypto/sasl/plain/PasswordFile.java: Likewise.
* gnu/javax/crypto/key/dh/GnuDHKey.java
(toString): Likewise.
* gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
(toString): Likewise.
* gnu/javax/crypto/key/dh/GnuDHPublicKey.java
(toString): Likewise.
Index: gnu/classpath/debug/Simple1LineFormatter.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/classpath/debug/Simple1LineFormatter.java,v
retrieving revision 1.2
diff -u -r1.2 Simple1LineFormatter.java
--- gnu/classpath/debug/Simple1LineFormatter.java 7 May 2006 07:55:33 -0000 1.2
+++ gnu/classpath/debug/Simple1LineFormatter.java 11 Jul 2006 01:37:53 -0000
@@ -38,10 +38,11 @@
package gnu.classpath.debug;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.security.AccessController;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@@ -94,7 +95,7 @@
private static final String THREAD_PATTERN = " #########0;-#########0";
private static final String SPACES_32 = " ";
private static final String SPACES_6 = " ";
- private static final String LS = SystemProperties.getProperty("line.separator");
+ private static final String LS = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
private DateFormat dateFormat;
private NumberFormat threadFormat;
Index: gnu/classpath/debug/SystemLogger.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/classpath/debug/SystemLogger.java,v
retrieving revision 1.1
diff -u -r1.1 SystemLogger.java
--- gnu/classpath/debug/SystemLogger.java 10 Jul 2005 19:08:02 -0000 1.1
+++ gnu/classpath/debug/SystemLogger.java 11 Jul 2006 01:37:53 -0000
@@ -38,7 +38,9 @@
package gnu.classpath.debug;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
+
+import java.security.AccessController;
import java.util.StringTokenizer;
import java.util.logging.Logger;
@@ -49,8 +51,7 @@
static
{
SYSTEM.setFilter (PreciseFilter.GLOBAL);
-
- String defaults = SystemProperties.getProperty ("gnu.classpath.debug.components");
+ String defaults = (String) AccessController.doPrivileged(new GetPropertyAction("gnu.classpath.debug.components"));
if (defaults != null)
{
Index: gnu/java/security/PolicyFile.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/PolicyFile.java,v
retrieving revision 1.8
diff -u -r1.8 PolicyFile.java
--- gnu/java/security/PolicyFile.java 4 Jun 2006 05:29:43 -0000 1.8
+++ gnu/java/security/PolicyFile.java 11 Jul 2006 01:37:54 -0000
@@ -37,9 +37,9 @@
package gnu.java.security;
-import gnu.classpath.SystemProperties;
import gnu.classpath.debug.Component;
import gnu.classpath.debug.SystemLogger;
+import gnu.java.security.action.GetPropertyAction;
import java.io.File;
import java.io.IOException;
@@ -149,15 +149,16 @@
// -------------------------------------------------------------------------
protected static final Logger logger = SystemLogger.SYSTEM;
-
+ // Added to cut redundant AccessController.doPrivileged calls
+ private static GetPropertyAction prop = new GetPropertyAction("file.seperator");
+ private static final String fs = (String) AccessController.doPrivileged(prop);
+
private static final String DEFAULT_POLICY =
- SystemProperties.getProperty("java.home")
- + SystemProperties.getProperty("file.separator") + "lib"
- + SystemProperties.getProperty("file.separator") + "security"
- + SystemProperties.getProperty("file.separator") + "java.policy";
+ (String) AccessController.doPrivileged(prop.setParameters("java.home"))
+ + fs + "lib" + fs + "security" + fs + "java.policy";
private static final String DEFAULT_USER_POLICY =
- SystemProperties.getProperty ("user.home") +
- SystemProperties.getProperty ("file.separator") + ".java.policy";
+ (String) AccessController.doPrivileged(prop.setParameters("user.home")) +
+ fs + ".java.policy";
private final Map cs2pc;
@@ -216,7 +217,7 @@
String allow = Security.getProperty ("policy.allowSystemProperty");
if (allow == null || Boolean.getBoolean (allow))
{
- String s = SystemProperties.getProperty ("java.security.policy");
+ String s = System.getProperty ("java.security.policy");
logger.log (Component.POLICY, "java.security.policy={0}", s);
if (s != null)
{
Index: gnu/java/security/key/dss/DSSKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/dss/DSSKey.java,v
retrieving revision 1.8
diff -u -r1.8 DSSKey.java
--- gnu/java/security/key/dss/DSSKey.java 20 Jun 2006 11:24:43 -0000 1.8
+++ gnu/java/security/key/dss/DSSKey.java 11 Jul 2006 01:37:54 -0000
@@ -38,11 +38,12 @@
package gnu.java.security.key.dss;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.util.FormatUtil;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.Key;
import java.security.interfaces.DSAKey;
import java.security.interfaces.DSAParams;
@@ -167,7 +168,8 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction(
+ "line.separator"));
str = new StringBuilder(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls)
.append("p=0x").append(p.toString(16)).append(",").append(ls)
Index: gnu/java/security/key/dss/DSSPrivateKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/dss/DSSPrivateKey.java,v
retrieving revision 1.7
diff -u -r1.7 DSSPrivateKey.java
--- gnu/java/security/key/dss/DSSPrivateKey.java 25 Jun 2006 22:45:27 -0000 1.7
+++ gnu/java/security/key/dss/DSSPrivateKey.java 11 Jul 2006 01:37:54 -0000
@@ -39,11 +39,12 @@
package gnu.java.security.key.dss;
import gnu.java.security.Configuration;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PrivateKey;
import java.security.interfaces.DSAPrivateKey;
@@ -188,7 +189,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("x=0x").append(Configuration.DEBUG ? x.toString(16)
Index: gnu/java/security/key/dss/DSSPublicKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/dss/DSSPublicKey.java,v
retrieving revision 1.5
diff -u -r1.5 DSSPublicKey.java
--- gnu/java/security/key/dss/DSSPublicKey.java 20 Jun 2006 11:24:43 -0000 1.5
+++ gnu/java/security/key/dss/DSSPublicKey.java 11 Jul 2006 01:37:55 -0000
@@ -38,11 +38,12 @@
package gnu.java.security.key.dss;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PublicKey;
import java.security.interfaces.DSAPublicKey;
@@ -187,7 +188,8 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction(
+ "line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("y=0x").append(y.toString(16)).append(ls)
Index: gnu/java/security/key/rsa/GnuRSAKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/rsa/GnuRSAKey.java,v
retrieving revision 1.6
diff -u -r1.6 GnuRSAKey.java
--- gnu/java/security/key/rsa/GnuRSAKey.java 20 Jun 2006 11:24:41 -0000 1.6
+++ gnu/java/security/key/rsa/GnuRSAKey.java 11 Jul 2006 01:37:55 -0000
@@ -38,11 +38,12 @@
package gnu.java.security.key.rsa;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.util.FormatUtil;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.Key;
import java.security.interfaces.RSAKey;
@@ -160,7 +161,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
str = new StringBuilder(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls)
.append("n=0x").append(n.toString(16)).append(",").append(ls)
Index: gnu/java/security/key/rsa/GnuRSAPrivateKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/rsa/GnuRSAPrivateKey.java,v
retrieving revision 1.8
diff -u -r1.8 GnuRSAPrivateKey.java
--- gnu/java/security/key/rsa/GnuRSAPrivateKey.java 25 Jun 2006 22:45:27 -0000 1.8
+++ gnu/java/security/key/rsa/GnuRSAPrivateKey.java 11 Jul 2006 01:37:55 -0000
@@ -39,11 +39,12 @@
package gnu.java.security.key.rsa;
import gnu.java.security.Configuration;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPrivateKey;
@@ -286,7 +287,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("d=0x").append(Configuration.DEBUG ? d.toString(16)
Index: gnu/java/security/key/rsa/GnuRSAPublicKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/rsa/GnuRSAPublicKey.java,v
retrieving revision 1.5
diff -u -r1.5 GnuRSAPublicKey.java
--- gnu/java/security/key/rsa/GnuRSAPublicKey.java 20 Jun 2006 11:24:41 -0000 1.5
+++ gnu/java/security/key/rsa/GnuRSAPublicKey.java 11 Jul 2006 01:37:55 -0000
@@ -38,11 +38,12 @@
package gnu.java.security.key.rsa;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
@@ -175,7 +176,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append(")")
Index: gnu/javax/crypto/key/dh/GnuDHKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/javax/crypto/key/dh/GnuDHKey.java,v
retrieving revision 1.6
diff -u -r1.6 GnuDHKey.java
--- gnu/javax/crypto/key/dh/GnuDHKey.java 1 Jul 2006 10:00:26 -0000 1.6
+++ gnu/javax/crypto/key/dh/GnuDHKey.java 11 Jul 2006 01:37:56 -0000
@@ -38,11 +38,12 @@
package gnu.javax.crypto.key.dh;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.util.FormatUtil;
import java.math.BigInteger;
+import java.security.AccessController;
import java.security.Key;
import javax.crypto.interfaces.DHKey;
@@ -154,7 +155,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
StringBuilder sb = new StringBuilder(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls);
if (q == null)
Index: gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java,v
retrieving revision 1.5
diff -u -r1.5 GnuDHPrivateKey.java
--- gnu/javax/crypto/key/dh/GnuDHPrivateKey.java 1 Jul 2006 10:00:26 -0000 1.5
+++ gnu/javax/crypto/key/dh/GnuDHPrivateKey.java 11 Jul 2006 01:37:56 -0000
@@ -38,12 +38,13 @@
package gnu.javax.crypto.key.dh;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Configuration;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import javax.crypto.interfaces.DHPrivateKey;
@@ -185,7 +186,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("x=0x").append(Configuration.DEBUG ? x.toString(16)
Index: gnu/javax/crypto/key/dh/GnuDHPublicKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/javax/crypto/key/dh/GnuDHPublicKey.java,v
retrieving revision 1.4
diff -u -r1.4 GnuDHPublicKey.java
--- gnu/javax/crypto/key/dh/GnuDHPublicKey.java 1 Jul 2006 10:00:26 -0000 1.4
+++ gnu/javax/crypto/key/dh/GnuDHPublicKey.java 11 Jul 2006 01:37:56 -0000
@@ -38,11 +38,12 @@
package gnu.javax.crypto.key.dh;
-import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
+import gnu.java.security.action.GetPropertyAction;
import gnu.java.security.key.IKeyPairCodec;
import java.math.BigInteger;
+import java.security.AccessController;
import javax.crypto.interfaces.DHPublicKey;
@@ -182,7 +183,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("y=0x").append(y.toString(16)).append(ls)
Index: gnu/javax/crypto/sasl/plain/PasswordFile.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/javax/crypto/sasl/plain/PasswordFile.java,v
retrieving revision 1.2
diff -u -r1.2 PasswordFile.java
--- gnu/javax/crypto/sasl/plain/PasswordFile.java 3 Jul 2006 12:15:39 -0000 1.2
+++ gnu/javax/crypto/sasl/plain/PasswordFile.java 11 Jul 2006 01:37:56 -0000
@@ -38,7 +38,7 @@
package gnu.javax.crypto.sasl.plain;
-import gnu.classpath.SystemProperties;
+import gnu.java.security.action.GetPropertyAction;
import gnu.javax.crypto.sasl.NoSuchUserException;
import gnu.javax.crypto.sasl.UserAlreadyExistsException;
@@ -50,6 +50,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import java.security.AccessController;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.NoSuchElementException;
@@ -63,8 +64,9 @@
private static String DEFAULT_FILE;
static
{
- DEFAULT_FILE = SystemProperties.getProperty(PlainRegistry.PASSWORD_FILE,
- PlainRegistry.DEFAULT_PASSWORD_FILE);
+ DEFAULT_FILE = (String) AccessController.doPrivileged(new GetPropertyAction(
+ PlainRegistry.PASSWORD_FILE,
+ PlainRegistry.DEFAULT_PASSWORD_FILE));
}
private Hashtable entries;
private File passwdFile;