From e755efce8f87ba0b194aab239570f6a0690dc88a Mon Sep 17 00:00:00 2001 From: bryce Date: Fri, 23 Jul 2004 22:20:14 +0000 Subject: 2004-07-23 Bryce McKinlay * gnu/java/net/protocol/http/Connection.java: Use GetPropertyAction for privileged getProperty calls. * java/io/ObjectOutputStream.java (getField): No longer static. Use SetAccessibleAction instead of anonymous class for doPrivileged call. (getMethod): Likewise. (setAccessible): New field. PrivilegedAction object to use when calling setAccessible. * java/io/ObjectStreamClass.java (calculateOffsets): Use SetAccessibleAction instead of anonymous class for diPrivileged call. (setFields): Likewise. (getClassUID): Likewise. (findMethod): Likewise. * gnu/java/security/action/GetPropertyAction.java: New class. * gnu/java/security/action/SetAccessibleAction.java: New class. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85097 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/gnu/java/net/protocol/http/Connection.java | 54 ++++++++++------------ 1 file changed, 25 insertions(+), 29 deletions(-) (limited to 'libjava/gnu/java/net/protocol/http/Connection.java') diff --git a/libjava/gnu/java/net/protocol/http/Connection.java b/libjava/gnu/java/net/protocol/http/Connection.java index 728d14a7e6b..ccae499dc33 100644 --- a/libjava/gnu/java/net/protocol/http/Connection.java +++ b/libjava/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.setName("http.proxyPort"); + port = (String) AccessController.doPrivileged(getProperty); + if (port != null) + { + try + { + proxyPort = Integer.parseInt(port); + } + catch (NumberFormatException ex) + { + // Nothing. + } + } + } - return null; - } - }); + getProperty.setName("http.agent"); + userAgent = (String) AccessController.doPrivileged(getProperty); } /** -- cgit v1.2.3