Add Dearmor.data(String) default method

This commit is contained in:
Paul Schaub 2023-07-11 21:18:37 +02:00
parent 7ab65f63a4
commit bfaba69222
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -10,6 +10,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 Dearmor { public interface Dearmor {
@ -19,7 +20,7 @@ public interface Dearmor {
* @param data armored OpenPGP data * @param data armored OpenPGP data
* @return input stream of unarmored data * @return input stream of unarmored data
* *
* @throws sop.exception.SOPGPException.BadData in case of non-OpenPGP data * @throws SOPGPException.BadData in case of non-OpenPGP data
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
Ready data(InputStream data) Ready data(InputStream data)
@ -32,7 +33,7 @@ public interface Dearmor {
* @param data armored OpenPGP data * @param data armored OpenPGP data
* @return input stream of unarmored data * @return input stream of unarmored data
* *
* @throws sop.exception.SOPGPException.BadData in case of non-OpenPGP data * @throws SOPGPException.BadData in case of non-OpenPGP data
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
default Ready data(byte[] data) default Ready data(byte[] data)
@ -40,4 +41,19 @@ public interface Dearmor {
IOException { IOException {
return data(new ByteArrayInputStream(data)); return data(new ByteArrayInputStream(data));
} }
/**
* Dearmor amored OpenPGP data.
*
* @param data armored OpenPGP data
* @return input stream of unarmored data
*
* @throws SOPGPException.BadData in case of non-OpenPGP data
* @throws IOException in case of an IO error
*/
default Ready data(String data)
throws SOPGPException.BadData,
IOException {
return data(data.getBytes(UTF8Util.UTF8));
}
} }