Package java.security

Examples of java.security.SecureRandom.nextLong()


        {
            parent = parentDir.getPath();
        }
        DecimalFormat fmt = new DecimalFormat( "#####" );
        SecureRandom secureRandom = new SecureRandom();
        long secureInitializer = secureRandom.nextLong();
        Random rand = new Random( secureInitializer + Runtime.getRuntime().freeMemory() );
        synchronized ( rand )
        {
            do
            {
View Full Code Here


      fail("Cannot find the default temporary-file directory: " + tmpDir.toString());
    }

    // get a temporary folder name
    SecureRandom random = new SecureRandom();
    long n = random.nextLong();
    n = (n == Long.MIN_VALUE) ? 0 : Math.abs(n);
    String tmpDirStr = Long.toString(n);
    File tempDir = new File(tmpDir, tmpDirStr);
    if (!tempDir.mkdir()) {
      fail("Cannot create a temporary directory at " + tempDir.toString());
View Full Code Here

    return new RAB<User>(pool, 0, new Supplier<String>() {
      Random random = new SecureRandom();

      @Override
      public String get() {
        return String.valueOf(random.nextLong());
      }
    }, User.SCHEMA$);
  }

  private JedisPool getPool() {
View Full Code Here

     * @return the random long value
     */
    public static long secureRandomLong() {
        SecureRandom sr = getSecureRandom();
        synchronized (sr) {
            return sr.nextLong();
        }
    }

    /**
     * Get a number of pseudo random bytes.
View Full Code Here

    return new FAB<User, String>(base + "/tmp/users", base + "/tmp/schemas", new Supplier<String>() {
      Random random = new SecureRandom();

      @Override
      public String get() {
        return String.valueOf(random.nextLong());
      }
    }, User.SCHEMA$, AvroFormat.BINARY, new ReversableFunction<String, byte[]>() {

      @Override
      public byte[] apply(String s) {
View Full Code Here

  public void testBeaconLoadAndScan() throws IOException, S3ServiceException, InterruptedException {
    final FAB<Beacon, byte[]> beaconFAB = new FAB<Beacon, byte[]>("/Volumes/Data/tmp/beacons", "/Volumes/Data/tmp/schemas", new Supplier<byte[]>() {
      Random r = new SecureRandom();
      @Override
      public byte[] get() {
        return Longs.toByteArray(r.nextLong());
      }
    }, Beacon.SCHEMA$, AvroFormat.BINARY, null);
    Properties p = new Properties();
    p.load(getClass().getResourceAsStream("creds.properties"));
    ProviderCredentials pc = new AWSCredentials(p.getProperty("AWS_ACCESS_KEY_ID"), p.getProperty("AWS_SECRET_ACCESS_KEY"));
View Full Code Here

  public void testBeaconScan() {
    final FAB<Beacon, byte[]> beaconFAB = new FAB<Beacon, byte[]>("/Volumes/Data/tmp/beacons", "/Volumes/Data/tmp/schemas", new Supplier<byte[]>() {
      Random r = new SecureRandom();
      @Override
      public byte[] get() {
        return Longs.toByteArray(r.nextLong());
      }
    }, Beacon.SCHEMA$, AvroFormat.BINARY, null);
    int total = 0;
    for (Row<Beacon, byte[]> beaconRow : beaconFAB.scan(null, null)) {
      total++;
View Full Code Here

            random = SecureRandom.getInstance(randAlgName);
        } catch (NoSuchAlgorithmException e) {
            throw new NoSuchAlgorithmException("The algorithm " + randAlgName
                    + " is not available in current environment.", e);
        }
        BigInteger nonce = BigInteger.valueOf(random.nextLong());
        TimeStampReq req = new TimeStampReq(1, // version
                msgImprint,     // message imprint
                null,           // not asking for a particular policy
                nonce,          // nonce
                Boolean.FALSE,  // don't need the certificate inside the stamp
View Full Code Here

        {
            parent = parentDir.getPath();
        }
        DecimalFormat fmt = new DecimalFormat( "#####" );
        SecureRandom secureRandom = new SecureRandom();
        long secureInitializer = secureRandom.nextLong();
        Random rand = new Random( secureInitializer + Runtime.getRuntime().freeMemory() );
        synchronized ( rand )
        {
            do
            {
View Full Code Here

     * @return the random long value
     */
    public static long secureRandomLong() {
        SecureRandom sr = getSecureRandom();
        synchronized (sr) {
            return sr.nextLong();
        }
    }

    /**
     * Get a number of pseudo random bytes.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.