diff options
| author | Bryce McKinlay <mckinlay@redhat.com> | 2004-07-28 22:32:30 +0000 |
|---|---|---|
| committer | Bryce McKinlay <mckinlay@redhat.com> | 2004-07-28 22:32:30 +0000 |
| commit | 39f4e18fc9d6769a1d5a3bb0f542fdcf77b21fbc (patch) | |
| tree | 6681663a56ecdcdcc3a88cce19a3a5cc54778c47 /gnu | |
| parent | b7aad7b5fc47db20bb2db34b765928c20e507870 (diff) | |
| download | classpath-39f4e18fc9d6769a1d5a3bb0f542fdcf77b21fbc.tar.gz | |
2004-07-28 Bryce McKinlay <mckinlay@redhat.com>
* gnu/java/security/action/GetPropertyAction.java (setParameters):
Renamed from 'setName'. New 2-argument form with default value.
(run): Pass default 'value' parameter to System.getProperty().
* gnu/java/security/action/SetAccessibleAction.java: Fix javadoc
typos.
* gnu/java/net/protocol/http/Connection.java: Use 'setParameters'
not 'setName'.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/java/net/protocol/http/Connection.java | 54 | ||||
| -rw-r--r-- | gnu/java/security/action/GetPropertyAction.java | 24 | ||||
| -rw-r--r-- | gnu/java/security/action/SetAccessibleAction.java | 4 |
3 files changed, 46 insertions, 36 deletions
diff --git a/gnu/java/net/protocol/http/Connection.java b/gnu/java/net/protocol/http/Connection.java index 728d14a7e..e15fda862 100644 --- a/gnu/java/net/protocol/http/Connection.java +++ b/gnu/java/net/protocol/http/Connection.java @@ -59,6 +59,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import gnu.java.net.HeaderFieldHelper; +import gnu.java.security.action.GetPropertyAction; /** * This subclass of java.net.URLConnection models a URLConnection via @@ -88,36 +89,31 @@ public final class Connection extends HttpURLConnection static { - // Make sure access control for system properties depends only on - // our class ProtectionDomain, not on any (indirect) callers. - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() - { - // Recognize some networking properties listed at - // http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. - String port = null; - proxyHost = System.getProperty("http.proxyHost"); - if (proxyHost != null) - { - proxyInUse = true; - if ((port = System.getProperty("http.proxyPort")) != null) - { - try - { - proxyPort = Integer.parseInt(port); - } - catch (Throwable t) - { - // Nothing. - } - } - } - - userAgent = System.getProperty("http.agent"); + // Recognize some networking properties listed at + // http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. + String port = null; + GetPropertyAction getProperty = new GetPropertyAction("http.proxyHost"); + proxyHost = (String) AccessController.doPrivileged(getProperty); + if (proxyHost != null) + { + proxyInUse = true; + getProperty.setParameters("http.proxyPort"); + port = (String) AccessController.doPrivileged(getProperty); + if (port != null) + { + try + { + proxyPort = Integer.parseInt(port); + } + catch (NumberFormatException ex) + { + // Nothing. + } + } + } - return null; - } - }); + getProperty.setParameters("http.agent"); + userAgent = (String) AccessController.doPrivileged(getProperty); } /** diff --git a/gnu/java/security/action/GetPropertyAction.java b/gnu/java/security/action/GetPropertyAction.java index f40f479ba..3657254d0 100644 --- a/gnu/java/security/action/GetPropertyAction.java +++ b/gnu/java/security/action/GetPropertyAction.java @@ -51,7 +51,8 @@ import java.security.PrivilegedAction; */ public class GetPropertyAction implements PrivilegedAction { - String propName; + String name; + String value = null; public GetPropertyAction() { @@ -59,17 +60,30 @@ public class GetPropertyAction implements PrivilegedAction public GetPropertyAction(String propName) { - this.propName = propName; + setParameters(propName); + } + + public GetPropertyAction(String propName, String defaultValue) + { + setParameters(propName, defaultValue); } public Object run() { - return System.getProperty(propName); + return System.getProperty(name, value); } - public GetPropertyAction setName(String propName) + public GetPropertyAction setParameters(String propName) + { + this.name = propName; + this.value = null; + return this; + } + + public GetPropertyAction setParameters(String propName, String defaultValue) { - this.propName = propName; + this.name = propName; + this.value = defaultValue; return this; } } diff --git a/gnu/java/security/action/SetAccessibleAction.java b/gnu/java/security/action/SetAccessibleAction.java index 810681fd8..2827a3a6f 100644 --- a/gnu/java/security/action/SetAccessibleAction.java +++ b/gnu/java/security/action/SetAccessibleAction.java @@ -41,13 +41,13 @@ import java.lang.reflect.AccessibleObject; import java.security.PrivilegedAction; /** - * PrivilagedAction implementation that calls setAccessible(true) on the + * PrivilegedAction implementation that calls setAccessible(true) on the * AccessibleObject passed to its constructor. * * Example of use: * <code> * Field dataField = cl.getDeclaredField("data"); - * AccessController.doPrivilaged(new SetAccessibleAction(dataField)); + * AccessController.doPrivileged(new SetAccessibleAction(dataField)); * </code> */ public class SetAccessibleAction implements PrivilegedAction |
