mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-23 04:42:06 +01:00
Add support for PolicyURI subpackets (fixes #248)
This commit is contained in:
parent
5f65ca4437
commit
d4c56f655f
3 changed files with 37 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
||||||
package org.pgpainless.signature.subpackets;
|
package org.pgpainless.signature.subpackets;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -15,6 +16,7 @@ import org.bouncycastle.bcpg.sig.IntendedRecipientFingerprint;
|
||||||
import org.bouncycastle.bcpg.sig.IssuerFingerprint;
|
import org.bouncycastle.bcpg.sig.IssuerFingerprint;
|
||||||
import org.bouncycastle.bcpg.sig.IssuerKeyID;
|
import org.bouncycastle.bcpg.sig.IssuerKeyID;
|
||||||
import org.bouncycastle.bcpg.sig.NotationData;
|
import org.bouncycastle.bcpg.sig.NotationData;
|
||||||
|
import org.bouncycastle.bcpg.sig.PolicyURI;
|
||||||
import org.bouncycastle.bcpg.sig.Revocable;
|
import org.bouncycastle.bcpg.sig.Revocable;
|
||||||
import org.bouncycastle.bcpg.sig.SignatureCreationTime;
|
import org.bouncycastle.bcpg.sig.SignatureCreationTime;
|
||||||
import org.bouncycastle.bcpg.sig.SignatureExpirationTime;
|
import org.bouncycastle.bcpg.sig.SignatureExpirationTime;
|
||||||
|
@ -88,6 +90,12 @@ public interface BaseSignatureSubpackets {
|
||||||
|
|
||||||
BaseSignatureSubpackets setExportable(@Nullable Exportable exportable);
|
BaseSignatureSubpackets setExportable(@Nullable Exportable exportable);
|
||||||
|
|
||||||
|
BaseSignatureSubpackets setPolicyUrl(@Nullable URL policyUrl);
|
||||||
|
|
||||||
|
BaseSignatureSubpackets setPolicyUrl(boolean isCritical, @Nonnull URL policyUrl);
|
||||||
|
|
||||||
|
BaseSignatureSubpackets setPolicyUrl(@Nullable PolicyURI policyUrl);
|
||||||
|
|
||||||
BaseSignatureSubpackets setRevocable(boolean revocable);
|
BaseSignatureSubpackets setRevocable(boolean revocable);
|
||||||
|
|
||||||
BaseSignatureSubpackets setRevocable(boolean isCritical, boolean isRevocable);
|
BaseSignatureSubpackets setRevocable(boolean isCritical, boolean isRevocable);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package org.pgpainless.signature.subpackets;
|
package org.pgpainless.signature.subpackets;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -26,6 +27,7 @@ import org.bouncycastle.bcpg.sig.IssuerKeyID;
|
||||||
import org.bouncycastle.bcpg.sig.KeyExpirationTime;
|
import org.bouncycastle.bcpg.sig.KeyExpirationTime;
|
||||||
import org.bouncycastle.bcpg.sig.KeyFlags;
|
import org.bouncycastle.bcpg.sig.KeyFlags;
|
||||||
import org.bouncycastle.bcpg.sig.NotationData;
|
import org.bouncycastle.bcpg.sig.NotationData;
|
||||||
|
import org.bouncycastle.bcpg.sig.PolicyURI;
|
||||||
import org.bouncycastle.bcpg.sig.PreferredAlgorithms;
|
import org.bouncycastle.bcpg.sig.PreferredAlgorithms;
|
||||||
import org.bouncycastle.bcpg.sig.PrimaryUserID;
|
import org.bouncycastle.bcpg.sig.PrimaryUserID;
|
||||||
import org.bouncycastle.bcpg.sig.Revocable;
|
import org.bouncycastle.bcpg.sig.Revocable;
|
||||||
|
@ -68,6 +70,7 @@ public class SignatureSubpackets
|
||||||
private final List<EmbeddedSignature> embeddedSignatureList = new ArrayList<>();
|
private final List<EmbeddedSignature> embeddedSignatureList = new ArrayList<>();
|
||||||
private SignerUserID signerUserId;
|
private SignerUserID signerUserId;
|
||||||
private KeyExpirationTime keyExpirationTime;
|
private KeyExpirationTime keyExpirationTime;
|
||||||
|
private PolicyURI policyURI;
|
||||||
private PrimaryUserID primaryUserId;
|
private PrimaryUserID primaryUserId;
|
||||||
private Revocable revocable;
|
private Revocable revocable;
|
||||||
private RevocationReason revocationReason;
|
private RevocationReason revocationReason;
|
||||||
|
@ -485,6 +488,26 @@ public class SignatureSubpackets
|
||||||
return exportable;
|
return exportable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseSignatureSubpackets setPolicyUrl(@Nullable URL policyUrl) {
|
||||||
|
return policyUrl == null ? setPolicyUrl((PolicyURI) null) : setPolicyUrl(false, policyUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseSignatureSubpackets setPolicyUrl(boolean isCritical, @Nonnull URL policyUrl) {
|
||||||
|
return setPolicyUrl(new PolicyURI(isCritical, policyUrl.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseSignatureSubpackets setPolicyUrl(@Nullable PolicyURI policyUrl) {
|
||||||
|
this.policyURI = policyUrl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyURI getPolicyURI() {
|
||||||
|
return policyURI;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SignatureSubpackets setRevocable(boolean revocable) {
|
public SignatureSubpackets setRevocable(boolean revocable) {
|
||||||
return setRevocable(true, revocable);
|
return setRevocable(true, revocable);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.bouncycastle.bcpg.sig.IntendedRecipientFingerprint;
|
||||||
import org.bouncycastle.bcpg.sig.KeyExpirationTime;
|
import org.bouncycastle.bcpg.sig.KeyExpirationTime;
|
||||||
import org.bouncycastle.bcpg.sig.KeyFlags;
|
import org.bouncycastle.bcpg.sig.KeyFlags;
|
||||||
import org.bouncycastle.bcpg.sig.NotationData;
|
import org.bouncycastle.bcpg.sig.NotationData;
|
||||||
|
import org.bouncycastle.bcpg.sig.PolicyURI;
|
||||||
import org.bouncycastle.bcpg.sig.PreferredAlgorithms;
|
import org.bouncycastle.bcpg.sig.PreferredAlgorithms;
|
||||||
import org.bouncycastle.bcpg.sig.PrimaryUserID;
|
import org.bouncycastle.bcpg.sig.PrimaryUserID;
|
||||||
import org.bouncycastle.bcpg.sig.Revocable;
|
import org.bouncycastle.bcpg.sig.Revocable;
|
||||||
|
@ -114,11 +115,14 @@ public class SignatureSubpacketsHelper {
|
||||||
IntendedRecipientFingerprint intendedRecipientFingerprint = (IntendedRecipientFingerprint) subpacket;
|
IntendedRecipientFingerprint intendedRecipientFingerprint = (IntendedRecipientFingerprint) subpacket;
|
||||||
subpackets.addIntendedRecipientFingerprint(intendedRecipientFingerprint);
|
subpackets.addIntendedRecipientFingerprint(intendedRecipientFingerprint);
|
||||||
break;
|
break;
|
||||||
|
case policyUrl:
|
||||||
|
PolicyURI policyURI = (PolicyURI) subpacket;
|
||||||
|
subpackets.setPolicyUrl(policyURI);
|
||||||
|
break;
|
||||||
|
|
||||||
case regularExpression:
|
case regularExpression:
|
||||||
case keyServerPreferences:
|
case keyServerPreferences:
|
||||||
case preferredKeyServers:
|
case preferredKeyServers:
|
||||||
case policyUrl:
|
|
||||||
case placeholder:
|
case placeholder:
|
||||||
case preferredAEADAlgorithms:
|
case preferredAEADAlgorithms:
|
||||||
case attestedCertification:
|
case attestedCertification:
|
||||||
|
@ -135,6 +139,7 @@ public class SignatureSubpacketsHelper {
|
||||||
addSubpacket(generator, subpackets.getSignatureCreationTimeSubpacket());
|
addSubpacket(generator, subpackets.getSignatureCreationTimeSubpacket());
|
||||||
addSubpacket(generator, subpackets.getSignatureExpirationTimeSubpacket());
|
addSubpacket(generator, subpackets.getSignatureExpirationTimeSubpacket());
|
||||||
addSubpacket(generator, subpackets.getExportableSubpacket());
|
addSubpacket(generator, subpackets.getExportableSubpacket());
|
||||||
|
addSubpacket(generator, subpackets.getPolicyURI());
|
||||||
for (NotationData notationData : subpackets.getNotationDataSubpackets()) {
|
for (NotationData notationData : subpackets.getNotationDataSubpackets()) {
|
||||||
addSubpacket(generator, notationData);
|
addSubpacket(generator, notationData);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue