Package java.security

Examples of java.security.SecureRandom


        return retval;
    }


    protected static byte[] generateRandomBytes() {
        SecureRandom ng=numberGenerator;
        if(ng == null)
            numberGenerator=ng=new SecureRandom();

        byte[] randomBytes=new byte[16];
        ng.nextBytes(randomBytes);
        return randomBytes;
    }
View Full Code Here


    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
    tmf.init(keystore);      
    TrustManager[] trustManagers = tmf.getTrustManagers();
   
    SSLContext ctx = SSLContext.getInstance(sslContext);
    SecureRandom securerandom = SecureRandom.getInstance("SHA1PRNG");
//    SecureRandom securerandom = null;
    ctx.init(kmf.getKeyManagers(),trustManagers,securerandom);
   
    return ctx.getSocketFactory();
  }
View Full Code Here

     * The {@code UUID} is generated using a cryptographically strong pseudo
     * random number generator.
     * @return  A randomly generated {@code UUID}
     */
    public static UUID randomUUID() {
        SecureRandom ng=numberGenerator;
        if(ng == null)
            numberGenerator=ng=new SecureRandom();

        byte[] randomBytes=new byte[16];
        ng.nextBytes(randomBytes);
        return new UUID(randomBytes);
    }
View Full Code Here

        TrustManagerFactory trustManagerFactory=TrustManagerFactory.getInstance(_sslTrustManagerFactoryAlgorithm);
        trustManagerFactory.init(trustStore);
        trustManagers=trustManagerFactory.getTrustManagers();

        SecureRandom secureRandom=_secureRandomAlgorithm==null?null:SecureRandom.getInstance(_secureRandomAlgorithm);
        SSLContext context=_provider==null?SSLContext.getInstance(_protocol):SSLContext.getInstance(_protocol,_provider);
        context.init(keyManagers,trustManagers,secureRandom);
        return context;
    }
View Full Code Here

    // TIPS: By adding option '-Djava.security.egd=file:/dev/./urandom'
    //       SHA1PRNG will be used instead of NativePRNG.
    // On MacOSX, 'new SecureRandom()' will use NativePRNG algorithm and
    // it is also slower than SHA1PRNG.
    // On Windows, 'new SecureRandom()' will use SHA1PRNG algorithm.
    random=new SecureRandom();

    /*
    try{
      random=SecureRandom.getInstance("SHA1PRNG");
      return;
View Full Code Here

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
    tmf.init(keystore);      
    TrustManager[] trustManagers = tmf.getTrustManagers();

    SSLContext ctx = SSLContext.getInstance(sslContext);
    SecureRandom securerandom = SecureRandom.getInstance("SHA1PRNG");
    //    SecureRandom securerandom = null;
    ctx.init(kmf.getKeyManagers(),trustManagers,securerandom);

    return ctx.getServerSocketFactory();
  }
View Full Code Here

    public void setPayload(String payload) {
        this.payload=payload;
    }

    protected static byte[] generateRandomBytes() {
        SecureRandom ng=numberGenerator;
        if(ng == null)
            numberGenerator=ng=new SecureRandom();

        byte[] randomBytes=new byte[16];
        ng.nextBytes(randomBytes);
        return randomBytes;
    }
View Full Code Here

        return super.toString() + "(" + printDetails() + ")";
    }

   
    protected static byte[] generateRandomBytes() {
        SecureRandom ng=numberGenerator;
        if(ng == null)
            numberGenerator=ng=new SecureRandom();

        byte[] randomBytes=new byte[16];
        ng.nextBytes(randomBytes);
        return randomBytes;
    }
View Full Code Here

    keepAliveHdrParams = "timeout=" + timeoutKeepAliveSec + ", max="
        + maxAliveConnUse;

    expiredIn = arguments.get(ARG_SESSION_TIMEOUT) != null ? ((Integer) arguments
        .get(ARG_SESSION_TIMEOUT)).intValue() : DEF_SESSION_TIMEOUT;
    srandom = new SecureRandom(
        (arguments.get(ARG_SESSION_SEED) == null ? "TJWS" + new Date()
            : (String) arguments.get(ARG_SESSION_SEED)).getBytes());
    try {
      gzipInStreamConstr = Class.forName("java.util.zip.GZIPInputStream")
          .getConstructor(new Class[] { InputStream.class });
View Full Code Here

   * @throws Exception
   */
  public static byte[] encrypt(byte[] src, byte[] key)
    throws Exception {
    //    DES�㷨Ҫ����һ�������ε������Դ
    SecureRandom sr = new SecureRandom();
    // ��ԭʼ�ܳ����ݴ���DESKeySpec����
    DESKeySpec dks = new DESKeySpec(key);
    // ����һ���ܳ׹�����Ȼ��������DESKeySpecת����
    // һ��SecretKey����
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
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.