final String prngName = "SHA1PRNG";
try {
prng = SecureRandom.getInstance(prngName);
} catch (NoSuchAlgorithmException e) {
throw new ProvisionException("Cannot create " + prngName, e);
}
// Run a test encryption to verify the proper algorithms exist in
// our JVM and we are able to invoke them. This helps to identify
// a system configuration problem early at startup, rather than a
// lot later during runtime.
//
try {
encrypt("test", new Date(0), "test".getBytes("UTF-8"));
} catch (NoSuchProviderException e) {
throw new ProvisionException("PGP encryption not available", e);
} catch (PGPException e) {
throw new ProvisionException("PGP encryption not available", e);
} catch (IOException e) {
throw new ProvisionException("PGP encryption not available", e);
}
}