pgpainless/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionBuilder.java

35 lines
1006 B
Java
Raw Normal View History

2021-10-07 15:48:52 +02:00
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.decryption_verification;
2018-06-06 18:46:41 +02:00
import java.io.IOException;
import java.io.InputStream;
2020-01-10 18:46:31 +01:00
import javax.annotation.Nonnull;
2018-06-06 18:46:41 +02:00
import org.bouncycastle.openpgp.PGPException;
public class DecryptionBuilder implements DecryptionBuilderInterface {
private InputStream inputStream;
2020-08-24 14:55:06 +02:00
2018-06-06 18:46:41 +02:00
@Override
public DecryptWith onInputStream(@Nonnull InputStream inputStream) {
2018-06-06 18:46:41 +02:00
this.inputStream = inputStream;
return new DecryptWithImpl();
}
class DecryptWithImpl implements DecryptWith {
2021-06-15 17:08:40 +02:00
@Override
public DecryptionStream withOptions(ConsumerOptions consumerOptions) throws PGPException, IOException {
if (consumerOptions == null) {
throw new IllegalArgumentException("Consumer options cannot be null.");
}
return DecryptionStreamFactory.create(inputStream, consumerOptions);
}
2018-06-06 18:46:41 +02:00
}
}