List of usage examples for java.lang Long parseUnsignedLong
public static long parseUnsignedLong(String s, int radix) throws NumberFormatException
From source file:org.elasticsearch.repositories.s3.AmazonS3Fixture.java
/** * Creates a {@link AmazonS3Fixture}/*w ww.ja v a2s . c om*/ */ private AmazonS3Fixture(final String workingDir, Properties properties) { super(workingDir); this.properties = properties; this.random = new Random(Long.parseUnsignedLong(requireNonNull(properties.getProperty("tests.seed")), 16)); new Bucket("s3Fixture.permanent", false); new Bucket("s3Fixture.temporary", true); final Bucket ec2Bucket = new Bucket("s3Fixture.ec2", randomAsciiAlphanumOfLength(random, 10), randomAsciiAlphanumOfLength(random, 10)); final Bucket ecsBucket = new Bucket("s3Fixture.ecs", randomAsciiAlphanumOfLength(random, 10), randomAsciiAlphanumOfLength(random, 10)); this.handlers = defaultHandlers(buckets, ec2Bucket, ecsBucket); }
From source file:com.antsdb.saltedfish.nosql.LogReplayer.java
private void run(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); CommandLine line = parser.parse(getOptions(), args); // help/* w w w .j a v a 2s . c om*/ if (line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("replay", getOptions()); return; } // other options this.hexDump = line.hasOption("hex"); this.notrx = line.hasOption("notrx"); if (line.getOptionValue("table") != null) { this.tableId = Integer.parseInt(line.getOptionValue("table")); } if (line.getOptionValue("rowid") != null) { this.rowid = Long.parseLong(line.getOptionValue("rowid")); } Heap heap = new BluntHeap(); if (line.getOptionValue("key") != null) { String keyText = line.getOptionValue("key"); byte[] keyBytes = Base64.getDecoder().decode(keyText); KeyBytes key = KeyBytes.allocSet(heap, keyBytes); this.pKey = key.getAddress(); } // start offset if (line.getOptionValue('s') != null) { String literal = line.getOptionValue('s'); this.offset = Long.parseUnsignedLong(literal, 16); } // length if (line.getOptionValue('n') != null) { String literal = line.getOptionValue('n'); this.length = Integer.parseInt(literal); } // now go if (line.getOptionValue("home") == null) { err.println("error: data directory is not specified"); return; } this.home = new File(line.getOptionValue("home")); if (!home.isDirectory()) { err.println("error: invalid home directory"); return; } if (!new File(this.home, "checkpoint.bin").exists()) { err.println("error: invalid home directory"); return; } // go go go this.out.println("log location: {}", this.home); this.spaceman = new SpaceManager(home, false); spaceman.init(); Gobbler gobbler = new Gobbler(spaceman, false); findStart(); println("start position: %08x", this.offset); try { gobbler.replay(this.offset, true, this); } catch (JumpException ignored) { } }
From source file:org.apache.gobblin.crypto.GPGFileEncryptorTest.java
/** * Encrypt a test string with an asymmetric key and check that it can be decrypted * @throws IOException/*from w w w.j ava 2 s . c o m*/ * @throws PGPException */ @Test public void encryptAsym() throws IOException, PGPException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = GPGFileEncryptor.encryptFile(baos, getClass().getResourceAsStream(PUBLIC_KEY), Long.parseUnsignedLong(KEY_ID, 16), "CAST5"); os.write(EXPECTED_FILE_CONTENT_BYTES); os.close(); baos.close(); byte[] encryptedBytes = baos.toByteArray(); try (InputStream is = GPGFileDecryptor.decryptFile(new ByteArrayInputStream(encryptedBytes), getClass().getResourceAsStream(PRIVATE_KEY), PASSPHRASE)) { byte[] decryptedBytes = IOUtils.toByteArray(is); Assert.assertNotEquals(EXPECTED_FILE_CONTENT_BYTES, encryptedBytes); Assert.assertEquals(EXPECTED_FILE_CONTENT_BYTES, decryptedBytes); } }
From source file:org.apache.gobblin.crypto.GPGFileEncryptorTest.java
/** * Test error with bad cipher//w w w . j ava 2 s . com */ @Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*BadCipher.*") public void badCipher() throws IOException, PGPException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = GPGFileEncryptor.encryptFile(baos, getClass().getResourceAsStream(PUBLIC_KEY), Long.parseUnsignedLong(KEY_ID, 16), "BadCipher"); }