Example usage for java.rmi RMISecurityManager RMISecurityManager

List of usage examples for java.rmi RMISecurityManager RMISecurityManager

Introduction

In this page you can find the example usage for java.rmi RMISecurityManager RMISecurityManager.

Prototype

public RMISecurityManager() 

Source Link

Document

Constructs a new RMISecurityManager .

Usage

From source file:edu.clemson.cs.nestbed.client.Client.java

public static void main(String[] args) throws Exception {
    /*/*from  www . j  a  va2 s .c o m*/
    System.setOut(new PrintStream(new BufferedOutputStream(
              new LogOutputStream(System.class, Level.WARN)),  true));
    System.setErr(new PrintStream(new BufferedOutputStream(
              new LogOutputStream(System.class, Level.ERROR)), true));
              */

    loadProperties();

    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    PropertyConfigurator.configure(Client.class.getClassLoader().getResource("clientLog.conf"));

    log.info("******************************************************\n" + "** NESTbed Client Starting\n"
            + "******************************************************");
    log.info("Version:  " + Version.VERSION);

    log.debug("Class Loader:  " + Client.class.getClassLoader());
    ParentClassLoader.setParent(Client.class.getClassLoader());

    TestbedManagerFrame mainWindow = new TestbedManagerFrame();
    mainWindow.setVisible(true);
}

From source file:uk.co.moonsit.rmi.GraphClient.java

@SuppressWarnings("SleepWhileInLoop")
public static void main(String args[]) {
    Properties p = new Properties();
    try {/*  ww w .  j  a  v a  2  s.  c om*/
        p.load(new FileReader("graph.properties"));
    } catch (IOException ex) {
        Logger.getLogger(GraphClient.class.getName()).log(Level.SEVERE, null, ex);
    }
    //String[] labels = p.getProperty("labels").split(",");
    GraphClient demo = null;
    int type = 0;
    boolean log = false;
    if (args[0].equals("-l")) {
        log = true;
    }

    switch (type) {
    case 0:
        try {
            System.setProperty("java.security.policy", "file:./client.policy");
            if (System.getSecurityManager() == null) {
                System.setSecurityManager(new RMISecurityManager());
            }
            String name = "GraphServer";
            String host = p.getProperty("host");
            System.out.println(host);
            Registry registry = LocateRegistry.getRegistry(host);
            String[] list = registry.list();
            for (String s : list) {
                System.out.println(s);
            }
            GraphDataInterface gs = null;
            boolean bound = false;
            while (!bound) {
                try {
                    gs = (GraphDataInterface) registry.lookup(name);
                    bound = true;
                } catch (NotBoundException e) {
                    System.err.println("GraphServer exception:" + e.toString());
                    Thread.sleep(500);
                }
            }
            @SuppressWarnings("null")
            String config = gs.getConfig();
            System.out.println(config);
            /*float[] fs = gs.getValues();
             for (float f : fs) {
             System.out.println(f);
             }*/

            demo = new GraphClient(gs, 1000, 700, Float.parseFloat(p.getProperty("frequency")), log);
            demo.init(config);
            demo.run();
        } catch (RemoteException e) {
            System.err.println("GraphClient exception:" + e.toString());
        } catch (FileNotFoundException ex) {
            Logger.getLogger(GraphClient.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(GraphClient.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(GraphClient.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            if (demo != null) {
                demo.close();
            }
        }
        break;
    case 1:
        try {
            demo = new GraphClient(1000, 700, Float.parseFloat(p.getProperty("frequency")));
            demo.init("A^B|Time|Error|-360|360");

            demo.addData(0, 1, 100);
            demo.addData(0, 2, 200);

            demo.addData(1, 1, 50);
            demo.addData(1, 2, 450);

        } catch (FileNotFoundException ex) {
            Logger.getLogger(GraphClient.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(GraphClient.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(GraphClient.class.getName()).log(Level.SEVERE, null, ex);
        }
        break;
    }

}

From source file:org.pegadi.client.ApplicationLauncher.java

public static void main(String[] args) {
    com.sun.net.ssl.internal.ssl.Provider provider = new com.sun.net.ssl.internal.ssl.Provider();
    java.security.Security.addProvider(provider);
    setAllPermissions();/*w ww. j a  va 2 s .  c o  m*/
    /**
     * If we are on Apples operating system, we would like to use the screen
     * menu bar It is the first property we set in our main method. This is
     * to make sure that the property is set before awt is loaded.
     */
    if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
    }
    Logger log = LoggerFactory.getLogger(ApplicationLauncher.class);
    /**
     * Making sure default L&F is System
     */
    if (!UIManager.getLookAndFeel().getName().equals(UIManager.getSystemLookAndFeelClassName())) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            log.warn("Unable to change L&F to System", e);
        }
    }

    long start = System.currentTimeMillis();

    // Splash
    Splash splash = new Splash("/images/splash.png");
    splash.setVisible(true);

    splash.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "org/pegadi/client/client-context.xml");
    closeContextOnShutdown(context);

    long timeToLogin = System.currentTimeMillis() - start;
    log.info("Connected OK after {} ms", timeToLogin);
    log.info("Java Version {}", System.getProperty("java.version"));

    splash.dispose();
}

From source file:org.openspaces.focalserver.FocalServer.java

/**
 * Install a Grant All security manager//  w w w  .  j a  v  a 2s  .  com
 */
private static void installSecurityManager() {
    System.setSecurityManager(new RMISecurityManager() {
        public void checkPermission(Permission perm) {

        }

        public void checkPermission(Permission perm, Object context) {

        }
    });
}

From source file:com.symbian.driver.remoting.master.TestMaster.java

/**
 * /*w  w w  .  j av a2  s .co m*/
 */
public TestMaster() {
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }
}

From source file:edu.clemson.cs.nestbed.server.Server.java

public static void main(String[] args) throws Exception {
    RMI_BASE_URL = System.getProperty("testbed.rmi.baseurl");

    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }/*www. j  a v  a2 s. co m*/

    PropertyConfigurator.configure(Server.class.getClassLoader().getResource("serverLog.conf"));

    try {
        Server server = new Server();
    } catch (RemoteException e) {
        log.fatal("Remote Exception occured!", e);
        System.exit(1);
    }
}

From source file:com.symbian.driver.remoting.client.TestClient.java

/**
 * // w  ww  . j a v  a2 s . c o m
 */
public TestClient() {
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }
}

From source file:com.vmware.identity.idm.server.IdmServer.java

/**
 * Initialize the IDM service.//from  www  .  j a v  a2  s.c o m
 *
 * @throws Exception when something goes wrong with initialization.
 */
private static void initialize() throws Exception {
    try (IDiagnosticsContextScope diagCtxt = DiagnosticsContextFactory.createContext("IDM Startup", "")) {
        logger.info("Starting IDM Server...");
        logger.debug("Creating RMI registry on port {}", Tenant.RMI_PORT);

        boolean allowRemoteConnections = Boolean
                .parseBoolean(System.getProperty(ALLOW_REMOTE_PROPERTY, "false"));

        if (allowRemoteConnections) {
            logger.warn("RMI registry is allowing remote connections!");
            registry = LocateRegistry.createRegistry(Tenant.RMI_PORT);
        } else {
            logger.debug("RMI registry is restricted to the localhost");
            RMIClientSocketFactory csf = RMISocketFactory.getDefaultSocketFactory();
            RMIServerSocketFactory ssf = new LocalRMIServerSocketFactory();
            registry = LocateRegistry.createRegistry(Tenant.RMI_PORT, csf, ssf);
        }

        // Assign a security manager, in the event that dynamic classes are loaded
        if (System.getSecurityManager() == null) {
            logger.debug("Creating RMI Security Manager...");
            System.setSecurityManager(new RMISecurityManager());
        }

        logger.debug("Creating Config Store factory...");
        IConfigStoreFactory cfgStoreFactory = new ConfigStoreFactory();

        logger.debug("Creating Identity Provider factory...");
        IProviderFactory providerFactory = new ProviderFactory();

        logger.debug("Checking VMware Directory Service...");
        ServerUtils.check_directory_service();

        logger.debug("Setting system properties...");
        System.setProperties(new ThreadLocalProperties(System.getProperties()));

        logger.debug("Creating Identity Manager instance...");
        manager = new IdentityManager(cfgStoreFactory, providerFactory);

        String rmiAddress = String.format("rmi://localhost:%d/%s", Tenant.RMI_PORT, IDENTITY_MANAGER_BIND_NAME);
        logger.debug("Binding to RMI address '{}'", rmiAddress);
        loginManager = new IdmLoginManager(manager);
        ILoginManager stub = (ILoginManager) UnicastRemoteObject.exportObject(loginManager, 0);
        Naming.rebind(rmiAddress, stub);

        startHeartbeat();

        logger.info(VmEvent.SERVER_STARTED, "IDM Server has started");
    } catch (Throwable t) {
        logger.error(VmEvent.SERVER_FAILED_TOSTART, "IDM Server has failed to start", t);
        throw t;
    }
}

From source file:org.red5.server.war.RootContextLoaderServlet.java

protected void initRegistry(ServletContext ctx) {
    Registry r = null;/*from  w w w  .  ja v a2 s. c  o m*/
    try {
        Object o = ctx.getInitParameter("rmiPort");
        if (o != null) {
            rmiPort = Integer.valueOf((String) o);
        }
        if (System.getSecurityManager() != null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        // lookup the registry
        r = LocateRegistry.getRegistry(rmiPort);
        // ensure we are not already registered with the registry
        for (String regName : r.list()) {
            logger.debug("Registry entry: " + regName);
        }
    } catch (RemoteException re) {
        logger.info("RMI Registry server was not found on port " + rmiPort);
        // if we didnt find the registry and the user wants it created
        try {
            logger.info("Starting an internal RMI registry");
            // create registry for rmi
            r = LocateRegistry.createRegistry(rmiPort);
        } catch (RemoteException e) {
            logger.info("RMI Registry server was not started on port " + rmiPort);
        }

    }
}

From source file:org.apache.axis.providers.java.RMIProvider.java

/**
 * Return a object which implements the service.
 * //from  w ww  . j  a va2 s .co m
 * @param msgContext the message context
 * @param clsName The JNDI name of the EJB home class
 * @return an object that implements the service
 */
protected Object makeNewServiceObject(MessageContext msgContext, String clsName) throws Exception {
    // Read deployment descriptor options
    String namingLookup = getStrOption(OPTION_NAMING_LOOKUP, msgContext.getService());
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }
    Object targetObject = Naming.lookup(namingLookup);
    return targetObject;
}