Example usage for java.security SecureRandom getInstanceStrong

List of usage examples for java.security SecureRandom getInstanceStrong

Introduction

In this page you can find the example usage for java.security SecureRandom getInstanceStrong.

Prototype

public static SecureRandom getInstanceStrong() throws NoSuchAlgorithmException 

Source Link

Document

Returns a SecureRandom object that was selected by using the algorithms/providers specified in the securerandom.strongAlgorithms Security property.

Usage

From source file:com.bconomy.autobit.Encryption.java

public static void makeRandomKey() {
    SecureRandom random;/*ww w  .  j a  va  2  s  . co m*/
    try {
        random = SecureRandom.getInstanceStrong();
    } catch (NoSuchAlgorithmException ex) {
        random = new SecureRandom();
    }
    key = new byte[16];
    random.nextBytes(key);
}

From source file:com.github.aynu.yukar.framework.util.SecurityHelper.java

/**
 * ???//  w  w  w .  j a va2  s .  co  m
 * <dl>
 * <dt>?
 * <dd>??????????
 * </dl>
 * @return ??
 * @throws NoSuchAlgorithmException ??
 */
public static SecureRandom getSecureRandom() throws NoSuchAlgorithmException {
    return SecureRandom.getInstanceStrong();
}

From source file:com.github.mrstampy.gameboot.security.SecurityConfiguration.java

/**
 * Secure random./*from w w w.  j av a2 s  .co  m*/
 *
 * @return the secure random
 * @throws Exception
 *           the exception
 */
@Bean(name = GAME_BOOT_SECURE_RANDOM)
public SecureRandom secureRandom() throws Exception {
    SecureRandom random = isEmpty(algorithm) ? SecureRandom.getInstanceStrong()
            : SecureRandom.getInstance(algorithm);

    byte[] seed = new byte[seedSize];
    random.nextBytes(seed);

    return random;
}

From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java

@Test
public void testKSTS() throws Exception {
    RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean();
    Log logger = spy(TestUtils.getPropertyValue(fb, "logger", Log.class));
    given(logger.isDebugEnabled()).willReturn(true);
    new DirectFieldAccessor(fb).setPropertyValue("logger", logger);
    fb.setUseSSL(true);/*from   ww w  .j a  v a2  s .  co  m*/
    fb.setKeyStoreType("JKS");
    fb.setKeyStoreResource(new ClassPathResource("test.ks"));
    fb.setKeyStorePassphrase("secret");
    fb.setTrustStoreResource(new ClassPathResource("test.truststore.ks"));
    fb.setKeyStorePassphrase("secret");
    fb.setSecureRandom(SecureRandom.getInstanceStrong());
    fb.afterPropertiesSet();
    fb.getObject();
    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    verify(logger).debug(captor.capture());
    final String log = captor.getValue();
    assertThat(log, allOf(containsString("KM: ["), containsString("TM: ["), containsString("random: java.")));
}