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:
parent
ae066484df
commit
ec5c28ece1
6 changed files with 217 additions and 83 deletions
|
@ -48,6 +48,7 @@ import java.util.Hashtable;
|
|||
|
||||
import gnu.java.io.ObjectIdentityWrapper;
|
||||
import gnu.java.lang.reflect.TypeSignature;
|
||||
import gnu.java.security.action.SetAccessibleAction;
|
||||
import gnu.classpath.Configuration;
|
||||
|
||||
/**
|
||||
|
@ -1516,20 +1517,14 @@ public class ObjectOutputStream extends OutputStream
|
|||
}
|
||||
}
|
||||
|
||||
private static Field getField (Class klass, String name)
|
||||
private Field getField (Class klass, String name)
|
||||
throws java.io.InvalidClassException
|
||||
{
|
||||
try
|
||||
{
|
||||
final Field f = klass.getDeclaredField(name);
|
||||
AccessController.doPrivileged(new PrivilegedAction()
|
||||
{
|
||||
public Object run()
|
||||
{
|
||||
f.setAccessible(true);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
setAccessible.setMember(f);
|
||||
AccessController.doPrivileged(setAccessible);
|
||||
return f;
|
||||
}
|
||||
catch (java.lang.NoSuchFieldException e)
|
||||
|
@ -1539,18 +1534,12 @@ public class ObjectOutputStream extends OutputStream
|
|||
}
|
||||
}
|
||||
|
||||
private static Method getMethod (Class klass, String name, Class[] args)
|
||||
private Method getMethod (Class klass, String name, Class[] args)
|
||||
throws java.lang.NoSuchMethodException
|
||||
{
|
||||
final Method m = klass.getDeclaredMethod(name, args);
|
||||
AccessController.doPrivileged(new PrivilegedAction()
|
||||
{
|
||||
public Object run()
|
||||
{
|
||||
m.setAccessible(true);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
setAccessible.setMember(m);
|
||||
AccessController.doPrivileged(setAccessible);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -1583,6 +1572,7 @@ public class ObjectOutputStream extends OutputStream
|
|||
private Hashtable OIDLookupTable;
|
||||
private int protocolVersion;
|
||||
private boolean useSubclassMethod;
|
||||
private SetAccessibleAction setAccessible = new SetAccessibleAction();
|
||||
|
||||
// The nesting depth for debugging output
|
||||
private int depth = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue