org.pgpainless.exception.SignatureValidationException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pgpainless-core Show documentation
Show all versions of pgpainless-core Show documentation
Simple to use OpenPGP API for Java based on Bouncycastle
The newest version!
// SPDX-FileCopyrightText: 2021 Paul Schaub
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.exception;
import java.util.Map;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSignature;
import org.pgpainless.algorithm.SignatureType;
public class SignatureValidationException extends PGPException {
public SignatureValidationException(String message) {
super(message);
}
public SignatureValidationException(String message, Exception underlying) {
super(message, underlying);
}
public SignatureValidationException(String message, Map rejections) {
super(message + ": " + exceptionMapToString(rejections));
}
private static String exceptionMapToString(Map rejections) {
StringBuilder sb = new StringBuilder();
sb.append(rejections.size()).append(" rejected signatures:\n");
for (PGPSignature signature : rejections.keySet()) {
sb.append(SignatureType.valueOf(signature.getSignatureType())).append(' ')
.append(signature.getCreationTime()).append(": ")
.append(rejections.get(signature).getMessage()).append('\n');
}
return sb.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy