Package java.security

Examples of java.security.SecureRandom


    private String getRefreshToken() {
        // authorize application on user's behalf
        webClient.getOptions().setRedirectEnabled(true);

        try {
            final String csrfId = String.valueOf(new SecureRandom().nextLong());

            final String encodedRedirectUri = URLEncoder.encode(oAuthParams.getRedirectUri(), "UTF-8");
            final OAuthScope[] scopes = oAuthParams.getScopes();

            final String url;
View Full Code Here


        try {
            keyGen = KeyPairGenerator.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        keyGen.initialize(keylength, new SecureRandom());
        return keyGen.generateKeyPair();
    }
View Full Code Here

    this.tokenSecret = Preconditions.checkNotNull(tokenSecret);

    this.normalizer = Normalizer.getStandardNormalizer();
    this.signer = Signer.getStandardSigner();

    this.secureRandom = new SecureRandom();
  }
View Full Code Here

     * @return the SecureRandom used to generate secure random data, wrapped in a
     * {@link RandomGenerator}.
     */
    private RandomGenerator getSecRan() {
        if (secRand == null) {
            secRand = RandomGeneratorFactory.createRandomGenerator(new SecureRandom());
            secRand.setSeed(System.currentTimeMillis() + System.identityHashCode(this));
        }
        return secRand;
    }
View Full Code Here

    //random_bits1 = md5.digest(SshMisc.addArrayOfBytes(md5.digest((password + login).getBytes()), random_bits1));
    //random_bits2 = md5.digest(SshMisc.addArrayOfBytes(md5.digest((password + login).getBytes()), random_bits2));


    SecureRandom random = new java.security.SecureRandom(random_bits1); //no supported by netscape :-(
    random.nextBytes(random_bits1);
    random.nextBytes(random_bits2);

    session_key = SshMisc.addArrayOfBytes(random_bits1, random_bits2);

    //Xor the 16 first bytes with the session-id
    byte[] session_keyXored = SshMisc.XORArrayOfBytes(random_bits1, hash_md5);
View Full Code Here

  }

  static public byte getNotZeroRandomByte() {
    byte[] randomBytes = new byte[32];

    SecureRandom random = new java.security.SecureRandom(randomBytes);
    while (true) {
      random.nextBytes(randomBytes);
      for (int i = 0; i < randomBytes.length; i++)
        if (randomBytes[i] != 0)
          return randomBytes[i];
    }
  }
View Full Code Here

   public static SSLContext createContext(final String keystorePath, final String keystorePassword, final String trustStorePath, final String trustStorePassword) throws Exception
   {
      SSLContext context = SSLContext.getInstance("TLS");
      KeyManager[] keyManagers = SSLSupport.loadKeyManagers(keystorePath, keystorePassword);
      TrustManager[] trustManagers = SSLSupport.loadTrustManager(trustStorePath, trustStorePassword);
      context.init(keyManagers, trustManagers, new SecureRandom());
      return context;
   }
View Full Code Here

    public static SSLContext clientContext() {
        try {
            InputStream stream = FixedCertificates.class.getResourceAsStream("/" + CLIENT_STORE);
            assert stream != null;
            SSLContext context = Utilities.newSSLContext(stream, CLIENT_PASSWORD, "PKCS12", "sunx509");
            context.init(null, new TrustManager[] { new X509TrustManagerTrustAll() }, new SecureRandom());
            return context;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        }};

        SSLContext sc = SSLContext.getInstance("TLS");
        sc.init(null, trustAllCerts, new SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    }
View Full Code Here

    private static final int ITERATION_COUNT = 1000;
    private static final int KEY_LENGTH = 64 * 8;
    public static final String SHA_1_PRNG = "SHA1PRNG";

    public static byte[] getSalt() {
        SecureRandom sr;
        try {
            sr = SecureRandom.getInstance(SHA_1_PRNG);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("Could not find algorithm: " + SHA_1_PRNG, e);
        }
        byte[] salt = new byte[SALT_LENGTH];
        sr.nextBytes(salt);
        return salt;
    }
View Full Code Here

TOP

Related Classes of java.security.SecureRandom

Copyright © 2018 www.massapicom. 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.