diff options
| author | Bryce McKinlay <mckinlay@redhat.com> | 2004-07-23 22:20:14 +0000 |
|---|---|---|
| committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2004-07-23 23:20:14 +0100 |
| commit | ec5c28ece1abe76452e1c70918fb44c543b71a81 (patch) | |
| tree | 96dc496d784f2249834ceb7610963655c445967c /libjava/gnu/java/net/protocol | |
| parent | ae066484dfc4edafddbcf5089720d8ceef28c232 (diff) | |
| download | gcc-ec5c28ece1abe76452e1c70918fb44c543b71a81.zip gcc-ec5c28ece1abe76452e1c70918fb44c543b71a81.tar.gz gcc-ec5c28ece1abe76452e1c70918fb44c543b71a81.tar.bz2 | |
Connection.java: Use GetPropertyAction for privileged getProperty calls.
2004-07-23 Bryce McKinlay <mckinlay@redhat.com>
* 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.
From-SVN: r85097
Diffstat (limited to 'libjava/gnu/java/net/protocol')
| -rw-r--r-- | libjava/gnu/java/net/protocol/http/Connection.java | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/libjava/gnu/java/net/protocol/http/Connection.java b/libjava/gnu/java/net/protocol/http/Connection.java index 728d14a..ccae499 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); } /** |
