/** * This method is called upon plug-in activation * * @param context * @throws Exception */ public void start(BundleContext context) throws Exception { super.start(context); iconsUrl = context.getBundle().getEntry(ICONS_PATH); Authenticator.setDefault(new UDIGAuthenticator()); /* * TODO Further code can nuke the previously set authenticator. Proper security access * should be configured to prevent this. */ disableCerts(); try { loadVersion(); java.lang.System.setProperty( "http.agent", "uDig " + getVersion() + " (http://udig.refractions.net)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ java.lang.System.setProperty( "https.agent", "uDig " + getVersion() + " (http://udig.refractions.net)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } catch (Throwable e) { log("error determining version", e); // $NON-NLS-1$ } }
/** * Setup proxy based on JAVA_OPTS if necessary */ static boolean isProxyValid() { //Setting up proxy if necessary System.setProperty("java.net.useSystemProxies","true"); List<Proxy> proxies; try { proxies = ProxySelector.getDefault().select(new URI("http://www.google.com")); } catch ( URISyntaxException e) { log.error("Failed to create URI." + e); return false; } for (Proxy proxy : proxies) { if (proxy.type() == Proxy.Type.DIRECT) { log.info("Proxy is DIRECT CONNECTION"); return true; } log.info("Proxy setting: host=" + System.getProperty("http.proxyHost") + "port=" + System.getProperty("http.proxyPort") + "user="******"http.proxyUser") + "password="******"http.proxyPassword")); if (System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null && System.getProperty("http.proxyUser") != null ) return true; log.error("Proxy is incorrect: host=" + System.getProperty("http.proxyHost") + "port=" + System.getProperty("http.proxyPort") + "user="******"http.proxyUser") + "password="******"http.proxyPassword")); return false; } return false; }
private static void loadEnvironment(String[] args) { final String defaultConfDir = getProperty("dash.application.conf.dir"); final String defaultConfFile = (defaultConfDir != null ? defaultConfDir + File.separatorChar : "") + "conf.yml"; ArgumentParser parser = ArgumentParsers.newArgumentParser("Dash", true) .description("Runs a performance test mix.") .version("${prog} " + Version.id()) .epilog("Dash is a free software under Apache License Version 2.0"); parser .addArgument("-c", "--conf") .help("the config file containing the test specification to run (default: ../conf/conf.yml") .required(false) .setDefault(new File(defaultConfFile)) .type(File.class); parser .addArgument("-t", "--test") .help("the name of the test to run") .required(true) .type(String.class); parser .addArgument("-v", "--version") .help("print the version number") .action(Arguments.version()); try { YamlEnv yamlEnv = new YamlEnv(); Namespace namespace = parser.parseArgs(args); @SuppressWarnings("unchecked") HashMap<String, Object> env = (HashMap<String, Object>) yamlEnv.loadProperties((File) namespace.get("conf")); String test = namespace.getString("test"); @SuppressWarnings("unchecked") HashMap<String, Object> testSpec = (HashMap<String, Object>) env.get(test); if (testSpec == null) { System.err.println("Test spec (" + test + ") does not exist in the config file."); throw new Error(); // todo: message or log or exit } for (Map.Entry<String, Object> entry : testSpec.entrySet()) { if (entry.getValue() != null) { System.setProperty(entry.getKey(), entry.getValue().toString()); } } } catch (ArgumentParserException e) { parser.handleError(e); } catch (IOException e) { e.printStackTrace(); } }
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT < 11) { java.lang.System.setProperty("java.net.preferIPv4Stack", "true"); java.lang.System.setProperty("java.net.preferIPv6Addresses", "false"); } applicationContext = getApplicationContext(); NativeLoader.initNativeLibs(ApplicationLoader.applicationContext); if (Build.VERSION.SDK_INT >= 14) { new ForegroundDetector(this); } applicationHandler = new Handler(applicationContext.getMainLooper()); startPushService(); }
@Test public void testConfigurationWithMessageFilesCofiguredByEnvironment() { setProperty(MESSAGE_FILES_SYSTEM_PROPERTY, "arq1, arq2"); assertEquals( TestMessageSource.class, getConfiguration().getConfiguredMessagesSource().getClass()); assertEquals(3, getConfiguration().getConfituredMessageFiles().size()); assertTrue(getConfiguration().getConfituredMessageFiles().contains(TEST_MESSAGE_FILE)); assertTrue(getConfiguration().getConfituredMessageFiles().contains("arq1")); assertTrue(getConfiguration().getConfituredMessageFiles().contains("arq2")); System.clearProperty(MESSAGE_FILES_SYSTEM_PROPERTY); }
public static java.lang.String initialize( java.lang.String s, java.lang.String s1, java.lang.String s2) { java.lang.String s3 = ""; try { java.lang.System.setProperty( "java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); java.security.Security.addProvider(new Provider()); com.sun.net.ssl.SSLContext sslcontext = com.sun.net.ssl.SSLContext.getInstance("SSL"); randomGenerator = new SecureRandom(); byte abyte0[] = new byte[20]; for (int i = 0; i < 20; i++) { abyte0[i] = (byte) (int) (java.lang.Math.random() * 256D - 128D); } randomGenerator.setSeed(abyte0); if ((new File(s + ".pfx")).exists()) { s = s + ".pfx"; } com.sun.net.ssl.KeyManager akeymanager[] = null; try { if ((new File(s)).exists()) { java.security.KeyStore keystore; if (s.endsWith(".pfx")) { keystore = java.security.KeyStore.getInstance("PKCS12"); } else { keystore = java.security.KeyStore.getInstance("JKS"); } com.sun.net.ssl.KeyManagerFactory keymanagerfactory = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509"); java.io.FileInputStream fileinputstream = new FileInputStream(s); char ac[] = s1.toCharArray(); char ac1[] = s2.toCharArray(); keystore.load(fileinputstream, ac); java.util.Enumeration enumeration = keystore.aliases(); while (enumeration.hasMoreElements()) { java.lang.String s4 = (java.lang.String) enumeration.nextElement(); certificateDescription = certificateDescription + " (" + s4; java.security.cert.Certificate acertificate[] = keystore.getCertificateChain(s4); if (acertificate != null) { int j = 0; while (j < acertificate.length) { java.security.cert.X509Certificate x509certificate = (java.security.cert.X509Certificate) acertificate[j]; certificateDescription = certificateDescription + " (cert " + x509certificate.getSubjectDN() + ", " + x509certificate.getSigAlgName() + ")"; j++; } } } s3 = s3 + "certs: " + certificateDescription + "\n"; keymanagerfactory.init(keystore, ac1); akeymanager = keymanagerfactory.getKeyManagers(); } } catch (java.lang.Exception exception) { exception.printStackTrace(); s3 = s3 + exception.toString(); } sslcontext.init(akeymanager, null, randomGenerator); if (akeymanager != null) { sslServerSocketFactory = sslcontext.getServerSocketFactory(); } sslSocketFactory = sslcontext.getSocketFactory(); } catch (java.lang.Throwable throwable) { throwable.printStackTrace(); s3 = s3 + throwable.toString(); } return s3; }
public void setSystemProperties() { java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); java.lang.System.setProperty("java.vm.vendor", "Oracle Corporation"); java.lang.System.setProperty("java.specification.version", "1.8"); java.lang.System.setProperty( "java.home", "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre"); java.lang.System.setProperty("java.awt.headless", "true"); java.lang.System.setProperty("user.home", "/Users/hhildebrand"); java.lang.System.setProperty("user.dir", "/Users/hhildebrand/git/Ultrastructure/model"); java.lang.System.setProperty( "java.io.tmpdir", "/var/folders/_r/y4_0rwd16zgblwjq7b_tbhk80000gn/T/"); java.lang.System.setProperty("awt.toolkit", "sun.lwawt.macosx.LWCToolkit"); java.lang.System.setProperty("file.encoding", "UTF-8"); java.lang.System.setProperty("file.separator", "/"); java.lang.System.setProperty("java.awt.graphicsenv", "sun.awt.CGraphicsEnvironment"); java.lang.System.setProperty("java.awt.printerjob", "sun.lwawt.macosx.CPrinterJob"); java.lang.System.setProperty( "java.class.path", "/var/folders/_r/y4_0rwd16zgblwjq7b_tbhk80000gn/T/EvoSuite_pathingJar8602748439413877740.jar"); java.lang.System.setProperty("java.class.version", "52.0"); java.lang.System.setProperty( "java.endorsed.dirs", "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/endorsed"); java.lang.System.setProperty( "java.ext.dirs", "/Users/hhildebrand/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"); java.lang.System.setProperty("java.library.path", "lib"); java.lang.System.setProperty("java.runtime.name", "Java(TM) SE Runtime Environment"); java.lang.System.setProperty("java.runtime.version", "1.8.0_45-b14"); java.lang.System.setProperty("java.specification.name", "Java Platform API Specification"); java.lang.System.setProperty("java.specification.vendor", "Oracle Corporation"); java.lang.System.setProperty("java.vendor", "Oracle Corporation"); java.lang.System.setProperty("java.vendor.url", "http://java.oracle.com/"); java.lang.System.setProperty("java.version", "1.8.0_45"); java.lang.System.setProperty("java.vm.info", "mixed mode"); java.lang.System.setProperty("java.vm.name", "Java HotSpot(TM) 64-Bit Server VM"); java.lang.System.setProperty( "java.vm.specification.name", "Java Virtual Machine Specification"); java.lang.System.setProperty("java.vm.specification.vendor", "Oracle Corporation"); java.lang.System.setProperty("java.vm.specification.version", "1.8"); java.lang.System.setProperty("java.vm.version", "25.45-b02"); java.lang.System.setProperty("line.separator", "\n"); java.lang.System.setProperty("os.arch", "x86_64"); java.lang.System.setProperty("os.name", "Mac OS X"); java.lang.System.setProperty("os.version", "10.11.3"); java.lang.System.setProperty("path.separator", ":"); java.lang.System.setProperty("user.country", "US"); java.lang.System.setProperty("user.language", "en"); java.lang.System.setProperty("user.name", "hhildebrand"); java.lang.System.setProperty("user.timezone", "America/Los_Angeles"); }
/** @see javax.servlet.GenericServlet#init() */ @Override public void init() throws ServletException { synchronized (OGCServletController.class) { if (LOG == null) { // hack to figure out and set the context path name // for a laugh, see http://marc.info/?l=tomcat-user&m=109215904113904&w=2 and the related // thread // http://marc.info/?t=109215871400004&r=1&w=2 String path = getServletContext().getRealPath(""); String[] ps = path.split("[/\\\\]"); path = ps[ps.length - 1]; // heuristics are always a charm (and work best for tomcat in this case) if (isDigit(path.charAt(0)) && path.indexOf("-") != -1) { path = path.split("-", 2)[1]; } // note that setting this changes it on a JVM GLOBAL BASIS, so it WILL GET OVERWRITTEN in // subsequent // deegree startups! (However, since the log4j.properties will only be read on startup, this // hack is // useful anyway) setProperty("context.name", path); LOG = getLogger(OGCServletController.class); } } super.init(); LOG.logDebug("Logger for " + this.getClass().getName() + " initialized."); SERVICE_FACTORIES_MAPPINGS.put(CSWHandler.class, "org.deegree.ogcwebservices.csw.CSWFactory"); SERVICE_FACTORIES_MAPPINGS.put( WFSHandler.class, "org.deegree.ogcwebservices.wfs.WFServiceFactory"); SERVICE_FACTORIES_MAPPINGS.put( WCSHandler.class, "org.deegree.ogcwebservices.wcs.WCServiceFactory"); SERVICE_FACTORIES_MAPPINGS.put( WMSHandler.class, "org.deegree.ogcwebservices.wms.WMServiceFactory"); SERVICE_FACTORIES_MAPPINGS.put( WPVSHandler.class, "org.deegree.ogcwebservices.wpvs.WPVServiceFactory"); SERVICE_FACTORIES_MAPPINGS.put( WMPSHandler.class, "org.deegree.ogcwebservices.wmps.WMPServiceFactory"); SERVICE_FACTORIES_MAPPINGS.put( WPSHandler.class, "org.deegree.ogcwebservices.wps.WPServiceFactory"); SERVICE_FACTORIES_MAPPINGS.put( WASSHandler.class, "org.deegree.ogcwebservices.wass.common.WASServiceFactory"); SERVICE_FACTORIES_MAPPINGS.put( WCTSHandler.class, "org.deegree.ogcwebservices.wcts.WCTServiceFactory"); LOG.logInfo("-------------------------------------------------------------------------------"); LOG.logInfo("Starting deegree version " + Version.getVersion()); LOG.logInfo("- context : " + this.getServletContext().getServletContextName()); LOG.logInfo("- real path : " + this.getServletContext().getRealPath("/")); LOG.logInfo("- java version : " + System.getProperty("java.version") + ""); LOG.logInfo( "- dom builder : " + DocumentBuilderFactory.newInstance().getClass().getName() + ""); LOG.logInfo("- xslt builder : " + TransformerFactory.newInstance().getClass().getName() + ""); LOG.logInfo("- system charset : " + CharsetUtils.getSystemCharset()); LOG.logInfo("- default charset: " + Charset.defaultCharset()); LOG.logInfo("- server info : " + this.getServletContext().getServerInfo()); logIfThere("proxyHost"); logIfThere("proxyPort"); logIfThere("noProxyHosts"); logIfThere("nonProxyHosts"); logIfThere("http.proxyHost"); logIfThere("http.proxyPort"); logIfThere("http.noProxyHosts"); logIfThere("http.nonProxyHosts"); logIfThere("ftp.proxyHost"); logIfThere("ftp.proxyPort"); logIfThere("ftp.noProxyHosts"); logIfThere("ftp.nonProxyHosts"); logIfThere("https.proxyHost"); logIfThere("https.proxyPort"); logIfThere("https.noProxyHosts"); logIfThere("https.nonProxyHosts"); try { LOG.logInfo("- ip : " + InetAddress.getLocalHost().getHostAddress()); LOG.logInfo("- host name : " + InetAddress.getLocalHost().getHostName()); LOG.logInfo("- domain name : " + InetAddress.getLocalHost().getCanonicalHostName()); } catch (Exception e) { LOG.logError(e.getMessage(), e); } LOG.logInfo("-------------------------------------------------------------------------------"); this.initServices(getServletContext()); checkServerCompatibility(); LOG.logInfo("-------------------------------------------------------------------------------"); String tmpServiceList = this.getServiceList(); if (tmpServiceList != null && !("".equals(tmpServiceList.trim()))) { LOG.logInfo( "Initialized successfully (context '" + this.getServletContext().getServletContextName() + "'):"); String[] tmpServices = tmpServiceList.split(","); for (String service : tmpServices) { // Added a check for the alternative service name, because it should not be outputed twice // for the csw. if (!OGCRequestFactory.CSW_SERVICE_NAME_EBRIM.toUpperCase().equals(service)) { LOG.logInfo("- " + service); } } } else { LOG.logError( "An Error occured while initializing context '" + this.getServletContext().getServletContextName() + "', no services are available."); } LOG.logInfo("-------------------------------------------------------------------------------"); // Sets the attributes for tomcat -> application.getAttribute(); in jsp sites this.getServletContext().setAttribute("deegree_ogc_services", this.getServiceList()); }
@BeforeClass public static void setup() { setProperty("STANS_SONG", "Total Eclipse of the Heart"); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // finding id on element btnSend = (Button) findViewById(R.id.btnSend); inputLogin = (EditText) findViewById(R.id.txtChatBox); lblWelcome = (TextView) findViewById(R.id.lblWelcome); linearLayout = (LinearLayout) findViewById(R.id.linearLayout); // create new element layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); currentContext = this; // to fix bug when request socket to server and don't forget add android // perminssion internet and android permisiion to network java.lang.System.setProperty("java.net.preferIPv4Stack", "true"); java.lang.System.setProperty("java.net.preferIPv6Addresses", "false"); btnSend.setOnClickListener( new OnClickListener() { public void onClick(View v) { if (btnSend.getText().toString().equals("login")) { ProcessAllSocket processTest = new ProcessAllSocket(currentContext, inputLogin.getText().toString()); processTest.ConnectToSocket(socket, "testActivity"); } else { // showing histori chat from client sendChat( linearLayout, layoutParams, inputLogin.getText().toString(), "Me", TestActivity.this); // send chat to server try { processTest.getSocketIo.emit( "chat", new JSONObject().put("msg", inputLogin.getText().toString())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); }