For PR27649: making it easy to separate crypto specific classes into an
independent jar, by removing direct calls to
gnu.classpath.SystemProperties. These calls have been replaced by
AccessController.doPrivileged
calls using GetPropertyAction (for improving readability).
Thanks,
Vivek
Changelog:
2006-06-07 Vivek Lakshmanan <[EMAIL PROTECTED]>
* 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.
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 7 Jun 2006 22:35:19 -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 7 Jun 2006 22:35:19 -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 7 Jun 2006 22:35:21 -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.7
diff -u -r1.7 DSSKey.java
--- gnu/java/security/key/dss/DSSKey.java 29 Apr 2006 06:53:06 -0000 1.7
+++ gnu/java/security/key/dss/DSSKey.java 7 Jun 2006 22:35:21 -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;
@@ -183,7 +184,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged( new GetPropertyAction("line.separator"));
str = new StringBuilder().append(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.4
diff -u -r1.4 DSSPrivateKey.java
--- gnu/java/security/key/dss/DSSPrivateKey.java 26 Mar 2006 22:57:46 -0000 1.4
+++ gnu/java/security/key/dss/DSSPrivateKey.java 7 Jun 2006 22:35:21 -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.PrivateKey;
import java.security.interfaces.DSAPrivateKey;
@@ -207,7 +208,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(DEBUG ? x.toString(16) : "**...*").append(ls)
Index: gnu/java/security/key/dss/DSSPublicKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/dss/DSSPublicKey.java,v
retrieving revision 1.4
diff -u -r1.4 DSSPublicKey.java
--- gnu/java/security/key/dss/DSSPublicKey.java 26 Mar 2006 22:57:46 -0000 1.4
+++ gnu/java/security/key/dss/DSSPublicKey.java 7 Jun 2006 22:35:21 -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;
@@ -205,7 +206,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/java/security/key/rsa/GnuRSAKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/rsa/GnuRSAKey.java,v
retrieving revision 1.5
diff -u -r1.5 GnuRSAKey.java
--- gnu/java/security/key/rsa/GnuRSAKey.java 29 Apr 2006 06:53:06 -0000 1.5
+++ gnu/java/security/key/rsa/GnuRSAKey.java 7 Jun 2006 22:35:21 -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;
@@ -180,7 +181,7 @@
{
if (str == null)
{
- String ls = SystemProperties.getProperty("line.separator");
+ String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
str = new StringBuilder().append(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.5
diff -u -r1.5 GnuRSAPrivateKey.java
--- gnu/java/security/key/rsa/GnuRSAPrivateKey.java 29 Apr 2006 06:53:06 -0000 1.5
+++ gnu/java/security/key/rsa/GnuRSAPrivateKey.java 7 Jun 2006 22:35:22 -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.PrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPrivateKey;
@@ -304,7 +305,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(DEBUG ? d.toString(16) : "**...*").append(ls)
Index: gnu/java/security/key/rsa/GnuRSAPublicKey.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/key/rsa/GnuRSAPublicKey.java,v
retrieving revision 1.4
diff -u -r1.4 GnuRSAPublicKey.java
--- gnu/java/security/key/rsa/GnuRSAPublicKey.java 29 Apr 2006 06:53:06 -0000 1.4
+++ gnu/java/security/key/rsa/GnuRSAPublicKey.java 7 Jun 2006 22:35:22 -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;
@@ -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(")").toString();
Index: gnu/javax/crypto/sasl/plain/PasswordFile.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/javax/crypto/sasl/plain/PasswordFile.java,v
retrieving revision 1.1
diff -u -r1.1 PasswordFile.java
--- gnu/javax/crypto/sasl/plain/PasswordFile.java 26 Jan 2006 02:25:10 -0000 1.1
+++ gnu/javax/crypto/sasl/plain/PasswordFile.java 7 Jun 2006 22:35:22 -0000
@@ -38,8 +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;
@@ -47,14 +46,15 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.io.PrintWriter;
+import java.security.AccessController;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.StringTokenizer;
import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
/**
* A representation of a Plain password file.
@@ -68,8 +68,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;