/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4179055
* @summary Some java apps need to have access to read "accessClassInPackage.sun.rmi.server"
* @author Laird Dornin
*
* @library ../../../testlibrary
* @build TestLibrary RMID ActivationLibrary
* CanCreateStubs StubClassesPermitted_Stub
* @run main/othervm/policy=security.policy/secure=java.lang.SecurityManager/timeout=240 StubClassesPermitted
*/
/**
* The RMI activation system needs to explicitly allow itself to
* create the following sun.* classes on behalf of code that runs with
* user privileges and needs to make use of RMI activation:
*
* sun.rmi.server.Activation$ActivationMonitorImpl_Stub
* sun.rmi.server.Activation$ActivationSystemImpl_Stub
* sun.rmi.registry.RegistryImpl_Stub
*
* The test causes the activation system to need to create each of
* these classes in turn. The test will fail if the activation system
* does not allow these classes to be created.
*/
public class StubClassesPermitted
{
public static boolean sameGroup = false;
sameGroup = true;
try {
// must run with java.lang.SecurityManager or the test
// result will be nullified if running with a build where
// 4180392 has not been fixed.
}
// start an rmid.
//rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
// Ensure that activation groups run with the correct
// security manager.
//
Properties p = new Properties();
p.put("java.security.policy",
p.put("java.security.manager",
"java.lang.SecurityManager");
// This action causes the following classes to be created
// in this VM (RMI must permit the creation of these classes):
//
// sun.rmi.server.Activation$ActivationSystemImpl_Stub
// sun.rmi.server.Activation$ActivationMonitorImpl_Stub
//
new ActivationGroupDesc(p, null);
// Fix for: 4271615: make sure activation group runs in a new VM
// ensure registry stub can be passed in a remote call
// make sure a client cant load just any sun.* class, just
// as a sanity check, try to create a class we are not
// allowed to access but which was passed in a remote call
try {
" sun.security.provider.SecureRandom");
// Make sure we received a *local* AccessControlException
e.printStackTrace(ps);
{
throw e;
}
}
// make sure that an ActivationGroupID can be passed in a
// remote call; this is slightly more inclusive than
// just passing a reference to the activation system
// Clean up object
("Deactivate object via method call");
("\nsuccess: StubClassesPermitted test passed ");
} catch (Exception e) {
} finally {
try {
} catch (InterruptedException e) {
}
}
}
/**
* implementation of CanCreateStubs
*/
public StubClassesPermitted
{
super(id, 0);
// obtain reference to the test registry
}
/**
* Spawns a thread to deactivate the object.
*/
}
/**
* Thread to deactivate object. First attempts to make object
* inactive (via the inactive method). If that fails (the
* unexport the object forcibly.
*/
public void run() {
}
/**
* Return a reference to the RMI registry, to make sure that
* the stub for it can be deserialized in the test client VM.
*/
if (sameGroup) {
} else {
}
return registry;
}
/**
* Remote call to create and return a random serializable sun.*
* class, the test should get a local security exception when
* trying to create the class. Ensure that not all sun.* classes
* can be resolved in a remote call.
*/
}
/**
* Ensures that an activation group id can be passed in a remote
* call (class may contain a remote reference to the activation
* system implementation).
*/
return ActivationGroup.currentGroupID();
}
}