Example usage for org.bouncycastle.x509 PKIXCertPathReviewer getErrors

List of usage examples for org.bouncycastle.x509 PKIXCertPathReviewer getErrors

Introduction

In this page you can find the example usage for org.bouncycastle.x509 PKIXCertPathReviewer getErrors.

Prototype

public List getErrors(int index) 

Source Link

Document

Returns an List of error messages for the certificate at the given index in the CertPath.

Usage

From source file:gov.nih.nci.cacis.nav.ValidateSignedMail.java

License:BSD License

private boolean handleCertPathValidation(PKIXCertPathReviewer review) {
    boolean valid = true;

    if (review.isValidCertPath()) {
        LOG.warn("Certificate path valid");
    } else {// ww  w . j ava2 s. c  o m
        LOG.warn("Certificate path invalid");
        valid = false;
    }

    LOG.warn("\nCertificate path validation results:");
    // global errors
    LOG.warn("Errors:");
    final Iterator errorsIt = review.getErrors(-1).iterator();
    while (errorsIt.hasNext()) {
        final ErrorBundle errorMsg = (ErrorBundle) errorsIt.next();
        if (dbgLvl == DETAIL) {
            LOG.warn(DBL_TAB + errorMsg.getDetail(loc));
        } else {
            LOG.warn(DBL_TAB + errorMsg.getText(loc));
        }
    }

    return valid;
}

From source file:gov.nih.nci.cacis.nav.ValidateSignedMail.java

License:BSD License

private void handleCertificateErrorsAndNotifications(PKIXCertPathReviewer review) {
    // per certificate errors and notifications
    final Iterator certIt = review.getCertPath().getCertificates().iterator();
    int i = 0;//  w w w.  j  ava 2s  .co m
    while (certIt.hasNext()) {
        final X509Certificate cert = (X509Certificate) certIt.next();
        LOG.warn("\nCertificate " + i + "\n========");
        LOG.warn("Issuer: " + cert.getIssuerDN().getName());
        LOG.warn("Subject: " + cert.getSubjectDN().getName());

        // errors
        LOG.warn("\tErrors:");
        final Iterator errorsIt = review.getErrors(i).iterator();
        while (errorsIt.hasNext()) {
            final ErrorBundle errorMsg = (ErrorBundle) errorsIt.next();
            if (dbgLvl == DETAIL) {
                LOG.warn(DBL_TAB + errorMsg.getDetail(loc));
            } else {
                LOG.warn(DBL_TAB + errorMsg.getText(loc));
            }
        }

        // notifications
        LOG.warn("\tNotifications:");
        final Iterator notificationsIt = review.getNotifications(i).iterator();
        while (notificationsIt.hasNext()) {
            final ErrorBundle noteMsg = (ErrorBundle) notificationsIt.next();
            if (dbgLvl == DETAIL) {
                LOG.warn(DBL_TAB + noteMsg.getDetail(loc));
            } else {
                LOG.warn(DBL_TAB + noteMsg.getText(loc));
            }
        }

        i++;
    }
}