All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pgpainless.exception.SignatureValidationException Maven / Gradle / Ivy

There is a newer version: 1.6.7
Show 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