1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-04 19:45:59 +01:00

Add toString() methods for SignatureVerification & failure

This commit is contained in:
Paul Schaub 2021-10-27 17:11:40 +02:00
parent e8bf2ea9e7
commit bc2afea7ed
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -7,6 +7,7 @@ package org.pgpainless.decryption_verification;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.util.encoders.Hex;
import org.pgpainless.exception.SignatureValidationException; import org.pgpainless.exception.SignatureValidationException;
import org.pgpainless.key.SubkeyIdentifier; import org.pgpainless.key.SubkeyIdentifier;
@ -52,6 +53,12 @@ public class SignatureVerification {
return signingKey; return signingKey;
} }
@Override
public String toString() {
return "Signature: " + (signature != null ? Hex.toHexString(signature.getDigestPrefix()) : "null")
+ "; Key: " + (signingKey != null ? signingKey.toString() : "null") + ";";
}
/** /**
* Tuple object of a {@link SignatureVerification} and the corresponding {@link SignatureValidationException} * Tuple object of a {@link SignatureVerification} and the corresponding {@link SignatureValidationException}
* that caused the verification to fail. * that caused the verification to fail.
@ -90,5 +97,10 @@ public class SignatureVerification {
public SignatureValidationException getValidationException() { public SignatureValidationException getValidationException() {
return validationException; return validationException;
} }
@Override
public String toString() {
return signatureVerification.toString() + " Failure: " + getValidationException().getMessage();
}
} }
} }