package com.github.arteam.simplejsonrpc.client.generator;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

/**
 * Date: 1/12/15
 * Time: 11:17 PM
 * Abstract generator of secure random identifiers
 */
abstract class SecureRandomIdGenerator<T> implements IdGenerator<T> {

    private static final String SHA_1_PRNG = "SHA1PRNG";

    protected final SecureRandom secureRandom;

    protected SecureRandomIdGenerator() {
        secureRandom = initSecureRandom();
    }

    private static SecureRandom initSecureRandom() {
        try {
            SecureRandom secureRandom = SecureRandom.getInstance(SHA_1_PRNG);
            secureRandom.nextBytes(new byte[]{}); // Important to seed immediately after creation
            return secureRandom;
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
}

@@ -56,55 +56,8 @@
 r;%0A%0A
-import java.security.NoSuchAlgorithmException;%0A
 impo
@@ -257,66 +257,8 @@
  %7B%0A%0A
-    private static final String SHA_1_PRNG = %22SHA1PRNG%22;%0A%0A
     
@@ -355,27 +355,17 @@
     
-secureRandom = init
+this(new 
 Secu
@@ -374,16 +374,17 @@
 Random()
+)
 ;%0A    %7D%0A
@@ -394,20 +394,15 @@
   pr
-ivate static
+otected
  Sec
@@ -414,121 +414,48 @@
 ndom
- initSecureRandom() %7B%0A        try %7B%0A            SecureRandom secureRandom = SecureRandom.getInstance(SHA_1_PRNG);
+IdGenerator(SecureRandom secureRandom) %7B
 %0A   
@@ -459,20 +459,21 @@
         
-    
+this.
 secureRa
@@ -480,214 +480,24 @@
 ndom
-.nextBytes(new byte%5B%5D%7B%7D); // Important to seed immediately after creation%0A            return secureRandom;%0A        %7D catch (NoSuchAlgorithmException e) %7B%0A            throw new RuntimeException(e);%0A        %7D
+ = secureRandom;
 %0A   

Use Native secure random generator by default