Java 类java.rmi.RMISecurityManager 实例源码

项目:Camel    文件:TransactionHelper.java   
private TransactionManager findTransactionManager(String uri) throws IOException, ClassNotFoundException {
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    // Creating service template to find transaction manager service by matching fields.
    Class<?>[] classes = new Class<?>[] {net.jini.core.transaction.server.TransactionManager.class};
    // Name sn = new Name("*");
    ServiceTemplate tmpl = new ServiceTemplate(null, classes, new Entry[] {});

    // Creating a lookup locator
    LookupLocator locator = new LookupLocator(uri);
    ServiceRegistrar sr = locator.getRegistrar();

    TransactionManager tm = (TransactionManager) sr.lookup(tmpl);
    return tm;
}
项目:rmi-auth    文件:Main.java   
public static void main(String[] args) throws Throwable {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    System.out.print("login: ");
    String login = br.readLine();
    System.out.println();

    System.out.print("password: ");
    String password = br.readLine();
    System.out.println();

    AuthRMIClientSocketFactory.setHostAuthData("127.0.0.1",
            new AuthData(login, password));

    // Create and install a security manager
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    TestController test = (TestController) Naming.lookup(TestController.RMI_BINDING_NAME);

    System.out.println(test.f());
}
项目:cn1    文件:ConnectionTest.java   
/**
 * Runs test server process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestSingle(int config) throws Exception {
    try {
        System.err.println("Test server started.");
        System.setSecurityManager(new RMISecurityManager());
        setEnvironmentForConfig(config);
        initServer();
        mainTestBody();
        System.err.println("Test server complete.");
        SubProcess.tellOut();
    } finally {
        System.err.println("Test server closing.");
        unexportObjects();
    }
    System.err.println("Test server exiting.");
}
项目:cn1    文件:DGCTest.java   
/**
 * Runs registry process, wait for READY and exits with export
 * or stays on if input stream is closed.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runRegistry(int config) throws Exception {
    System.err.println("Registry starting");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    Registry reg = LocateRegistry.createRegistry(REGISTRY_PORT);
    System.err.println("Registry initialized, telling READY to parent");
    SubProcess.tellOut();
    System.err.println("Expecting READY from parent");

    try {
        SubProcess.expectIn();
        UnicastRemoteObject.unexportObject(reg, true);
        System.err.println("Registry exiting");
    } catch (EOFException e) {
        System.err.println("EOFException caught, registry stays on");
    }
}
项目:SORCER    文件:ContextScriptView.java   
/**
 * Constructor for creating the context view panel
 * 
 * @param dispatcher
 *            Remote dispatcher to use.
 */
public ContextScriptView(SignatureDispatchment dispatcher, BrowserModel model) {
    super(new BorderLayout());
    // needed for exerting the service
    this.model = model;
    if (System.getSecurityManager() == null)
        System.setSecurityManager(new RMISecurityManager());

    if (dispatcher instanceof SignatureDispatcherForProvider)
        provider = ((SignatureDispatcherForProvider)dispatcher).getProvider();
    else
        provider = ((SignatureDispatcherForCataloger)dispatcher).getProvider();

    tabbedPane = new JTabbedPane();

    inViewer = new EditorView("", false);

    tabbedPane.addTab("Browser", null,
            createBrowserPanel(null), "Browser");
    add(tabbedPane, BorderLayout.CENTER);
}
项目:freeVM    文件:ClientExecutor.java   
public static void main(String[] args) throws RemoteException,
        MalformedURLException {
    System.setSecurityManager(new RMISecurityManager() {
        public void checkPermission(Permission perm) {
        };
    });
    try {
        ReportIPServer.setServerHost(System
                .getProperty("java.rmi.server.hostname"));
    } catch (UnknownHostException e2) {
        e2.printStackTrace();
        System.exit(1);
    }
    initRegistry();
    exportExecutor();
    /*
     * This is just to avoid the Registry from being Garbage Collected.
     */
    while (true) {
        try {
            ReportIPServer.doit();
            Thread.sleep(SLEEP_MINUTES * 6000);
        } catch (InterruptedException e) {
        }
    }
}
项目:freeVM    文件:TestRMIClassLoader.java   
private void LoadClassStringString(String clase, boolean url) {
    SecurityManager smOld = System.getSecurityManager();
    System.setSecurityManager(new RMISecurityManager() {
        public void checkPermission(Permission perm) {
        }
    });
    try {
        if (url) {
            RMIClassLoader.loadClass(new URL("file://" + pathOwnClass),
                    clase);
        } else {
            RMIClassLoader.loadClass("file://" + pathOwnClass, clase);
        }
    } catch (Throwable e) {
        fail("Failed with: " + e);
    } finally {
        System.setSecurityManager(smOld);
    }

}
项目:freeVM    文件:TestRMIClassLoader.java   
public final void testLoadClassStringStringClassLoader006() {
    SecurityManager smOld = System.getSecurityManager();
    System.setSecurityManager(new RMISecurityManager() {
        public void checkPermission(Permission perm) {
        }
    });
    try {
        RMIClassLoader
                .loadClass(
                        "file://" + pathOwnClass,
                        "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001",
                        null);
    } catch (Throwable e) {
        fail("Should not raise an exception but raised: " + e);
    } finally {
        System.setSecurityManager(smOld);
    }
}
项目:freeVM    文件:ConnectionTest.java   
/**
 * Runs test server process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestSingle(int config) throws Exception {
    try {
        System.err.println("Test server started.");
        System.setSecurityManager(new RMISecurityManager());
        setEnvironmentForConfig(config);
        initServer();
        mainTestBody();
        System.err.println("Test server complete.");
        SubProcess.tellOut();
    } finally {
        System.err.println("Test server closing.");
        unexportObjects();
    }
    System.err.println("Test server exiting.");
}
项目:freeVM    文件:DGCTest.java   
/**
 * Runs registry process, wait for READY and exits with export
 * or stays on if input stream is closed.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runRegistry(int config) throws Exception {
    System.err.println("Registry starting");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    Registry reg = LocateRegistry.createRegistry(REGISTRY_PORT);
    System.err.println("Registry initialized, telling READY to parent");
    SubProcess.tellOut();
    System.err.println("Expecting READY from parent");

    try {
        SubProcess.expectIn();
        UnicastRemoteObject.unexportObject(reg, true);
        System.err.println("Registry exiting");
    } catch (EOFException e) {
        System.err.println("EOFException caught, registry stays on");
    }
}
项目:freeVM    文件:ConnectionTest.java   
/**
 * Runs test server process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestSingle(int config) throws Exception {
    try {
        System.err.println("Test server started.");
        System.setSecurityManager(new RMISecurityManager());
        setEnvironmentForConfig(config);
        initServer();
        mainTestBody();
        System.err.println("Test server complete.");
        SubProcess.tellOut();
    } finally {
        System.err.println("Test server closing.");
        unexportObjects();
    }
    System.err.println("Test server exiting.");
}
项目:freeVM    文件:DGCTest.java   
/**
 * Runs registry process, wait for READY and exits with export
 * or stays on if input stream is closed.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runRegistry(int config) throws Exception {
    System.err.println("Registry starting");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    Registry reg = LocateRegistry.createRegistry(REGISTRY_PORT);
    System.err.println("Registry initialized, telling READY to parent");
    SubProcess.tellOut();
    System.err.println("Expecting READY from parent");

    try {
        SubProcess.expectIn();
        UnicastRemoteObject.unexportObject(reg, true);
        System.err.println("Registry exiting");
    } catch (EOFException e) {
        System.err.println("EOFException caught, registry stays on");
    }
}
项目:freeVM    文件:BSTest.java   
public int test(final String host, final int port) {

        System.setProperty("java.security.policy", "NoPolicy!");
        Policy.getPolicy().refresh();
        System.setSecurityManager(new RMISecurityManager());
        try {
            ServerInterface obj = (ServerInterface) Naming.lookup("rmi://"
                    + host + ":" + port + "/Server");
            obj.remoteMethod("1 v pole ne voin");
            System.out.println("SecurityException wasn't thrown");

            return Result.FAIL;
        } catch (Throwable ex) {
            Throwable th = ex;
            while (th != null) {
                if (th instanceof SecurityException) {
                    return Result.PASS;
                }
                th = th.getCause();
            }
            ex.printStackTrace();
            return Result.FAIL;
        }
    }
项目:PortlandStateJava    文件:MovieDatabaseImpl.java   
/**
 * This main program registers an instance of MovieDatabaseImpl in
 * an RMI registry.
 */
public static void main(String[] args) {
  String host = args[0];
  int port = Integer.parseInt(args[1]);

  // Install an RMISecurityManager, if there is not a
  // SecurityManager already installed
  if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
  }

  String name = "rmi://" + host + ":" + port + "/MovieDatabase";

  try {
    MovieDatabase db  = new MovieDatabaseImpl();
    Naming.rebind(name, db);

  } catch (RemoteException | MalformedURLException ex) {
    ex.printStackTrace(System.err);
  }

}
项目:PortlandStateJava    文件:GetFilmography.java   
public static void main(String[] args) {
  String host = args[0];
  int port = Integer.parseInt(args[1]);
  Long actor = Long.parseLong(args[2]);

  // Install an RMISecurityManager, if there is not a
  // SecurityManager already installed
  if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
  }

  String name = "rmi://" + host + ":" + port + "/MovieDatabase";

  try {
    MovieDatabase db = 
      (MovieDatabase) Naming.lookup(name);
    db.getFilmography(actor).forEach(System.out::println);

  } catch (RemoteException | NotBoundException | MalformedURLException ex) {
    ex.printStackTrace(System.err);
  }

}
项目:sqlpower-library    文件:DBConnectionSpecServerImpl.java   
/**
 * Basic server main.  This class is executable with a command line
 * something like this:
 * 
 * java -Djava.rmi.server.codebase="base.of.classpath" \
 *      -cp ".;../../../../common/lib/xerces.jar" \
 *      -Djava.security.policy=rmi.policy \
 *      -DdatabasesFile=../databases.xml \
 *      ca.sqlpower.sql.DBConnectionSpecServerImpl
 */
public static void main(String args[]) throws RemoteException{

    // Create and install a security manager
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    DBConnectionSpecServerImpl obj =
            new DBConnectionSpecServerImpl();

    obj.xmlFileName = System.getProperty("databasesFile");
    if (obj.xmlFileName == null) {
        System.out.println(
            "no databases file specified.  Please add -DdatabaseFile=filename to the command line.");
    } else {
        try {
            java.rmi.registry.LocateRegistry.createRegistry(1099);
            Naming.rebind("///DBConnectionSpecServer", obj);
            System.out.println("DBConnectionSpecServer bound in registry");
        } catch (Exception e) {
            System.out.println(
                "DBConnectionSpecImpl err: " + e.getMessage());
            e.printStackTrace();
        }
    }
}
项目:Dragons-Arena    文件:Server.java   
public static void securitySetup() {
    System.setProperty("java.security.policy","file:./my.policy");
    // Create and install a security manager
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }
}
项目:rmi-auth    文件:Main.java   
public static void main(String[] args) throws Throwable {
    // Create and install a security manager
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    Naming.rebind(TestController.RMI_BINDING_NAME,
            new TestControllerRmiImpl(TestController.PORT, csf, ssf));

    while (true) {
        Thread.sleep(100);
    }
}
项目:jdk7-jdk    文件:Main.java   
/**
 * Set up security manager and policy, if not set already.
 */
static void setupSecurity() {
    if (System.getSecurityManager() != null)
        return;

    /* As of 1.4, it is too late to set the security policy
     * file at this point so these line have been commented out.
     */
    //System.setProperty("java.security.policy",
    //      Main.class.getResource("/bench/rmi/policy.all").toString());
    System.setSecurityManager(new RMISecurityManager());
}
项目:openjdk-source-code-learn    文件:Main.java   
/**
 * Set up security manager and policy, if not set already.
 */
static void setupSecurity() {
    if (System.getSecurityManager() != null)
        return;

    /* As of 1.4, it is too late to set the security policy
     * file at this point so these line have been commented out.
     */
    //System.setProperty("java.security.policy",
    //      Main.class.getResource("/bench/rmi/policy.all").toString());
    System.setSecurityManager(new RMISecurityManager());
}
项目:cn1    文件:RegistryContext.java   
/**
 * Installs {@link RMISecurityManager} if it is not already installed.
 * 
 * @throws NoPermissionException
 *             If security manager other than {@link RMISecurityManager} is
 *             installed and prohibits installing a new security manager.
 */
protected void installSecurityManager() throws NoPermissionException {
    if (!(System.getSecurityManager() instanceof RMISecurityManager)) {
        try {
            System.setSecurityManager(new RMISecurityManager());
        } catch (SecurityException e) {
            // jndi.84=Cannot install RMISecurityManager
            throw (NoPermissionException) new NoPermissionException(
                    Messages.getString("jndi.84")).initCause(e); //$NON-NLS-1$
        }
    }
}
项目:cn1    文件:ActivationGroupImpl.java   
/**
 * This main method is used to start new VMs for ActivationGroups. Four
 * parameters needed to create ActivationGroup are: <br>
 * ActivationGroupID <br>
 * ActivationGroupDesc <br>
 * incarnation The parameters needed to create ActivationGroup correctly are
 * passed through the standard input stream in the following order: <br>
 * ActivationGroupID -> ActivationGroupDesc -> incarnation
 */
public static void main(String args[]) {
    // rmi.log.4C=ActivationGroupImpl.main:
    rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.4C")); //$NON-NLS-1$
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    try {
        // rmi.log.4F=System.in.available = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.4F", //$NON-NLS-1$
                System.in.available()));

        RMIObjectInputStream ois = new RMIObjectInputStream(
                new BufferedInputStream(System.in));
        // rmi.log.55=ois = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.55", ois)); //$NON-NLS-1$
        ActivationGroupID agid = (ActivationGroupID) ois.readObject();
        // rmi.log.57=agid = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.57", agid)); //$NON-NLS-1$
        ActivationGroupDesc agdesc = (ActivationGroupDesc) ois.readObject();
        // rmi.log.74=agdesc = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.74", agdesc)); //$NON-NLS-1$
        long incarnation = ois.readLong();
        // rmi.log.7B=incarnation = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.7B", incarnation)); //$NON-NLS-1$
        ActivationGroup.createGroup(agid, agdesc, incarnation);
    } catch (Throwable t) {
        // rmi.log.7C=: Exception: {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.7C", t)); //$NON-NLS-1$
        t.printStackTrace();
    }
}
项目:cn1    文件:RegistryImpl.java   
/**
 * Starts rmiregistry on the specified port. If no port specified then
 * registry will be started on default port. This method ends with a
 * blocking construction to not let the VM exit.
 *
 * @param args arguments which can contain port number
 */
public static void main(String[] args) throws Exception {
    String usage =
        "Usage: java org.apache.harmony.rmi.registry.RegistryImpl <port>"; //$NON-NLS-1$
    int port = REGISTRY_PORT;

    if (args.length > 1) {
        System.err.println(usage);
        System.exit(-1);
    } else if (args.length == 1) {
        try {
            port = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            // rmi.console.1B=Invalid port number {0}
            System.out.println(Messages.getString("rmi.console.1B", args[0])); //$NON-NLS-1$
            System.out.println(usage);
            System.exit(-1);
        }
    }

    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }
    Registry reg = new RegistryImpl(port, null, null);

    // do not let VM exit
    Object obj = new Object();  //$NON-LOCK-1$

    synchronized(obj) {
        obj.wait();
    }
}
项目:cn1    文件:RegistryTest.java   
/**
 * Tests registry creation and destruction.
 *
 * @throws  Exception
 *          If some error occurs.
 */
public void testBasic() throws Exception {
    System.setSecurityManager(new RMISecurityManager());

    // Create registry.
    int port = CUSTOM_PORT_1;
    Registry reg = LocateRegistry.createRegistry(port);
    System.out.println("Registry on CUSTOM port ("
                       + port + ") created.");

    // Destroy registry.
    UnicastRemoteObject.unexportObject(reg, true);
    System.out.println("Test complete.");
}
项目:cn1    文件:DGCTest.java   
/**
 * Runs test server process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestServer0(int config) throws Exception {
    System.err.println("Test server started");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    MyRemoteInterface1 obj = new TestObject();
    UnicastRemoteObject.exportObject(obj, CUSTOM_PORT_4);
    LocateRegistry.getRegistry().rebind(
            TEST_STRING_1, RemoteObject.toStub(obj));
    GCThread.create();
    System.err.println("Test server initialized, telling READY to parent");
    SubProcess.tellOut();
}
项目:cn1    文件:DGCTest.java   
/**
 * Runs test client process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestClient0(int config) throws Exception {
    System.err.println("Test client started");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    Registry reg = LocateRegistry.getRegistry();
    MyRemoteInterface1 mri = (MyRemoteInterface1) reg.lookup(TEST_STRING_1);
    mri.test1();
    System.err.println("Test client completed");
}
项目:cn1    文件:DGCTest.java   
/**
 * Runs test server process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestServer3(int config) throws Exception {
    System.err.println("Test server started");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    Registry reg = LocateRegistry.createRegistry(REGISTRY_PORT);
    TestObject obj = new TestObject();
    UnicastRemoteObject.exportObject(obj, REGISTRY_PORT);
    obj = null;
    System.gc();
    System.err.println("Test server exiting");
}
项目:mtools    文件:RmiServer.java   
public static void main(String[] args) {
    // TODO Auto-generated method stub
       try {
        System.setSecurityManager(new RMISecurityManager());
        RmiService service=new RmiServiceImpl();
        //注册通讯端口
        LocateRegistry.createRegistry(6600);
        //注册通讯路径
        Naming.rebind("rmi://127.0.0.1:6600/PersonService", service);
        System.out.println("Service Start!");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:CERTUS-Server    文件:CertusServer.java   
public static void main(String args[]) {

        PORT = Integer.parseInt(ConfigurationProperties.rmiPort());
        String filePath = ConfigurationProperties.rmiBasePath();
        System.setProperty("java.security.policy", filePath + ConfigurationProperties.rmiFilePolicy());

        // Create and install a security manager
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }

        try {
            // Create SSL-based registry
            Registry registry = LocateRegistry.createRegistry(PORT,
            new RMISSLClientSocketFactory(),
            new RMISSLServerSocketFactory());

            CertusServer obj = new CertusServer();

            // Bind this object instance to the name "CertusServer"
            registry.bind(ConfigurationProperties.rmiRegistry(), obj);

            dbc = new DatabaseConnector();
            sec = new SecurityValidator();
            refMonitor = new Authoriser(dbc);
            clientSessions = new ClientsSessions();

            System.out.println("Certus Service bound in registry");         
        } catch (Exception e) {
            System.out.println("ERROR: CERTUS RMI service exception: " + e.getMessage());
            e.printStackTrace();
        }
    }
项目:JAVA_UNIT    文件:Main.java   
/**
 * Set up security manager and policy, if not set already.
 */
static void setupSecurity() {
    if (System.getSecurityManager() != null)
        return;

    /* As of 1.4, it is too late to set the security policy
     * file at this point so these line have been commented out.
     */
    //System.setProperty("java.security.policy",
    //      Main.class.getResource("/bench/rmi/policy.all").toString());
    System.setSecurityManager(new RMISecurityManager());
}
项目:openjdk-jdk7u-jdk    文件:Main.java   
/**
 * Set up security manager and policy, if not set already.
 */
static void setupSecurity() {
    if (System.getSecurityManager() != null)
        return;

    /* As of 1.4, it is too late to set the security policy
     * file at this point so these line have been commented out.
     */
    //System.setProperty("java.security.policy",
    //      Main.class.getResource("/bench/rmi/policy.all").toString());
    System.setSecurityManager(new RMISecurityManager());
}
项目:nextop-client    文件:RegistryContext.java   
/**
 * Installs {@link RMISecurityManager} if it is not already installed.
 * 
 * @throws NoPermissionException
 *             If security manager other than {@link RMISecurityManager} is
 *             installed and prohibits installing a new security manager.
 */
protected void installSecurityManager() throws NoPermissionException {
    if (!(System.getSecurityManager() instanceof RMISecurityManager)) {
        try {
            System.setSecurityManager(new RMISecurityManager());
        } catch (SecurityException e) {
            // jndi.84=Cannot install RMISecurityManager
            throw (NoPermissionException) new NoPermissionException(
                    Messages.getString("jndi.84")).initCause(e); //$NON-NLS-1$
        }
    }
}
项目:freeVM    文件:TestRMIClassLoader.java   
private void LoadClassStringStringClassLoader(String path, String clase,
        String name) throws MalformedURLException {
    SecurityManager smOld = System.getSecurityManager();
    System.setSecurityManager(new RMISecurityManager() {
        public void checkPermission(Permission perm) {
        }
    });
    try {
        File f = new File(pathOwnClass);
        if (f.exists() && f.isDirectory()) {
            URL list[] = { new URL("file://" + pathOwnClass) };
            try {
                RMIClassLoader.loadClass(path, clase, new URLClassLoader(
                        list));
            } catch (Throwable e) {
                fail("Should not raise an exception but raised: " + e);
            }
        } else {
            System.err
                    .println("Directory: " + pathOwnClass + " not found.");
            System.err.println(name + " disabled.");
            fail("TEST DISABLED");
        }
    } finally {
        System.setSecurityManager(smOld);
    }
}
项目:freeVM    文件:TestRMISecurityManager.java   
public void testRMISecurityManager001() {
    try {
        assertTrue(new RMISecurityManager() instanceof RMISecurityManager);
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
项目:freeVM    文件:RegistryContext.java   
/**
 * Installs {@link RMISecurityManager} if it is not already installed.
 *
 * @throws  NoPermissionException
 *          If security manager other than {@link RMISecurityManager}
 *          is installed and prohibits installing a new security manager.
 */
protected void installSecurityManager() throws NoPermissionException {
    if (! (System.getSecurityManager() instanceof RMISecurityManager)) {
        try {
            System.setSecurityManager(new RMISecurityManager());
        } catch (SecurityException e) {
            // jndi.84=Cannot install RMISecurityManager
            throw (NoPermissionException) new NoPermissionException(
                    Messages.getString("jndi.84")).initCause(e); //$NON-NLS-1$
        }
    }
}
项目:freeVM    文件:ActivationGroupImpl.java   
/**
 * This main method is used to start new VMs for ActivationGroups. Four
 * parameters needed to create ActivationGroup are: <br>
 * ActivationGroupID <br>
 * ActivationGroupDesc <br>
 * incarnation The parameters needed to create ActivationGroup correctly are
 * passed through the standard input stream in the following order: <br>
 * ActivationGroupID -> ActivationGroupDesc -> incarnation
 */
public static void main(String args[]) {
    // rmi.log.4C=ActivationGroupImpl.main:
    rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.4C")); //$NON-NLS-1$
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    try {
        // rmi.log.4F=System.in.available = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.4F", //$NON-NLS-1$
                System.in.available()));

        RMIObjectInputStream ois = new RMIObjectInputStream(
                new BufferedInputStream(System.in));
        // rmi.log.55=ois = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.55", ois)); //$NON-NLS-1$
        ActivationGroupID agid = (ActivationGroupID) ois.readObject();
        // rmi.log.57=agid = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.57", agid)); //$NON-NLS-1$
        ActivationGroupDesc agdesc = (ActivationGroupDesc) ois.readObject();
        // rmi.log.74=agdesc = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.74", agdesc)); //$NON-NLS-1$
        long incarnation = ois.readLong();
        // rmi.log.7B=incarnation = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.7B", incarnation)); //$NON-NLS-1$
        ActivationGroup.createGroup(agid, agdesc, incarnation);
    } catch (Throwable t) {
        // rmi.log.7C=: Exception: {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.7C", t)); //$NON-NLS-1$
        t.printStackTrace();
    }
}
项目:freeVM    文件:RegistryImpl.java   
/**
 * Starts rmiregistry on the specified port. If no port specified then
 * registry will be started on default port. This method ends with a
 * blocking construction to not let the VM exit.
 *
 * @param args arguments which can contain port number
 */
public static void main(String[] args) throws Exception {
    String usage =
        "Usage: java org.apache.harmony.rmi.registry.RegistryImpl <port>"; //$NON-NLS-1$
    int port = REGISTRY_PORT;

    if (args.length > 1) {
        System.err.println(usage);
        System.exit(-1);
    } else if (args.length == 1) {
        try {
            port = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            // rmi.console.1B=Invalid port number {0}
            System.out.println(Messages.getString("rmi.console.1B", args[0])); //$NON-NLS-1$
            System.out.println(usage);
            System.exit(-1);
        }
    }

    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }
    Registry reg = new RegistryImpl(port, null, null);

    // do not let VM exit
    Object obj = new Object();  //$NON-LOCK-1$

    synchronized(obj) {
        obj.wait();
    }
}
项目:freeVM    文件:RegistryTest.java   
/**
 * Tests registry creation and destruction.
 *
 * @throws  Exception
 *          If some error occurs.
 */
public void testBasic() throws Exception {
    System.setSecurityManager(new RMISecurityManager());

    // Create registry.
    int port = CUSTOM_PORT_1;
    Registry reg = LocateRegistry.createRegistry(port);
    System.out.println("Registry on CUSTOM port ("
                       + port + ") created.");

    // Destroy registry.
    UnicastRemoteObject.unexportObject(reg, true);
    System.out.println("Test complete.");
}
项目:freeVM    文件:DGCTest.java   
/**
 * Runs test server process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestServer0(int config) throws Exception {
    System.err.println("Test server started");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    MyRemoteInterface1 obj = new TestObject();
    UnicastRemoteObject.exportObject(obj, CUSTOM_PORT_4);
    LocateRegistry.getRegistry().rebind(
            TEST_STRING_1, RemoteObject.toStub(obj));
    GCThread.create();
    System.err.println("Test server initialized, telling READY to parent");
    SubProcess.tellOut();
}