List of usage examples for java.lang System setSecurityManager
public static void setSecurityManager(SecurityManager sm)
From source file:org.firstopen.singularity.admin.view.ECSpecBean.java
public ECSpecBean(String name) { try {/*from w w w . java 2 s .com*/ if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } InitialContext jndiContext = JNDIUtil.getInitialContext(); Object objref = jndiContext.lookup("jnp://localhost:1099/ejb/ale/AleSLSB"); AleSLSBHome aleSLSBHome = (AleSLSBHome) PortableRemoteObject.narrow(objref, AleSLSBHome.class); aSLSB = aleSLSBHome.create(); createLogicalDeviceSelectList(); createECSpecSelectList(); } catch (Exception e) { log.error("can't create ECSpecBean"); /* * can't recover wrap in RuntimeException */ throw new InfrastructureException(e); } }
From source file:org.kawanfw.file.servlet.ServerFileDispatch.java
/** * NOT USED ANYMORE//from ww w. j av a2 s . c o m * Install the Security Manager that restricts FileFilter and FilenameFilter * to write/delete files. * @param fileConfigurator the file configurator in use */ @SuppressWarnings("unused") private void installSecurityManager(FileConfigurator fileConfigurator) { // Ok, install our security manager if (System.getSecurityManager() == null) { securityManager = new KawanfwSecurityManager(); System.setSecurityManager(securityManager); } }
From source file:org.kchine.r.server.http.frontend.CommandServlet.java
public void init(ServletConfig sConfig) throws ServletException { super.init(sConfig); log.info("command servlet init"); if (_rkit == null) { PoolUtils.injectSystemProperties(true); ServerDefaults.init();//from w w w . ja v a 2 s. c o m } PoolUtils.initRmiSocketFactory(); getServletContext().setAttribute("SESSIONS_MAP", new HashMap<String, HttpSession>()); getServletContext().setAttribute("SESSIONS_ATTRIBUTES_MAP", new HashMap<String, HashMap<String, Object>>()); getServletContext().setAttribute("R_SESSIONS", new HashMap<RServices, HttpSession>()); if (System.getSecurityManager() == null) { System.setSecurityManager(new YesSecurityManager()); } }
From source file:org.kchine.r.server.http.frontend.RebindServlet.java
public void init(ServletConfig sConfig) throws ServletException { super.init(sConfig); log.info("command servlet init"); PoolUtils.injectSystemProperties(true); ServerDefaults.init();/*from www. j a va 2s . com*/ if (System.getSecurityManager() == null) { System.setSecurityManager(new YesSecurityManager()); } }
From source file:org.kchine.rpf.MainServer.java
public static void main(String[] args) throws Exception { PoolUtils.initLog4J();//from ww w . ja v a 2 s . c om 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:org.kie.workbench.common.migration.MigrationToolTest.java
@BeforeClass public static void runToolAndCloneProjectRepos() throws GitAPIException { originalSecurityManager = System.getSecurityManager(); System.setSecurityManager(new NoExitSecurityManager()); try {// ww w. j a v a2 s . co m runMigrationTool(); } catch (ExitException e) { assertThat(e.getStatus()).isEqualTo(0); } finally { System.setSecurityManager(originalSecurityManager); } cloneAllProjectRepos(); }
From source file:org.lnicholls.galleon.server.Server.java
public static void setup(ArrayList errors) { System.setProperty("os.user.home", System.getProperty("user.home")); System.setProperty("http.agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); try {/*ww w . jav a 2 s. c o m*/ File file = new File("."); String root = file.getAbsolutePath() + "/.."; if (System.getProperty("root") == null) System.setProperty("root", root); else root = System.getProperty("root"); File check = new File(System.getProperty("root")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: root=" + System.getProperty("root")); System.setProperty("user.home", System.getProperty("root")); if (System.getProperty("bin") == null) System.setProperty("bin", root + "/bin"); check = new File(System.getProperty("bin")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: bin=" + System.getProperty("bin")); if (System.getProperty("conf") == null) System.setProperty("conf", root + "/conf"); check = new File(System.getProperty("conf")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: conf=" + System.getProperty("conf")); if (System.getProperty("cache") == null) System.setProperty("cache", root + "/data"); check = new File(System.getProperty("cache")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: cache=" + System.getProperty("cache")); if (System.getProperty("data") == null) System.setProperty("data", root + "/data"); check = new File(System.getProperty("data")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: data=" + System.getProperty("data")); if (System.getProperty("apps") == null) System.setProperty("apps", root + "/apps"); check = new File(System.getProperty("apps")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: apps=" + System.getProperty("apps")); if (System.getProperty("hme") == null) System.setProperty("hme", root + "/hme"); check = new File(System.getProperty("hme")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: hme=" + System.getProperty("hme")); if (System.getProperty("skins") == null) System.setProperty("skins", root + "/skins"); check = new File(System.getProperty("skins")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: skins=" + System.getProperty("skins")); if (System.getProperty("logs") == null) System.setProperty("logs", root + "/logs"); check = new File(System.getProperty("logs")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: logs=" + System.getProperty("logs")); if (System.getProperty("demo") != null) mDemoMode = Boolean.valueOf(System.getProperty("demo")).booleanValue(); if (System.getProperty("remoteHost") != null) { System.setSecurityManager(new RMISecurityManager() { public void checkConnect(String host, int port) { if (host != null && host.equals(System.getProperty("remoteHost"))) return; throw new SecurityException("Invalid remote host: " + host); } public void checkConnect(String host, int port, Object context) { if (host != null && host.equals(System.getProperty("remoteHost"))) return; throw new SecurityException("Invalid remote host: " + host); } }); } } catch (Exception ex) { Tools.logException(Server.class, ex); } }
From source file:org.mule.transport.rmi.RmiConnector.java
@Override protected void doInitialise() throws InitialisationException { if (securityPolicy != null) { System.setProperty("java.security.policy", securityPolicy); }//from w w w.j a v a 2s .c o m // Set security manager if (securityManager != null) { System.setSecurityManager(securityManager); } initJndiContext(); }
From source file:org.mule.transport.rmi.RmiMessageReceiver.java
@SuppressWarnings("unchecked") @Override// ww w . j a v a2s . c o m protected void doConnect() throws Exception { System.setProperty("java.security.policy", connector.getSecurityPolicy()); // Set security manager if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } // Get methodName String methodName = MapUtils.getString(endpoint.getEndpointURI().getParams(), MuleProperties.MULE_METHOD_PROPERTY, null); if (null == methodName) { methodName = (String) endpoint.getProperty(MuleProperties.MULE_METHOD_PROPERTY); if (null == methodName) { throw new ConnectException(RmiMessages.messageParamServiceMethodNotSet(), this); } } // Get remoteObject remoteObject = connector.getRemoteObject(getEndpoint()); // Set methodArguments List<Object> args = (List<Object>) endpoint.getProperty(RmiConnector.PROPERTY_SERVICE_METHOD_PARAMS_LIST); Class[] argTypes = new Class[] {}; if (args == null) { logger.info(RmiConnector.PROPERTY_SERVICE_METHOD_PARAMS_LIST + " not set on endpoint, assuming method call has no arguments"); methodArguments = ClassUtils.NO_ARGS; } else { argTypes = connector.getArgTypes(endpoint.getProperty(RmiConnector.PROPERTY_SERVICE_METHOD_PARAM_TYPES), RequestContext.getEvent()); methodArguments = new Object[args.size()]; methodArguments = args.toArray(methodArguments); } // Set invokeMethod invokeMethod = remoteObject.getClass().getMethod(methodName, argTypes); }
From source file:org.ngrinder.sm.SecurityManagerTest.java
@Before public void init() { System.setProperty("ngrinder.exec.path", PATH); System.setProperty("ngrinder.etc.hosts", "10.34.64.36,CN14748-D-1:127.0.0.1,localhost:127.0.0.1"); System.setProperty("ngrinder.console.ip", "10.34.63.53"); preSecurityManager = System.getSecurityManager(); System.setSecurityManager(new MockNGrinderSecurityManager()); }