1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-17 00:54:50 +02:00
pgpainless/pgpainless-core/src/main/java/org/pgpainless/signature/consumer/DetachedSignatureCheck.java

72 lines
2.2 KiB
Java
Raw Normal View History

2021-10-07 15:48:52 +02:00
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.signature.consumer;
2020-08-24 14:55:06 +02:00
2021-04-26 13:38:12 +02:00
import org.bouncycastle.openpgp.PGPKeyRing;
2020-08-24 14:55:06 +02:00
import org.bouncycastle.openpgp.PGPSignature;
import org.pgpainless.key.OpenPgpFingerprint;
2021-04-26 13:38:12 +02:00
import org.pgpainless.key.SubkeyIdentifier;
2020-08-24 14:55:06 +02:00
/**
* Tuple-class which bundles together a signature, the signing key that created the signature,
2021-12-28 13:53:25 +01:00
* an identifier of the signing key and a record of whether the signature was verified.
*/
public class DetachedSignatureCheck {
2020-08-24 14:55:06 +02:00
private final PGPSignature signature;
2021-04-26 13:38:12 +02:00
private final PGPKeyRing signingKeyRing;
private final SubkeyIdentifier signingKeyIdentifier;
2020-08-24 14:55:06 +02:00
/**
* Create a new {@link DetachedSignatureCheck} object.
*
* @param signature signature
* @param signingKeyRing signing key that created the signature
* @param signingKeyIdentifier identifier of the used signing key
*/
public DetachedSignatureCheck(PGPSignature signature, PGPKeyRing signingKeyRing, SubkeyIdentifier signingKeyIdentifier) {
2020-08-24 14:55:06 +02:00
this.signature = signature;
2021-04-26 13:38:12 +02:00
this.signingKeyRing = signingKeyRing;
this.signingKeyIdentifier = signingKeyIdentifier;
2020-08-24 14:55:06 +02:00
}
/**
* Return the OpenPGP signature.
*
* @return signature
*/
2020-08-24 14:55:06 +02:00
public PGPSignature getSignature() {
return signature;
}
/**
* Return an identifier pointing to the exact signing key which was used to create this signature.
*
* @return signing key identifier
*/
2021-04-26 13:38:12 +02:00
public SubkeyIdentifier getSigningKeyIdentifier() {
return signingKeyIdentifier;
}
/**
* Return the key ring that contains the signing key that created this signature.
*
* @return key ring
*/
2021-04-26 13:38:12 +02:00
public PGPKeyRing getSigningKeyRing() {
return signingKeyRing;
}
/**
* Return the {@link OpenPgpFingerprint} of the key that created the signature.
*
* @return fingerprint of the signing key
2021-08-15 15:38:31 +02:00
* @deprecated use {@link #getSigningKeyIdentifier()} instead.
*/
2021-04-26 13:38:12 +02:00
@Deprecated
public OpenPgpFingerprint getFingerprint() {
2021-04-26 13:38:12 +02:00
return signingKeyIdentifier.getSubkeyFingerprint();
2020-08-24 14:55:06 +02:00
}
}