List of usage examples for java.lang System getSecurityManager
public static SecurityManager getSecurityManager()
From source file:Main.java
public static void main(String[] args) throws Exception { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); }/*from w w w . j a va 2s . co m*/ }
From source file:Main.java
public static void main(String[] args) { SecurityManager s = System.getSecurityManager(); if (s == null) { System.out.println("SecurityManager not established!"); }/* ww w.ja va 2 s. c o m*/ }
From source file:MainClass.java
public static void main(String args[]) throws Exception { SecurityManager sm = System.getSecurityManager(); if (sm != null) { FilePermission fp = new FilePermission("c:\\autoexec.bat", "read"); sm.checkPermission(fp);//from w w w . j a v a 2s .c o m } if (sm != null) { AWTPermission ap = new AWTPermission("accessClipboard"); sm.checkPermission(ap); } System.out.println("Has AWTPermission to access AWT Clipboard"); }
From source file:org.pepstock.jem.junit.test.antutils.java.TrySecurity.java
/** * //from w w w. j a v a 2s. c o m * @param args * @throws Exception */ public static void main(String[] args) throws Exception { String what = null; try { what = "CHANGE SECURITY MANAGER!"; // gry to change security manager System.setSecurityManager(null); } catch (Exception e) { e.printStackTrace(); try { what = "CHANGE FIELD OF SECURITY MANAGER!"; SecurityManager sm = System.getSecurityManager(); Field f = sm.getClass().getField("isAdministrator"); System.err.println(FieldUtils.readField(f, sm, true)); } catch (Exception e1) { e1.printStackTrace(); return; } } throw new SecurityException("Securitymanager is not secure: " + what); }
From source file:client.ComputePi.java
public static void main(String args[]) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); }/*from w w w. jav a 2 s . co m*/ try { String name = "Compute"; Registry registry = LocateRegistry.getRegistry(args[0]); Compute comp = (Compute) registry.lookup(name); Pi task = new Pi(Integer.parseInt(args[1])); BigDecimal pi = comp.executeTask(task); System.out.println(pi); } catch (Exception e) { System.err.println("ComputePi exception:"); e.printStackTrace(); } }
From source file:azkaban.soloserver.AzkabanSingleServer.java
public static void main(String[] args) throws Exception { log.info("Starting Azkaban Server"); if (System.getSecurityManager() == null) { Policy.setPolicy(new Policy() { @Override/* w ww . j a v a2 s . co m*/ public boolean implies(final ProtectionDomain domain, final Permission permission) { return true; // allow all } }); System.setSecurityManager(new SecurityManager()); } if (args.length == 0) { args = prepareDefaultConf(); } final Props props = AzkabanServer.loadProps(args); if (props == null) { log.error("Properties not found. Need it to connect to the db."); log.error("Exiting..."); return; } if (props.getBoolean(AzkabanDatabaseSetup.DATABASE_CHECK_VERSION, true)) { final boolean updateDB = props.getBoolean(AzkabanDatabaseSetup.DATABASE_AUTO_UPDATE_TABLES, true); final String scriptDir = props.getString(AzkabanDatabaseSetup.DATABASE_SQL_SCRIPT_DIR, "sql"); AzkabanDatabaseUpdater.runDatabaseUpdater(props, scriptDir, updateDB); } /* Initialize Guice Injector */ final Injector injector = Guice.createInjector(new AzkabanCommonModule(props), new AzkabanWebServerModule(), new AzkabanExecServerModule()); SERVICE_PROVIDER.setInjector(injector); /* Launch server */ injector.getInstance(AzkabanSingleServer.class).launch(); }
From source file:engine.ComputeEngine.java
public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); }//from w w w. j a v a2s . c o m try { String name = "Compute"; Compute engine = new ComputeEngine(); Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0); Registry registry = LocateRegistry.getRegistry(); registry.rebind(name, stub); System.out.println("ComputeEngine bound"); } catch (Exception e) { System.err.println("ComputeEngine exception:"); e.printStackTrace(); } }
From source file:org.kchine.rpf.MainServer.java
public static void main(String[] args) throws Exception { PoolUtils.initLog4J();// ww w . ja v a 2 s . c o m PoolUtils.ensurePublicIPIsUsedForRMI(); PoolUtils.noGui(); try { if (System.getSecurityManager() == null) { System.setSecurityManager(new YesSecurityManager()); } boolean isNodeProvided = System.getProperty("node") != null && !System.getProperty("node").equals(""); if (isNodeProvided) { NodeDataDB nodeData = null; try { rmiRegistry = ServerDefaults.getRmiRegistry(); nodeData = ((DBLayerInterface) rmiRegistry) .getNodeData("NODE_NAME='" + System.getProperty("node") + "'").elementAt(0); } catch (Exception e) { log.info("Couldn't retrieve Node Info for node <" + System.getProperty("node") + ">"); e.printStackTrace(); return; } System.setProperty("autoname", "true"); _servantPoolPrefix = nodeData.getPoolPrefix(); System.out.println("nodedata:" + nodeData); } if (System.getProperty("autoname") != null && System.getProperty("autoname").equalsIgnoreCase("true")) { log.info("Instantiating " + _mainServantClassName + " with autonaming, prefix " + _servantPoolPrefix); servantName = null; } else { // no autonaming, check the name here if (System.getProperty("name") != null && !System.getProperty("name").equals("")) { servantName = System.getProperty("name"); } log.info("Instantiating " + _mainServantClassName + " with name " + servantName + " , prefix " + _servantPoolPrefix); } if (rmiRegistry == null) rmiRegistry = ServerDefaults.getRmiRegistry(); System.out.println("### code base:" + System.getProperty("java.rmi.server.codebase")); ClassLoader cl = new URLClassLoader(PoolUtils.getURLS(System.getProperty("java.rmi.server.codebase")), MainServer.class.getClassLoader()); Thread.currentThread().setContextClassLoader(cl); System.out.println(Arrays.toString(PoolUtils.getURLS(System.getProperty("java.rmi.server.codebase")))); mainServantClass = cl.loadClass(_mainServantClassName); boolean isPrivateServant = !isNodeProvided && ((System.getProperty("private") != null && System.getProperty("private").equalsIgnoreCase("true"))); String servantCreationListenerStub = System.getProperty("listener.stub"); if (servantCreationListenerStub != null && !servantCreationListenerStub.equals("")) { servantCreationListener = (ServantCreationListener) PoolUtils .hexToObject(servantCreationListenerStub); } if (!isPrivateServant) { mservant = (ManagedServant) mainServantClass .getConstructor(new Class[] { String.class, String.class, Registry.class }) .newInstance(new Object[] { servantName, _servantPoolPrefix, rmiRegistry }); } else { mservant = (ManagedServant) mainServantClass .getConstructor(new Class[] { String.class, String.class, Registry.class }) .newInstance(new Object[] { null, "PRIVATE_", rmiRegistry }); } //System.out.println("clone:"+mservant.cloneServer()); if (servantCreationListener != null) { PoolUtils.callBack(servantCreationListener, mservant, null); } String sname = mservant.getServantName(); log.info("sname :::" + sname); if (rmiRegistry instanceof DBLayerInterface) { if (System.getProperty("node") != null && !System.getProperty("node").equalsIgnoreCase("")) { ((DBLayerInterface) rmiRegistry).updateServantNodeName(sname, System.getProperty("node")); } else { Vector<NodeDataDB> nodes = ((DBLayerInterface) rmiRegistry).getNodeData(""); for (int i = 0; i < nodes.size(); ++i) { String nodeName = nodes.elementAt(i).getNodeName(); String nodeIp = nodes.elementAt(i).getHostIp(); String nodePrefix = nodes.elementAt(i).getPoolPrefix(); if (sname.startsWith(nodePrefix) && nodeIp.equals(PoolUtils.getHostIp())) { ((DBLayerInterface) rmiRegistry).updateServantNodeName(sname, nodeName); break; } } } HashMap<String, Object> attributes = new HashMap<String, Object>(); Enumeration<Object> sysPropKeys = (Enumeration<Object>) System.getProperties().keys(); while (sysPropKeys.hasMoreElements()) { String key = (String) sysPropKeys.nextElement(); if (key.startsWith("attr.")) { attributes.put(key, System.getProperty(key)); } } ((DBLayerInterface) rmiRegistry).updateServantAttributes(sname, attributes); } //log.info("*************************$$$$$$$$$$$$"); log.info("Servant " + sname + " instantiated successfully."); } catch (InvocationTargetException ite) { if (servantCreationListener != null) { PoolUtils.callBack(servantCreationListener, null, new RemoteException("", ite.getTargetException())); } throw new Exception(PoolUtils.getStackTraceAsString(ite.getTargetException())); } catch (Exception e) { log.info("----------------------"); log.info(PoolUtils.getStackTraceAsString(e)); e.printStackTrace(); log.error(e); if (servantCreationListener != null) { PoolUtils.callBack(servantCreationListener, null, new RemoteException("", e)); } System.exit(1); } }
From source file:edu.clemson.cs.nestbed.client.Client.java
public static void main(String[] args) throws Exception { /*//from w ww .j a va 2 s .co 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:edu.cornell.med.icb.R.RConfigurationServer.java
public static void main(final String[] args) throws RemoteException { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); }//from ww w . j ava2s . c o m final String name = "RConfiguration"; final RConfiguration engine = new RConfigurationServer(); final RConfiguration stub = (RConfiguration) UnicastRemoteObject.exportObject(engine, 0); final Registry registry = LocateRegistry.getRegistry(); System.out.println(ArrayUtils.toString(registry.list())); registry.rebind(name, stub); System.out.println("RConfiguration bound"); }