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
This commit is contained in:
Bryce McKinlay 2004-07-23 22:20:14 +00:00 committed by Bryce McKinlay
parent ae066484df
commit ec5c28ece1
6 changed files with 217 additions and 83 deletions

View file

@ -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);
}
/**