private SecureRandom getSecureRandom() { SecureRandom secureRandom = this.secureRandom.get(); if (secureRandom != null) { return secureRandom; } for (String algorithm : OsTools.secureRandomAlgorithmNames()) { try { secureRandom = SecureRandom.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { // ignore and try next. } } if (secureRandom == null) { throw new InvalidDataAccessApiUsageException( String.format("Could not create SecureRandom instance for one of the algorithms '%s'.", StringUtils.collectionToCommaDelimitedString(OsTools.secureRandomAlgorithmNames()))); } this.secureRandom.compareAndSet(null, secureRandom); return secureRandom; }
private SecureRandom getSecureRandom() { SecureRandom secureRandom = this.secureRandom.get(); if (secureRandom != null) { return secureRandom; } for (String algorithm : OsTools.secureRandomAlgorithmNames()) { try { secureRandom = SecureRandom.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { // ignore and try next. } } if (secureRandom == null) { throw new InvalidDataAccessApiUsageException( String.format("Could not create SecureRandom instance for one of the algorithms '%s'.", StringUtils.collectionToCommaDelimitedString(OsTools.secureRandomAlgorithmNames()))); } this.secureRandom.compareAndSet(null, secureRandom); return secureRandom; }
private SecureRandom getSecureRandom() { SecureRandom secureRandom = this.secureRandom.get(); if (secureRandom != null) { return secureRandom; } for (String algorithm : OsTools.secureRandomAlgorithmNames()) { try { secureRandom = SecureRandom.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { // ignore and try next. } } if (secureRandom == null) { throw new InvalidDataAccessApiUsageException( String.format("Could not create SecureRandom instance for one of the algorithms '%s'.", StringUtils.collectionToCommaDelimitedString(OsTools.secureRandomAlgorithmNames()))); } this.secureRandom.compareAndSet(null, secureRandom); return secureRandom; }