List of usage examples for org.apache.commons.lang SystemUtils JAVA_VENDOR
String JAVA_VENDOR
To view the source code for org.apache.commons.lang SystemUtils JAVA_VENDOR.
Click Source Link
The java.vendor
System Property.
From source file:SystemUtilsTrial.java
public static void main(String[] args) { System.out.println("1) FILE_SEPARATOR =" + SystemUtils.FILE_SEPARATOR); System.out.println("2) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("3) JAVA_HOME =" + SystemUtils.JAVA_HOME); System.out.println("4) Is 1.3 + =" + SystemUtils.isJavaVersionAtLeast(1.3f)); System.out.println("5) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("6) JAVA_VENDOR =" + SystemUtils.JAVA_VENDOR); System.out.println("7) OS_NAME =" + SystemUtils.OS_NAME); }
From source file:com.enonic.cms.web.boot.BootEnvironment.java
private String getFormattedJvmInfo() { final StringBuilder str = new StringBuilder(); str.append(SystemUtils.JAVA_RUNTIME_NAME).append(" ").append(SystemUtils.JAVA_RUNTIME_VERSION).append(" (") .append(SystemUtils.JAVA_VENDOR).append(")"); return str.toString(); }
From source file:com.yahoo.flowetl.commons.runner.Main.java
/** * Gets some useful runtime info as a map of names -> info. *//*w ww .j av a 2 s . co m*/ private static Map<String, Object> getRuntimeInfo() { Map<String, Object> sysInfo = new TreeMap<String, Object>(); StringBuilder jvminfo = new StringBuilder(); jvminfo.append("Vendor: "); jvminfo.append(SystemUtils.JAVA_VENDOR); jvminfo.append(", Version: "); jvminfo.append(SystemUtils.JAVA_VERSION + " - " + SystemUtils.JAVA_VM_INFO); jvminfo.append(", OS: "); jvminfo.append(SystemUtils.OS_NAME + " (" + SystemUtils.OS_VERSION + " : " + SystemUtils.OS_ARCH + ")"); sysInfo.put(WordUtils.capitalizeFully("jvm"), jvminfo.toString()); sysInfo.put(WordUtils.capitalizeFully("default charset encoding"), DEF_CHAR_SET.name()); String netAdd = NetUtils.getLocalAddress(); if (StringUtils.isEmpty(netAdd)) { netAdd = "????"; } String localName = NetUtils.getLocalHostName(); if (StringUtils.isEmpty(localName)) { localName = "????"; } sysInfo.put(WordUtils.capitalizeFully("network"), localName + " at ip address " + netAdd); String cPath = SystemUtils.JAVA_CLASS_PATH; String linesep = StringEscapeUtils.escapeJava(SystemUtils.LINE_SEPARATOR); sysInfo.put(WordUtils.capitalizeFully("classpath"), cPath); sysInfo.put(WordUtils.capitalizeFully("jvm home"), SystemUtils.JAVA_HOME); sysInfo.put(WordUtils.capitalizeFully("jvm tmpdir"), SystemUtils.JAVA_IO_TMPDIR); sysInfo.put(WordUtils.capitalizeFully("jvm libpath"), SystemUtils.JAVA_LIBRARY_PATH); sysInfo.put(WordUtils.capitalizeFully("line separator"), linesep); sysInfo.put(WordUtils.capitalizeFully("path separator"), StringEscapeUtils.escapeJava(SystemUtils.PATH_SEPARATOR)); sysInfo.put(WordUtils.capitalizeFully("user timezone"), SystemUtils.USER_TIMEZONE); sysInfo.put(WordUtils.capitalizeFully("user home"), SystemUtils.USER_HOME); sysInfo.put(WordUtils.capitalizeFully("user language"), SystemUtils.USER_LANGUAGE); sysInfo.put(WordUtils.capitalizeFully("user name"), SystemUtils.USER_NAME); return sysInfo; }
From source file:org.apache.cocoon.generation.StatusGenerator.java
private void genVMStatus() throws SAXException { AttributesImpl atts = new AttributesImpl(); startGroup("VM"); // BEGIN ClassPath String classpath = SystemUtils.JAVA_CLASS_PATH; if (classpath != null) { List paths = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(classpath, SystemUtils.PATH_SEPARATOR); while (tokenizer.hasMoreTokens()) { paths.add(tokenizer.nextToken()); }//from w w w . j a v a 2 s .co m addMultilineValue("classpath", paths); } // END ClassPath // BEGIN CONTEXT CLASSPATH String contextClassPath = null; try { contextClassPath = (String) this.context.get(Constants.CONTEXT_CLASSPATH); } catch (ContextException e) { // we ignore this } if (contextClassPath != null) { List paths = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(contextClassPath, File.pathSeparator); while (tokenizer.hasMoreTokens()) { paths.add(tokenizer.nextToken()); } addMultilineValue("context-classpath", paths); } // END CONTEXT CLASSPATH // BEGIN Memory status startGroup("Memory"); final long totalMemory = Runtime.getRuntime().totalMemory(); final long freeMemory = Runtime.getRuntime().freeMemory(); addValue("total", String.valueOf(totalMemory)); addValue("used", String.valueOf(totalMemory - freeMemory)); addValue("free", String.valueOf(freeMemory)); endGroup(); // END Memory status // BEGIN JRE startGroup("JRE"); addValue("version", SystemUtils.JAVA_VERSION); atts.clear(); // qName = prefix + ':' + localName atts.addAttribute(XLINK_NS, "type", XLINK_PREFIX + ":type", "CDATA", "simple"); atts.addAttribute(XLINK_NS, "href", XLINK_PREFIX + ":href", "CDATA", SystemUtils.JAVA_VENDOR_URL); addValue("java-vendor", SystemUtils.JAVA_VENDOR, atts); endGroup(); // END JRE // BEGIN Operating system startGroup("Operating System"); addValue("name", SystemUtils.OS_NAME); addValue("architecture", SystemUtils.OS_ARCH); addValue("version", SystemUtils.OS_VERSION); endGroup(); // END operating system // BEGIN Cache if (this.storeJanitor != null) { startGroup("Store Janitor"); // For each element in StoreJanitor Iterator i = this.storeJanitor.iterator(); while (i.hasNext()) { Store store = (Store) i.next(); startGroup( store.getClass().getName() + " (hash = 0x" + Integer.toHexString(store.hashCode()) + ")"); int size = 0; int empty = 0; atts.clear(); atts.addAttribute(NAMESPACE, "name", "name", "CDATA", "cached"); super.contentHandler.startElement(NAMESPACE, "value", "value", atts); atts.clear(); Enumeration e = store.keys(); while (e.hasMoreElements()) { size++; Object key = e.nextElement(); Object val = store.get(key); String line; if (val == null) { empty++; } else { line = key + " (class: " + val.getClass().getName() + ")"; super.contentHandler.startElement(NAMESPACE, "line", "line", atts); super.contentHandler.characters(line.toCharArray(), 0, line.length()); super.contentHandler.endElement(NAMESPACE, "line", "line"); } } if (size == 0) { super.contentHandler.startElement(NAMESPACE, "line", "line", atts); String value = "[empty]"; super.contentHandler.characters(value.toCharArray(), 0, value.length()); super.contentHandler.endElement(NAMESPACE, "line", "line"); } super.contentHandler.endElement(NAMESPACE, "value", "value"); addValue("size", String.valueOf(size) + " items in cache (" + empty + " are empty)"); endGroup(); } endGroup(); } if (this.storePersistent != null) { startGroup(storePersistent.getClass().getName() + " (hash = 0x" + Integer.toHexString(storePersistent.hashCode()) + ")"); int size = 0; int empty = 0; atts.clear(); atts.addAttribute(NAMESPACE, "name", "name", "CDATA", "cached"); super.contentHandler.startElement(NAMESPACE, "value", "value", atts); atts.clear(); Enumeration e = this.storePersistent.keys(); while (e.hasMoreElements()) { size++; Object key = e.nextElement(); Object val = storePersistent.get(key); String line; if (val == null) { empty++; } else { line = key + " (class: " + val.getClass().getName() + ")"; super.contentHandler.startElement(NAMESPACE, "line", "line", atts); super.contentHandler.characters(line.toCharArray(), 0, line.length()); super.contentHandler.endElement(NAMESPACE, "line", "line"); } } if (size == 0) { super.contentHandler.startElement(NAMESPACE, "line", "line", atts); String value = "[empty]"; super.contentHandler.characters(value.toCharArray(), 0, value.length()); super.contentHandler.endElement(NAMESPACE, "line", "line"); } super.contentHandler.endElement(NAMESPACE, "value", "value"); addValue("size", size + " items in cache (" + empty + " are empty)"); endGroup(); } // END Cache endGroup(); }
From source file:org.jboss.as.test.integration.security.common.Krb5LoginConfiguration.java
public static Map<String, String> getOptions(final String principal, final File keyTab, final boolean acceptor) { final Map<String, String> res = new HashMap<String, String>(); if (SystemUtils.JAVA_VENDOR.startsWith("IBM")) { if (keyTab != null) { res.put("useKeytab", keyTab.toURI().toString()); }/* w w w. j a v a2 s . c om*/ if (acceptor) { res.put("credsType", "acceptor"); } else { res.put("noAddress", "true"); } } else { if (keyTab != null) { res.put("keyTab", keyTab.getAbsolutePath()); res.put("doNotPrompt", "true"); res.put("useKeyTab", "true"); } if (acceptor) { res.put("storeKey", "true"); } } res.put("refreshKrb5Config", "true"); res.put("debug", "true"); if (principal != null) { res.put("principal", principal); } return res; }
From source file:org.jboss.as.test.integration.security.common.Krb5LoginConfiguration.java
public static String getLoginModule() { if (SystemUtils.JAVA_VENDOR.startsWith("IBM")) { return "com.ibm.security.auth.module.Krb5LoginModule"; } else {//w w w. j a va 2 s . c o m return "com.sun.security.auth.module.Krb5LoginModule"; } }
From source file:org.jboss.as.test.integration.security.loginmodules.negotiation.PropagateIdentityServlet.java
/** * Retrieves a {@link GSSCredential} from {@link DelegationCredentialContext#getDelegCredential()}. If it's null error 401 * (SC_UNAUTHORIZED) is returned, otherwise {@link GSSTestClient} is used retrieve name of propagated identity from * {@link GSSTestServer}./* w w w . ja v a2 s .c om*/ * * @param req * @param resp * @throws ServletException * @throws IOException * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { LOGGER.debug("New request coming."); final GSSCredential credential = DelegationCredentialContext.getDelegCredential(); if (credential == null) { resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, "GSSCredential not found"); } else { resp.setContentType("text/plain"); final PrintWriter writer = resp.getWriter(); final GSSTestClient client = new GSSTestClient(StringUtils.strip(req.getServerName(), "[]"), GSSTestConstants.PORT, GSSTestConstants.PRINCIPAL); LOGGER.trace("Client for identity propagation created: " + client); try { writer.print(client.getName(credential)); } catch (GSSException e) { if (StringUtils.startsWith(SystemUtils.JAVA_VENDOR, "IBM") && e.getMessage().contains("message: Incorrect net address")) { writer.print("jduke@JBOSS.ORG"); } else { throw new ServletException("Propagation failed.", e); } } } }
From source file:org.jboss.as.test.manualmode.web.ssl.AbstractCertificateLoginModuleTestCase.java
/** * Testing access to HTTPS connector which have configured truststore with * trusted certificates. Client with trusted certificate is allowed to * access both secured/unsecured resource. Client with untrusted certificate * can only access unprotected resources. * * @throws Exception// ww w . ja va2 s . c om */ public void testLoginWithCertificate(String appName) throws Exception { Assume.assumeFalse( SystemUtils.IS_JAVA_1_6 && SystemUtils.JAVA_VENDOR.toUpperCase(Locale.ENGLISH).contains("IBM")); final URL printPrincipalUrl = getServletUrl(HTTPS_PORT, appName, PrincipalPrintingServlet.SERVLET_PATH); final URL securedUrl = getServletUrl(HTTPS_PORT, appName, SECURED_SERVLET_WITH_SESSION); final URL unsecuredUrl = getServletUrl(HTTPS_PORT, appName, SimpleServlet.SERVLET_PATH); final HttpClient httpClient = getHttpsClient(CLIENT_KEYSTORE_FILE); final HttpClient httpClientUntrusted = getHttpsClient(UNTRUSTED_KEYSTORE_FILE); try { makeCallWithHttpClient(printPrincipalUrl, httpClient, HttpServletResponse.SC_FORBIDDEN); String responseBody = makeCallWithHttpClient(securedUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Secured page was not reached", SimpleSecuredServlet.RESPONSE_BODY, responseBody); String principal = makeCallWithHttpClient(printPrincipalUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Unexpected principal", "cn=client", principal.toLowerCase()); responseBody = makeCallWithHttpClient(unsecuredUrl, httpClientUntrusted, HttpServletResponse.SC_OK); assertEquals("Secured page was not reached", SimpleServlet.RESPONSE_BODY, responseBody); try { makeCallWithHttpClient(securedUrl, httpClientUntrusted, HttpServletResponse.SC_FORBIDDEN); } catch (SSLHandshakeException e) { // OK } catch (java.net.SocketException se) { // OK - on windows usually fails with this one } } finally { httpClient.getConnectionManager().shutdown(); httpClientUntrusted.getConnectionManager().shutdown(); } }
From source file:org.jboss.as.test.manualmode.web.ssl.HTTPSWebConnectorTestCase.java
/** * @test.tsfi tsfi.keystore.file// ww w .java2 s .com * @test.tsfi tsfi.truststore.file * @test.objective Testing default HTTPs connector with verify-client attribute set to "false". The CLIENT-CERT * authentication (BaseCertLoginModule) is configured for this test. Trusted client is allowed to access * both secured/unsecured resource. Untrusted client can only access unprotected resources. * @test.expectedResult Trusted client has access to protected and unprotected resources. Untrusted client has only access * to unprotected resources. * @throws Exception */ @Test @InSequence(1) public void testNonVerifyingConnector() throws Exception { Assume.assumeFalse( SystemUtils.IS_JAVA_1_6 && SystemUtils.JAVA_VENDOR.toUpperCase(Locale.ENGLISH).contains("IBM")); final URL printPrincipalUrl = getServletUrl(HTTPS_PORT_VERIFY_FALSE, PrincipalPrintingServlet.SERVLET_PATH); final URL securedUrl = getServletUrl(HTTPS_PORT_VERIFY_FALSE, SECURED_SERVLET_WITH_SESSION); final URL unsecuredUrl = getServletUrl(HTTPS_PORT_VERIFY_FALSE, SimpleServlet.SERVLET_PATH); final HttpClient httpClient = getHttpClient(CLIENT_KEYSTORE_FILE); final HttpClient httpClientUntrusted = getHttpClient(UNTRUSTED_KEYSTORE_FILE); try { makeCallWithHttpClient(printPrincipalUrl, httpClient, HttpServletResponse.SC_FORBIDDEN); String responseBody = makeCallWithHttpClient(securedUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Secured page was not reached", SimpleSecuredServlet.RESPONSE_BODY, responseBody); String principal = makeCallWithHttpClient(printPrincipalUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Unexpected principal", "cn=client", principal.toLowerCase()); responseBody = makeCallWithHttpClient(unsecuredUrl, httpClientUntrusted, HttpServletResponse.SC_OK); assertEquals("Secured page was not reached", SimpleServlet.RESPONSE_BODY, responseBody); try { makeCallWithHttpClient(securedUrl, httpClientUntrusted, HttpServletResponse.SC_FORBIDDEN); } catch (SSLHandshakeException e) { // OK } catch (java.net.SocketException se) { // OK - on windows usually fails with this one } } finally { httpClient.getConnectionManager().shutdown(); httpClientUntrusted.getConnectionManager().shutdown(); } }
From source file:org.jboss.as.test.manualmode.web.ssl.HTTPSWebConnectorTestCase.java
/** * @test.tsfi tsfi.keystore.file//from www . j av a2s . co m * @test.tsfi tsfi.truststore.file * @test.objective Testing default HTTPs connector with verify-client attribute set to "want". The CLIENT-CERT * authentication (BaseCertLoginModule) is configured for this test. Trusted client is allowed to access * both secured/unsecured resource. Untrusted client can only access unprotected resources. * @test.expectedResult Trusted client has access to protected and unprotected resources. Untrusted client has only access * to unprotected resources. * @throws Exception */ @Test @InSequence(1) public void testWantVerifyConnector() throws Exception { Assume.assumeFalse( SystemUtils.IS_JAVA_1_6 && SystemUtils.JAVA_VENDOR.toUpperCase(Locale.ENGLISH).contains("IBM")); final URL printPrincipalUrl = getServletUrl(HTTPS_PORT_VERIFY_WANT, PrincipalPrintingServlet.SERVLET_PATH); final URL securedUrl = getServletUrl(HTTPS_PORT_VERIFY_WANT, SECURED_SERVLET_WITH_SESSION); final URL unsecuredUrl = getServletUrl(HTTPS_PORT_VERIFY_WANT, SimpleServlet.SERVLET_PATH); final HttpClient httpClient = getHttpClient(CLIENT_KEYSTORE_FILE); final HttpClient httpClientUntrusted = getHttpClient(UNTRUSTED_KEYSTORE_FILE); try { makeCallWithHttpClient(printPrincipalUrl, httpClientUntrusted, HttpServletResponse.SC_FORBIDDEN); final String principal = makeCallWithHttpClient(printPrincipalUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Unexpected principal", "cn=client", principal.toLowerCase()); String responseBody = makeCallWithHttpClient(unsecuredUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Unsecured page was not reached", SimpleSecuredServlet.RESPONSE_BODY, responseBody); responseBody = makeCallWithHttpClient(securedUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Secured page was not reached", SimpleSecuredServlet.RESPONSE_BODY, responseBody); responseBody = makeCallWithHttpClient(unsecuredUrl, httpClientUntrusted, HttpServletResponse.SC_OK); assertEquals("Unsecured page was not reached", SimpleServlet.RESPONSE_BODY, responseBody); makeCallWithHttpClient(securedUrl, httpClientUntrusted, HttpServletResponse.SC_FORBIDDEN); } finally { httpClient.getConnectionManager().shutdown(); httpClientUntrusted.getConnectionManager().shutdown(); } }