/******************************************************************************* *******************************************************************************/ package at.gv.egiz.eaaf.core.impl.idp.process.support; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; /** * Holder for a secure random instance following the initialization on demand holder design pattern. The secure random * instance is a singleton that is initialized on first usage. * * @author tknall * */ public class SecureRandomHolder { private SecureRandomHolder() { } private static final SecureRandom SRND_INSTANCE; static { try { SRND_INSTANCE = SecureRandom.getInstance("SHA1PRNG"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("Unable to instantiate SHA1PRNG.", e); } } /** * Returns a secure random generator instance. * @return The secure random instance. */ public static SecureRandom getInstance() { return SecureRandomHolder.SRND_INSTANCE; } }