use of name.neuhalfen.projects.crypto.bouncycastle.openpgp.keys.callbacks.KeyringConfigCallback in project iaf by ibissource.
the class PGPAction method configure.
/**
* Generates a keyring configuration with public keys and the private key.
*
* @throws ConfigurationException When the files do not exist, or unexpected PGP exception has occurred.
*/
public void configure() throws ConfigurationException {
try {
// Create configuration
KeyringConfigCallback callback = KeyringConfigCallbacks.withUnprotectedKeys();
if (secretPassword != null)
callback = KeyringConfigCallbacks.withPassword(secretPassword);
keyringConfig = KeyringConfigs.forGpgExportedKeys(callback);
// Add public keys
if (publicKeys != null) {
for (String s : publicKeys) {
URL url = ClassUtils.getResourceURL(this, s);
keyringConfig.addPublicKey(IOUtils.toByteArray(url.openStream()));
}
}
// Add private key
if (secretKey != null) {
URL url = ClassUtils.getResourceURL(this, secretKey);
keyringConfig.addSecretKey(IOUtils.toByteArray(url.openStream()));
}
} catch (IOException | PGPException e) {
throw new ConfigurationException("Unknown exception has occurred.", e);
}
}
Aggregations