List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:net.wastl.webmail.server.SystemCheck.java
public SystemCheck(WebMailServer parent) throws WebMailException { log.info("Checking Java Virtual Machine ... "); log.info("Version: " + System.getProperty("java.version") + " ... "); /* Test if the Java version might cause trouble */ if (System.getProperty("java.version").compareTo("1.5") >= 0) { log.info("JDK version ok."); } else {/*from w w w . j a v a 2s . c o m*/ log.warn("At least Java 1.5 is required for WebMail."); } /* Test if the operating system is supported */ log.info("Operating System: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch") + " " + System.getProperty("os.version") + " ... "); if (System.getProperty("os.name").equals("SunOS") || System.getProperty("os.name").equals("Solaris") || System.getProperty("os.name").equals("Linux")) { log.info("OS variant Ok"); } else { log.warn( "WebMail was only tested\n on Solaris, HP-UX and Linux and may cause problems on your platform."); } /* Check if we are running as root and issue a warning */ try { log.info("User name: " + System.getProperty("user.name") + " ... "); if (!System.getProperty("user.name").equals("root")) { log.info("User ok."); } else { log.warn("warning. You are running WebMail as root. This may be a potential security problem."); } } catch (Exception ex) { // Security restriction prohibit reading the username, then we do not need to // check for root anyway } /* Check whether all WebMail system properties are defined */ log.info("WebMail System Properties: "); //checkPathProperty(parent,"webmail.plugin.path"); //checkPathProperty(parent,"webmail.auth.path"); checkPathProperty(parent, "webmail.lib.path"); checkPathProperty(parent, "webmail.template.path"); checkPathProperty(parent, "webmail.data.path"); checkPathProperty(parent, "webmail.xml.path"); log.info("WebMail System Properties ok!"); log.info("Setting DTD-path in webmail.xml ... "); File f1 = new File( parent.getProperty("webmail.data.path") + System.getProperty("file.separator") + "webmail.xml"); File f2 = new File(parent.getProperty("webmail.data.path") + System.getProperty("file.separator") + "webmail.xml." + Long.toHexString(System.currentTimeMillis())); try { Pattern regexp = Pattern.compile("<!DOCTYPE SYSDATA SYSTEM \".*\">"); BufferedReader file1 = new BufferedReader(new FileReader(f1)); PrintWriter file2 = new PrintWriter(new FileWriter(f2)); try { String line = file1.readLine(); while (line != null) { Matcher m = regexp.matcher(line); String s = m.replaceAll( "<!DOCTYPE SYSDATA SYSTEM \"file://" + parent.getProperty("webmail.xml.path") + System.getProperty("file.separator") + "sysdata.dtd" + "\">"); // String s=regexp.substituteAll(line,"<!DOCTYPE SYSDATA SYSTEM \"file://"+ // parent.getProperty("webmail.xml.path")+ // System.getProperty("file.separator")+ // "sysdata.dtd"+"\">"); //log.debug(s); file2.println(s); line = file1.readLine(); } } catch (EOFException ex) { } file2.close(); file1.close(); } catch (Exception ex) { throw new WebMailException(ex); } f2.renameTo(f1); log.info("Done checking system!"); }
From source file:org.loklak.android.data.Timeline.java
private void addTweet(MessageEntry tweet) { String key = ""; if (this.order == Order.RETWEET_COUNT) { key = Long.toHexString(tweet.getRetweetCount()); while (key.length() < 16) key = "0" + key; key = key + "_" + tweet.getIdStr(); } else if (this.order == Order.FAVOURITES_COUNT) { key = Long.toHexString(tweet.getFavouritesCount()); while (key.length() < 16) key = "0" + key; key = key + "_" + tweet.getIdStr(); } else {/*w w w . j a v a 2s .c o m*/ key = Long.toHexString(tweet.getCreatedAt().getTime()) + "_" + tweet.getIdStr(); } synchronized (tweets) { this.tweets.put(key, tweet); } }
From source file:HexNumberFormat.java
/** * Formats the specified number as a hexadecimal string. The decimal * fraction is ignored.//from w w w. j a va 2 s . c o m * * @param number the number to format. * @param toAppendTo the buffer to append to (ignored here). * @param pos the field position (ignored here). * * @return The string buffer. */ public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { String l_hex = Long.toHexString(number).toUpperCase(); int l_pad = this.m_numDigits - l_hex.length(); l_pad = (0 < l_pad) ? l_pad : 0; StringBuffer l_extended = new StringBuffer("0x"); for (int i = 0; i < l_pad; i++) { l_extended.append(0); } l_extended.append(l_hex); return l_extended; }
From source file:com.cloudbees.jenkins.plugins.dockerslaves.DockerSlaves.java
public DockerLabelAssignmentAction createLabelAssignmentAction(final Queue.BuildableItem bi) { final String id = Long.toHexString(System.nanoTime()); final Label label = Label.get("docker_" + id); return new DockerLabelAssignmentAction(label); }
From source file:com.parse.LocalIdManager.java
/** * Creates a new local id./*from w w w.j ava 2s . c o m*/ */ synchronized String createLocalId() { long localIdNumber = random.nextLong(); String localId = "local_" + Long.toHexString(localIdNumber); if (!isLocalId(localId)) { throw new IllegalStateException("Generated an invalid local id: \"" + localId + "\". " + "This should never happen. Contact us at https://parse.com/help"); } return localId; }
From source file:org.enotron.simulator.impl.simulator.AbstractSimulator.java
public AbstractSimulator(String name, int blockSize) throws SimulatorException { if (name == null || name.isEmpty()) { throw new SimulatorException("Name parameter cannot be empty", 130); } else if (blockSize <= 1 || blockSize > 10000) { _logger.warning(/*from w w w. java 2s. c om*/ "Block size must be between 2 and " + BLOCK_SIZE_MAX + " setting to " + DEFAULT_BLOCK_SIZE); blockSize = DEFAULT_BLOCK_SIZE; } this.name = name; this.blockSize = blockSize; long uidLong = rand.nextLong(); uniqueId = BigInteger.valueOf(uidLong).toByteArray(); _logger.info("Created new simulator " + name + " with Uid: " + Long.toHexString(uidLong).toUpperCase()); }
From source file:org.apache.accumulo.core.trace.TraceDump.java
private static int listSpans(CommandLine commandLine) throws Exception { PrintStream out = System.out; long endTime = System.currentTimeMillis(); long startTime = endTime - DEFAULT_TIME_IN_MILLIS; InstanceUserPassword info = getInstance(commandLine); Connector conn = info.instance.getConnector(info.username, info.password); Scanner scanner = conn.createScanner(TRACE_TABLE, conn.securityOperations().getUserAuthorizations(info.username)); Range range = new Range(new Text("start:" + Long.toHexString(startTime)), new Text("start:" + Long.toHexString(endTime))); scanner.setRange(range);// w w w . j a v a 2s.co m out.println("Trace Day/Time (ms) Start"); for (Entry<Key, Value> entry : scanner) { RemoteSpan span = TraceFormatter.getRemoteSpan(entry); out.println(String.format("%016x %s %5d %s", span.traceId, TraceFormatter.formatDate(new Date(span.getStart())), span.stop - span.start, span.description)); } return 0; }
From source file:com.geoxp.oss.client.OSSClient.java
public static Map<String, String> genMasterSecret(byte[] secret, List<String> pubrings, List<String> pgpkeyids, int k) throws OSSException { try {/*from w ww . j av a 2s .co m*/ // // Extract public keys from key rings // List<PGPPublicKey> keys = new ArrayList<PGPPublicKey>(); for (String pubring : pubrings) { List<PGPPublicKey> pubkeys = CryptoHelper.PGPPublicKeysFromKeyRing(pubring); for (PGPPublicKey key : pubkeys) { // // Generate hex version of key id // String id = "000000000000000" + Long.toHexString(key.getKeyID()).toLowerCase(); id = id.substring(id.length() - 16); // // Add the key if it is in 'keyids' // for (String keyid : pgpkeyids) { if (id.endsWith(keyid.toLowerCase())) { keys.add(key); break; } } } } // // If we have fewer keys than the number of ids specified, throw an error // if (keys.size() < pgpkeyids.size()) { throw new OSSException("Some keys not present in the provided key rings."); } // // Generate the master secret // Map<PGPPublicKey, byte[]> shares = MasterSecretGenerator.generate(secret, keys, k); // // Produce JSON output // Map<String, String> strshares = new HashMap<String, String>(); for (Entry<PGPPublicKey, byte[]> entry : shares.entrySet()) { String id = "000000000000000" + Long.toHexString(entry.getKey().getKeyID()); id = id.substring(id.length() - 16); strshares.put(id, new String(entry.getValue(), "UTF-8")); } return strshares; } catch (Exception e) { throw new OSSException(e); } }
From source file:org.apache.accumulo.master.tableOps.Utils.java
public static void unreserveTable(String tableId, long tid, boolean writeLock) throws Exception { getLock(tableId, tid, writeLock).unlock(); log.info("table " + tableId + " (" + Long.toHexString(tid) + ") unlocked for " + (writeLock ? "write" : "read")); }
From source file:edu.umd.cs.buildServer.BuildServerTestHarness.java
@Override public void initConfig() throws IOException { if (System.getenv("PMD_HOME") != null) getConfig().setProperty(PMD_HOME, System.getenv("PMD_HOME")); getConfig().setProperty(LOG_DIRECTORY, "console"); // FIXME: this is also wrong in general, but might allow me to do some // testing// w w w.j av a 2 s. co m getConfig().setProperty(SUPPORTED_COURSE_LIST, "CMSC433"); getConfig().setProperty(DEBUG_VERBOSE, "true"); getConfig().setProperty(DEBUG_DO_NOT_LOOP, "true"); getConfig().setProperty(DEBUG_PRESERVE_SUBMISSION_ZIPFILES, "true"); if (Boolean.getBoolean("debug.security")) getConfig().setProperty(DEBUG_SECURITY, "true"); if (Boolean.getBoolean("runStudentTests")) getConfig().setProperty(RUN_STUDENT_TESTS, "true"); String tools = System.getenv("tools.java"); if (tools != null) getConfig().setProperty(ConfigurationKeys.INSPECTION_TOOLS_PFX + "java", tools); String performCodeCoverage = System.getenv("PERFORM_CODE_COVERAGE"); if ("true".equals(performCodeCoverage)) getConfig().setProperty(CODE_COVERAGE, "true"); // TODO move the location of the Clover DB to the build directory. // NOTE: This requires changing the security.policy since Clover needs // to be able // to read, write and create files in the directory. String cloverDBPath = "/tmp/myclover.db." + Long.toHexString(nextRandomLong()); getConfig().setProperty(CLOVER_DB, cloverDBPath); }