mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 03:17:58 +01:00
SOP: Hide armor version header by default
This commit is contained in:
parent
48005da7f3
commit
86b06ee5e3
3 changed files with 19 additions and 6 deletions
|
@ -31,7 +31,11 @@ public final class ArmoredOutputStreamFactory {
|
|||
*/
|
||||
public static ArmoredOutputStream get(OutputStream outputStream) {
|
||||
ArmoredOutputStream armoredOutputStream = new ArmoredOutputStream(outputStream);
|
||||
armoredOutputStream.setHeader(ArmorUtils.HEADER_VERSION, version);
|
||||
armoredOutputStream.clearHeaders();
|
||||
if (version != null && !version.isEmpty()) {
|
||||
armoredOutputStream.setHeader(ArmorUtils.HEADER_VERSION, version);
|
||||
}
|
||||
|
||||
for (String comment : comment) {
|
||||
ArmorUtils.addCommentHeader(armoredOutputStream, comment);
|
||||
}
|
||||
|
@ -55,10 +59,16 @@ public final class ArmoredOutputStreamFactory {
|
|||
* @param versionString version string
|
||||
*/
|
||||
public static void setVersionInfo(String versionString) {
|
||||
if (versionString == null || versionString.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("Version Info MUST NOT be null NOR empty.");
|
||||
if (versionString == null) {
|
||||
version = null;
|
||||
return;
|
||||
}
|
||||
String trimmed = versionString.trim();
|
||||
if (trimmed.isEmpty()) {
|
||||
version = null;
|
||||
} else {
|
||||
version = trimmed;
|
||||
}
|
||||
version = versionString;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.pgpainless.sop;
|
||||
|
||||
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
||||
import sop.SOP;
|
||||
import sop.operation.Armor;
|
||||
import sop.operation.Dearmor;
|
||||
|
@ -20,6 +21,10 @@ import sop.operation.Version;
|
|||
|
||||
public class SOPImpl implements SOP {
|
||||
|
||||
static {
|
||||
ArmoredOutputStreamFactory.setVersionInfo(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version version() {
|
||||
return new VersionImpl();
|
||||
|
|
|
@ -18,7 +18,6 @@ import sop.exception.SOPGPException;
|
|||
public class ExtractCertTest {
|
||||
|
||||
public static final String key = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
||||
"Version: PGPainless\n" +
|
||||
"Comment: A8D9 9FF4 C8DD BBA6 C610 A6B7 9ACB 2195 A9BC DF5B\n" +
|
||||
"Comment: Alice <alice@pgpainless.org>\n" +
|
||||
"\n" +
|
||||
|
@ -42,7 +41,6 @@ public class ExtractCertTest {
|
|||
"-----END PGP PRIVATE KEY BLOCK-----\n";
|
||||
|
||||
public static final String cert = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
|
||||
"Version: PGPainless\n" +
|
||||
"Comment: A8D9 9FF4 C8DD BBA6 C610 A6B7 9ACB 2195 A9BC DF5B\n" +
|
||||
"Comment: Alice <alice@pgpainless.org>\n" +
|
||||
"\n" +
|
||||
|
|
Loading…
Reference in a new issue