Code example for SecureRandom

Methods: getProvider

0
        } 
 
        // Assert that new SecureRandom() and 
        // SecureRandom.getInstance("SHA1PRNG") return a SecureRandom backed 
        // by the Linux PRNG-based SecureRandom implementation. 
        SecureRandom rng1 = new SecureRandom();
        if (!LinuxPRNGSecureRandomProvider.class.equals(
                rng1.getProvider().getClass())) {
            throw new SecurityException(
                    "new SecureRandom() backed by wrong Provider: " 
                            + rng1.getProvider().getClass());
        } 
 
        SecureRandom rng2;
        try { 
            rng2 = SecureRandom.getInstance("SHA1PRNG");
        } catch (NoSuchAlgorithmException e) {
            throw new SecurityException("SHA1PRNG not available", e);
        } 
        if (!LinuxPRNGSecureRandomProvider.class.equals(
                rng2.getProvider().getClass())) {