2018-06-13 17:26:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Paul Schaub.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2018-07-18 18:23:06 +02:00
|
|
|
package org.pgpainless.encryption_signing;
|
2018-06-04 19:45:18 +02:00
|
|
|
|
2018-06-05 01:30:58 +02:00
|
|
|
import java.io.IOException;
|
2018-06-04 19:45:18 +02:00
|
|
|
import java.io.OutputStream;
|
2018-06-28 18:25:11 +02:00
|
|
|
|
2018-06-05 01:30:58 +02:00
|
|
|
import org.bouncycastle.openpgp.PGPException;
|
2018-06-04 19:45:18 +02:00
|
|
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
|
|
|
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|
|
|
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
2018-06-11 01:33:49 +02:00
|
|
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
2018-06-04 19:45:18 +02:00
|
|
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|
|
|
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
2018-07-18 18:23:06 +02:00
|
|
|
import org.pgpainless.algorithm.CompressionAlgorithm;
|
|
|
|
import org.pgpainless.algorithm.HashAlgorithm;
|
|
|
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
|
|
|
import org.pgpainless.exception.SecretKeyNotFoundException;
|
|
|
|
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
|
|
|
import org.pgpainless.key.selection.keyring.PublicKeyRingSelectionStrategy;
|
|
|
|
import org.pgpainless.key.selection.keyring.SecretKeyRingSelectionStrategy;
|
|
|
|
import org.pgpainless.util.MultiMap;
|
2018-06-04 19:45:18 +02:00
|
|
|
|
|
|
|
public interface EncryptionBuilderInterface {
|
|
|
|
|
|
|
|
ToRecipients onOutputStream(OutputStream outputStream);
|
|
|
|
|
|
|
|
interface ToRecipients {
|
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
WithAlgorithms toRecipients(PGPPublicKey... keys);
|
2018-06-04 19:45:18 +02:00
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
WithAlgorithms toRecipients(PGPPublicKeyRing... keys);
|
2018-06-04 19:45:18 +02:00
|
|
|
|
2018-07-08 17:22:29 +02:00
|
|
|
WithAlgorithms toRecipients(PGPPublicKeyRingCollection... keys);
|
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
<O> WithAlgorithms toRecipients(PublicKeyRingSelectionStrategy<O> selectionStrategy,
|
|
|
|
MultiMap<O, PGPPublicKeyRingCollection> keys);
|
2018-06-04 19:45:18 +02:00
|
|
|
|
|
|
|
SignWith doNotEncrypt();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
interface WithAlgorithms {
|
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
WithAlgorithms andToSelf(PGPPublicKey... keys);
|
2018-06-07 18:12:13 +02:00
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
WithAlgorithms andToSelf(PGPPublicKeyRing... keys);
|
|
|
|
|
2018-07-08 18:05:55 +02:00
|
|
|
WithAlgorithms andToSelf(PGPPublicKeyRingCollection keys);
|
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
<O> WithAlgorithms andToSelf(PublicKeyRingSelectionStrategy<O> selectionStrategy,
|
|
|
|
MultiMap<O, PGPPublicKeyRingCollection> keys);
|
2018-06-04 19:45:18 +02:00
|
|
|
|
|
|
|
SignWith usingAlgorithms(SymmetricKeyAlgorithm symmetricKeyAlgorithm,
|
|
|
|
HashAlgorithm hashAlgorithm,
|
|
|
|
CompressionAlgorithm compressionAlgorithm);
|
|
|
|
|
2018-06-07 18:12:13 +02:00
|
|
|
SignWith usingSecureAlgorithms();
|
|
|
|
|
2018-06-04 19:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
interface SignWith {
|
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
<O> Armor signWith(SecretKeyRingProtector decryptor, PGPSecretKey... keys);
|
2018-06-04 19:45:18 +02:00
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
<O> Armor signWith(SecretKeyRingProtector decryptor, PGPSecretKeyRing... keyRings);
|
2018-06-04 19:45:18 +02:00
|
|
|
|
2018-06-11 01:33:49 +02:00
|
|
|
<O> Armor signWith(SecretKeyRingSelectionStrategy<O> selectionStrategy,
|
|
|
|
SecretKeyRingProtector decryptor,
|
|
|
|
MultiMap<O, PGPSecretKeyRingCollection> keys)
|
2018-06-05 01:30:58 +02:00
|
|
|
throws SecretKeyNotFoundException;
|
2018-06-04 19:45:18 +02:00
|
|
|
|
|
|
|
Armor doNotSign();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Armor {
|
|
|
|
|
2018-06-27 15:09:39 +02:00
|
|
|
EncryptionStream asciiArmor() throws IOException, PGPException;
|
2018-06-04 19:45:18 +02:00
|
|
|
|
2018-06-27 15:09:39 +02:00
|
|
|
EncryptionStream noArmor() throws IOException, PGPException;
|
2018-06-04 19:45:18 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|