in src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java [187:217]
public static CryptoRandom getCryptoRandom(final Properties props)
throws GeneralSecurityException {
final List<String> names = Utils.splitClassNames(getRandomClassString(props), ",");
if (names.isEmpty()) {
throw new IllegalArgumentException("No class name(s) provided");
}
final StringBuilder errorMessage = new StringBuilder();
CryptoRandom random = null;
Exception lastException = null;
for (final String className : names) {
try {
final Class<?> klass = ReflectionUtils.getClassByName(className);
random = (CryptoRandom) ReflectionUtils.newInstance(klass, props);
break;
} catch (final ClassCastException e) {
lastException = e;
errorMessage.append("Class: [" + className + "] is not a CryptoRandom.");
} catch (final ClassNotFoundException e) {
lastException = e;
errorMessage.append("CryptoRandom: [" + className + "] not found.");
} catch (final Exception e) {
lastException = e;
errorMessage.append("CryptoRandom: [" + className + "] failed with " + e.getMessage());
}
}
if (random != null) {
return random;
}
throw new GeneralSecurityException(errorMessage.toString(), lastException);
}