1 /*
2 * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
44 import java.util.Properties;
45 import java.util.StringTokenizer;
46
47 /**
48 * The RMI activation system needs to explicitly allow itself to
49 * create the following sun.* classes on behalf of code that runs with
50 * user privileges and needs to make use of RMI activation:
51 *
52 * sun.rmi.server.Activation$ActivationMonitorImpl_Stub
53 * sun.rmi.server.Activation$ActivationSystemImpl_Stub
54 * sun.rmi.registry.RegistryImpl_Stub
55 *
56 * The test causes the activation system to need to create each of
57 * these classes in turn. The test will fail if the activation system
58 * does not allow these classes to be created.
59 */
60 public class StubClassesPermitted
61 extends Activatable implements Runnable, CanCreateStubs
62 {
63 public static boolean sameGroup = false;
64
65 private static CanCreateStubs canCreateStubs = null;
66 private static Registry registry = null;
67
68 public static void main(String args[]) {
69
70 sameGroup = true;
71
72 RMID rmid = null;
73
74 System.err.println("\nRegression test for bug/rfe 4179055\n");
75
76 try {
77 TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
78
79 registry = java.rmi.registry.LocateRegistry.
80 createRegistry(TestLibrary.REGISTRY_PORT);
81
82 // must run with java.lang.SecurityManager or the test
83 // result will be nullified if running with a build where
84 // 4180392 has not been fixed.
85 String smClassName =
86 System.getSecurityManager().getClass().getName();
87 if (!smClassName.equals("java.lang.SecurityManager")) {
88 TestLibrary.bomb("Test must run with java.lang.SecurityManager");
89 }
90
91 // start an rmid.
92 RMID.removeLog();
93 rmid = RMID.createRMID();
94 rmid.start();
95
96 //rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
97
98 // Ensure that activation groups run with the correct
99 // security manager.
100 //
175
176 canCreateStubs = null;
177 ActivationLibrary.rmidCleanup(rmid);
178 System.err.println("rmid shut down");
179 }
180 }
181
182 static ActivationGroupID GroupID = null;
183
184 /**
185 * implementation of CanCreateStubs
186 */
187 public StubClassesPermitted
188 (ActivationID id, MarshalledObject mo) throws RemoteException
189 {
190 // register/export anonymously
191 super(id, 0);
192
193 // obtain reference to the test registry
194 registry = java.rmi.registry.LocateRegistry.
195 getRegistry(TestLibrary.REGISTRY_PORT);
196 }
197
198 /**
199 * Spawns a thread to deactivate the object.
200 */
201 public void shutdown() throws Exception {
202 (new Thread(this,"StubClassesPermitted")).start();
203 }
204
205 /**
206 * Thread to deactivate object. First attempts to make object
207 * inactive (via the inactive method). If that fails (the
208 * object may still have pending/executing calls), then
209 * unexport the object forcibly.
210 */
211 public void run() {
212 ActivationLibrary.deactivate(this, getID());
213 }
214
215 /**
|
1 /*
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
44 import java.util.Properties;
45 import java.util.StringTokenizer;
46
47 /**
48 * The RMI activation system needs to explicitly allow itself to
49 * create the following sun.* classes on behalf of code that runs with
50 * user privileges and needs to make use of RMI activation:
51 *
52 * sun.rmi.server.Activation$ActivationMonitorImpl_Stub
53 * sun.rmi.server.Activation$ActivationSystemImpl_Stub
54 * sun.rmi.registry.RegistryImpl_Stub
55 *
56 * The test causes the activation system to need to create each of
57 * these classes in turn. The test will fail if the activation system
58 * does not allow these classes to be created.
59 */
60 public class StubClassesPermitted
61 extends Activatable implements Runnable, CanCreateStubs
62 {
63 public static boolean sameGroup = false;
64 private static int registryPort = -1;
65 private static CanCreateStubs canCreateStubs = null;
66 private static Registry registry = null;
67
68 public static void main(String args[]) {
69
70 sameGroup = true;
71
72 RMID rmid = null;
73
74 System.err.println("\nRegression test for bug/rfe 4179055\n");
75
76 try {
77 TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
78
79 registry = TestLibrary.createRegistryOnUnusedPort();
80 registryPort = TestLibrary.getRegistryPort(registry);
81
82 // must run with java.lang.SecurityManager or the test
83 // result will be nullified if running with a build where
84 // 4180392 has not been fixed.
85 String smClassName =
86 System.getSecurityManager().getClass().getName();
87 if (!smClassName.equals("java.lang.SecurityManager")) {
88 TestLibrary.bomb("Test must run with java.lang.SecurityManager");
89 }
90
91 // start an rmid.
92 RMID.removeLog();
93 rmid = RMID.createRMID();
94 rmid.start();
95
96 //rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
97
98 // Ensure that activation groups run with the correct
99 // security manager.
100 //
175
176 canCreateStubs = null;
177 ActivationLibrary.rmidCleanup(rmid);
178 System.err.println("rmid shut down");
179 }
180 }
181
182 static ActivationGroupID GroupID = null;
183
184 /**
185 * implementation of CanCreateStubs
186 */
187 public StubClassesPermitted
188 (ActivationID id, MarshalledObject mo) throws RemoteException
189 {
190 // register/export anonymously
191 super(id, 0);
192
193 // obtain reference to the test registry
194 registry = java.rmi.registry.LocateRegistry.
195 getRegistry(registryPort);
196 }
197
198 /**
199 * Spawns a thread to deactivate the object.
200 */
201 public void shutdown() throws Exception {
202 (new Thread(this,"StubClassesPermitted")).start();
203 }
204
205 /**
206 * Thread to deactivate object. First attempts to make object
207 * inactive (via the inactive method). If that fails (the
208 * object may still have pending/executing calls), then
209 * unexport the object forcibly.
210 */
211 public void run() {
212 ActivationLibrary.deactivate(this, getID());
213 }
214
215 /**
|