Add withKeyPassword() methods to GenerateKey

This commit is contained in:
Paul Schaub 2022-05-24 21:13:30 +02:00
parent be2fd9de49
commit 146a2bd761
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -9,6 +9,7 @@ import java.io.InputStream;
import sop.Ready; import sop.Ready;
import sop.exception.SOPGPException; import sop.exception.SOPGPException;
import sop.util.UTF8Util;
public interface GenerateKey { public interface GenerateKey {
@ -27,6 +28,27 @@ public interface GenerateKey {
*/ */
GenerateKey userId(String userId); GenerateKey userId(String userId);
/**
* Set a password for the key.
*
* @param password password to protect the key
* @return builder instance
*/
GenerateKey withKeyPassword(String password);
/**
* Set a password for the key.
*
* @param password password to protect the key
* @return builder instance
*
* @throws sop.exception.SOPGPException.PasswordNotHumanReadable in case of a non-UTF8 password
*/
default GenerateKey withKeyPassword(byte[] password)
throws SOPGPException.PasswordNotHumanReadable {
return withKeyPassword(UTF8Util.decodeUTF8(password));
}
/** /**
* Generate the OpenPGP key and return it encoded as an {@link InputStream}. * Generate the OpenPGP key and return it encoded as an {@link InputStream}.
* *