mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-22 12:22:06 +01:00
Basic support for sop encrypt --profile=XXX
This commit is contained in:
parent
5b363de6e4
commit
3b1edb076c
2 changed files with 23 additions and 0 deletions
|
@ -8,7 +8,9 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
|
@ -28,6 +30,7 @@ import org.pgpainless.exception.WrongPassphraseException;
|
|||
import org.pgpainless.key.OpenPgpFingerprint;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import sop.Profile;
|
||||
import sop.Ready;
|
||||
import sop.enums.EncryptAs;
|
||||
import sop.exception.SOPGPException;
|
||||
|
@ -39,10 +42,15 @@ import sop.util.ProxyOutputStream;
|
|||
*/
|
||||
public class EncryptImpl implements Encrypt {
|
||||
|
||||
private static final Profile DEFAULT_PROFILE = new Profile("default", "Use the implementer's recommendations");
|
||||
|
||||
public static final List<Profile> SUPPORTED_PROFILES = Arrays.asList(DEFAULT_PROFILE);
|
||||
|
||||
EncryptionOptions encryptionOptions = EncryptionOptions.get();
|
||||
SigningOptions signingOptions = null;
|
||||
MatchMakingSecretKeyRingProtector protector = new MatchMakingSecretKeyRingProtector();
|
||||
private final Set<PGPSecretKeyRing> signingKeys = new HashSet<>();
|
||||
private String profile = DEFAULT_PROFILE.getName(); // TODO: Use in future releases
|
||||
|
||||
private EncryptAs encryptAs = EncryptAs.Binary;
|
||||
boolean armor = true;
|
||||
|
@ -111,6 +119,18 @@ public class EncryptImpl implements Encrypt {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Encrypt profile(String profileName) {
|
||||
for (Profile profile : SUPPORTED_PROFILES) {
|
||||
if (profile.getName().equals(profileName)) {
|
||||
this.profile = profile.getName();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
throw new SOPGPException.UnsupportedProfile("encrypt", profileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ready plaintext(InputStream plaintext) throws IOException {
|
||||
if (!encryptionOptions.hasEncryptionMethod()) {
|
||||
|
|
|
@ -22,6 +22,9 @@ public class ListProfilesImpl implements ListProfiles {
|
|||
case "generate-key":
|
||||
return GenerateKeyImpl.SUPPORTED_PROFILES;
|
||||
|
||||
case "encrypt":
|
||||
return EncryptImpl.SUPPORTED_PROFILES;
|
||||
|
||||
default:
|
||||
throw new SOPGPException.UnsupportedProfile(command);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue