001/*
002 * Copyright 2018 Paul Schaub.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.pgpainless.decryption_verification;
017
018import javax.annotation.Nonnull;
019import java.io.IOException;
020import java.io.InputStream;
021import java.util.Set;
022
023import org.bouncycastle.openpgp.PGPException;
024import org.bouncycastle.openpgp.PGPPublicKeyRing;
025import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
026import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
027import org.pgpainless.key.OpenPgpV4Fingerprint;
028import org.pgpainless.key.protection.SecretKeyRingProtector;
029
030public interface DecryptionBuilderInterface {
031
032    DecryptWith onInputStream(InputStream inputStream);
033
034    interface DecryptWith {
035
036        VerifyWith decryptWith(@Nonnull SecretKeyRingProtector decryptor, @Nonnull PGPSecretKeyRingCollection secretKeyRings);
037
038        VerifyWith doNotDecrypt();
039
040    }
041
042    interface VerifyWith {
043
044        HandleMissingPublicKeys verifyWith(@Nonnull PGPPublicKeyRingCollection publicKeyRings);
045
046        HandleMissingPublicKeys verifyWith(@Nonnull Set<OpenPgpV4Fingerprint> trustedFingerprints, @Nonnull PGPPublicKeyRingCollection publicKeyRings);
047
048        HandleMissingPublicKeys verifyWith(@Nonnull Set<PGPPublicKeyRing> publicKeyRings);
049
050        Build doNotVerify();
051
052    }
053
054    interface HandleMissingPublicKeys {
055
056        Build handleMissingPublicKeysWith(@Nonnull MissingPublicKeyCallback callback);
057
058        Build ignoreMissingPublicKeys();
059    }
060
061    interface Build {
062
063        DecryptionStream build() throws IOException, PGPException;
064
065    }
066
067}