Package java.security

Examples of java.security.SecureRandom


            kmf.init(ks, certificatePassword);

            // Initialize the SSLContext to work with our key managers.
            KeyManager[] keyManagers = kmf.getKeyManagers();
            TrustManager[] trustManagers = new TrustManager[]{DUMMY_TRUST_MANAGER};
            SecureRandom secureRandom = new SecureRandom();

            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(keyManagers, trustManagers, secureRandom);
            return sslContext;
        } catch (Exception e) {
View Full Code Here


     {
         PreparedStatement ps = null;
         try {
             if (login!=null&&password!=null&&login.length()<=100){
                 // Uses a secure Random not a simple Random
                 SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
                 // Salt generation 64 bits long
                 byte[] bSalt = new byte[8];
                 random.nextBytes(bSalt);
                 // Digest computation
                 byte[] bDigest = getHash(ITERATION_NUMBER,password,bSalt);
                 String sDigest = byteToBase64(bDigest);
                 String sSalt = byteToBase64(bSalt);
  
View Full Code Here

    } catch (IOException exc) {
      //ignore the failure, we're just trying to come up with a random seed
    }
    byte[] rand = byteOut.toByteArray();

    SecureRandom randomizer = new SecureRandom(rand);
    randomizer.nextBytes(address);

    // set the MSB of the first octet to 1 to distinguish from IEEE node addresses
    address[0] = (byte) (address[0] | (byte) 0x80);

    return address;
View Full Code Here

        http.addNode("localhost.80", "sling:Mapping");
        Node https = map.addNode("https", "sling:Mapping");
        https.addNode("localhost.443", "sling:Mapping");

        // define a vanity path for the rootPath
        SecureRandom random = new SecureRandom();
        // creating <nodeCount> nodes
        for (int j = 0; j < nodeCount; j++) {
            Node content = rootNode.addNode("a" + j, JcrConstants.NT_UNSTRUCTURED);
            String alias = new BigInteger(130, random).toString(32);
            content.setProperty(PN_SLING_ALIAS, alias);
View Full Code Here

        Node http = map.addNode("http", "sling:Mapping");
        http.addNode("localhost.80", "sling:Mapping");
        Node https = map.addNode("https", "sling:Mapping");
        https.addNode("localhost.443", "sling:Mapping");

        SecureRandom random = new SecureRandom();

        // creating <nodeCount> x <childNodeCount> nodes with vanity
        for (int j = 0; j < nodeCount; j++) {
            Node content = rootNode.addNode("a" + j, JcrConstants.NT_UNSTRUCTURED);
            String s = new BigInteger(130, random).toString(32);
View Full Code Here

        Node aliasNode = map.addNode("alias", "nt:unstructured");
        Node localhost80 =http.addNode("localhost.80", "sling:Mapping");
        Node https = map.addNode("https", "sling:Mapping");
        https.addNode("localhost.443", "sling:Mapping");

        SecureRandom random = new SecureRandom();

        for (int j = 0; j < nodeCount; j++) {
            Node content = rootNode.addNode("a" + j, JcrConstants.NT_UNSTRUCTURED);
            String alias = new BigInteger(130, random).toString(32);
            content.setProperty(PN_SLING_ALIAS, alias);
View Full Code Here

        Node aliasNode = map.addNode("alias", "nt:unstructured");
        Node localhost80 =http.addNode("localhost.80", "sling:Mapping");
        Node https = map.addNode("https", "sling:Mapping");
        https.addNode("localhost.443", "sling:Mapping");

        SecureRandom random = new SecureRandom();

        // creating <nodeCount> x <childNodeCount> nodes with vanity
        for (int j = 0; j < nodeCount; j++) {
            Node content = rootNode.addNode("a" + j, JcrConstants.NT_UNSTRUCTURED);
            String s = new BigInteger(130, random).toString(32);
View Full Code Here

      HostnameVerifier hv = new HostnameVerifier() {
        public boolean verify(String arg0, SSLSession arg1) {
          return true;
        }
      };
      sc.init(null, trustAllCerts, new SecureRandom());

      if(protocol != null) {
        factory = new DisabledProtocolsSocketFactory(sc.getSocketFactory(), protocol);
      } else {
        factory = sc.getSocketFactory();
View Full Code Here

   * hashing to apply - the work factor therefore increases as
   * 2**log_rounds.
   * @return  an encoded salt value
   */
  public static String gensalt(int log_rounds) {
    return gensalt(log_rounds, new SecureRandom());
  }
View Full Code Here

    extends CipherProvider.Encryptor.Builder<AESCTRNoPaddingEncryptor> {
    @Override
    public AESCTRNoPaddingEncryptor build() {
      ByteBuffer buffer = ByteBuffer.allocate(16);
      byte[] seed = new byte[12];
      SecureRandom random = new SecureRandom();
      random.nextBytes(seed);
      buffer.put(seed).putInt(1);
      return new AESCTRNoPaddingEncryptor(key, buffer.array());
    }
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.