Search in sources :

Example 1 with Encrypt

use of nl.nn.adapterframework.pgp.Encrypt in project iaf by ibissource.

the class PGPPipe method configure.

@Override
public void configure() throws ConfigurationException {
    super.configure();
    if (action == null)
        throw new ConfigurationException("Action can not be null!");
    if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) != null)
        Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
    Security.addProvider(new BouncyCastleProvider());
    switch(action.toLowerCase()) {
        case "encrypt":
            pgpAction = new Encrypt(publicKeys, recipients);
            break;
        case "decrypt":
            pgpAction = new Decrypt(secretKey, secretPassword);
            break;
        case "sign":
            if (verificationAddresses == null || verificationAddresses.length == 0)
                throw new ConfigurationException("During signing action, senders has to be set.");
            pgpAction = new Sign(publicKeys, secretKey, secretPassword, recipients, verificationAddresses[0]);
            break;
        case "verify":
            pgpAction = new Verify(publicKeys, secretKey, secretPassword, verificationAddresses);
            break;
        default:
            throw new ConfigurationException("Unknown action. Action has to be set to one of [Encrypt, Decrypt, Sign, Verify]");
    }
    pgpAction.configure();
}
Also used : Decrypt(nl.nn.adapterframework.pgp.Decrypt) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Sign(nl.nn.adapterframework.pgp.Sign) Verify(nl.nn.adapterframework.pgp.Verify) Encrypt(nl.nn.adapterframework.pgp.Encrypt) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Aggregations

ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 Decrypt (nl.nn.adapterframework.pgp.Decrypt)1 Encrypt (nl.nn.adapterframework.pgp.Encrypt)1 Sign (nl.nn.adapterframework.pgp.Sign)1 Verify (nl.nn.adapterframework.pgp.Verify)1 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)1