Update of /cvsroot/mx4j/mx4j/src/test/test/javax/management/remote
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3968/test/test/javax/management/remote
Added Files:
RemoteSecurityManagerTestCase.java
Log Message:
Rewriting security tests based on a modifiable policy, for both remote and local tests
--- NEW FILE: RemoteSecurityManagerTestCase.java ---
/*
* Copyright (C) MX4J.
* All rights reserved.
*
* This software is distributed under the terms of the MX4J License version 1.0.
* See the terms of the MX4J License in the documentation provided with this software.
*/
package test.javax.management.remote;
import java.net.MalformedURLException;
import java.net.SocketPermission;
import java.security.AccessController;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.Policy;
[...1357 lines suppressed...]
* {@link PermissionCollection#setReadOnly}. Since this policy
* adds permissions at runtime, having the Permissions object marked as read-only
* causes an exception that invalidates the test.
* Here I copy the read-only Permissions into a new Permissions object (by copying
* all permissions it contains into the copied object), and return it.
* If the Permissions object is not read-only, it is returned immediately.
*/
private PermissionCollection copyIfReadOnly(PermissionCollection p)
{
if (!p.isReadOnly()) return p;
Permissions permissions = new Permissions();
for (Enumeration e = p.elements(); e.hasMoreElements();)
{
Permission permission = (Permission)e.nextElement();
permissions.add(permission);
}
return permissions;
}
}
}
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.