1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-12-10 22:31:09 +01:00

Add SignatureUtils.readSignatures(byte[])

This commit is contained in:
Paul Schaub 2021-08-26 19:35:25 +02:00
parent 1a274bf91b
commit e19acb667c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 31 additions and 17 deletions

View file

@ -217,14 +217,28 @@ public final class SignatureUtils {
}
/**
* Parse an ASCII encoded list of OpenPGP signatures into a {@link PGPSignatureList}.
* Parse an ASCII encoded list of OpenPGP signatures into a {@link PGPSignatureList}
* and return it as a {@link List}.
*
* @param encodedSignatures ASCII armored signature list
* @return signature list
* @throws IOException if the signatures cannot be read
*/
public static List<PGPSignature> readSignatures(String encodedSignatures) throws IOException, PGPException {
InputStream inputStream = new ByteArrayInputStream(encodedSignatures.getBytes(Charset.forName("UTF8")));
byte[] bytes = encodedSignatures.getBytes(Charset.forName("UTF8"));
return readSignatures(bytes);
}
/**
* Read a single, or a list of {@link PGPSignature PGPSignatures} and return them as a {@link List}.
*
* @param encodedSignatures ASCII armored or binary signatures
* @return signatures
* @throws IOException if the signatures cannot be read
* @throws PGPException in case of an OpenPGP error
*/
public static List<PGPSignature> readSignatures(byte[] encodedSignatures) throws IOException, PGPException {
InputStream inputStream = new ByteArrayInputStream(encodedSignatures);
return readSignatures(inputStream);
}