KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > javax > management > remote > rmi > RMIJRMPRemoteSecurityManagerTest


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package test.javax.management.remote.rmi;
10
11 import java.net.MalformedURLException JavaDoc;
12 import java.security.Policy JavaDoc;
13 import javax.management.remote.JMXServiceURL JavaDoc;
14
15 import test.javax.management.remote.RemoteSecurityManagerTestCase;
16
17 /**
18  * @version $Revision: 1.3 $
19  */

20 public class RMIJRMPRemoteSecurityManagerTest extends RemoteSecurityManagerTestCase
21 {
22    static
23    {
24       // For the way JUnit works, we have one JVM per test class
25
Policy.setPolicy(new RMIJRMPRemoteModifiablePolicy());
26       System.setSecurityManager(new SecurityManager JavaDoc());
27    }
28
29    public RMIJRMPRemoteSecurityManagerTest(String JavaDoc s)
30    {
31       super(s);
32    }
33
34    protected JMXServiceURL JavaDoc createJMXConnectorServerAddress() throws MalformedURLException JavaDoc
35    {
36       return new JMXServiceURL JavaDoc("rmi", "localhost", 7777);
37    }
38
39    public static class RMIJRMPRemoteModifiablePolicy extends RemoteModifiablePolicy
40    {
41       public boolean isServerSide()
42       {
43          if (!isSeparateClientServerPermissions()) return true;
44          String JavaDoc name = Thread.currentThread().getName();
45          if (name.indexOf("RMI") >= 0) return true;
46          return false;
47       }
48    }
49 }
50
Popular Tags