Search in sources :

Example 1 with PemObject

use of org.openecard.bouncycastle.util.io.pem.PemObject in project open-ecard by ecsec.

the class SmartCardCredentialFactory method printCerts.

private void printCerts(List<DidInfo> infos) {
    for (DidInfo next : infos) {
        try {
            List<X509Certificate> chain = next.getRelatedCertificateChain();
            if (LOG.isDebugEnabled()) {
                for (X509Certificate cert : chain) {
                    StringWriter out = new StringWriter();
                    PemWriter pw = new PemWriter(out);
                    pw.writeObject(new PemObject("CERTIFICATE", cert.getEncoded()));
                    pw.close();
                    LOG.debug("Certificate for DID {}\n{}", next.getDidName(), out);
                    LOG.debug("Certificate details\n{}", cert);
                }
            }
        } catch (SecurityConditionUnsatisfiable | NoSuchDid | CertificateException | IOException ex) {
            LOG.error("Failed to read certificates from card. Skipping DID " + next.getDidName() + ".", ex);
        } catch (WSHelper.WSException ex) {
            LOG.error("Unknown error accessing DID " + next.getDidName() + ".", ex);
        }
    }
}
Also used : WSHelper(org.openecard.common.WSHelper) PemWriter(org.openecard.bouncycastle.util.io.pem.PemWriter) SecurityConditionUnsatisfiable(org.openecard.common.SecurityConditionUnsatisfiable) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate) PemObject(org.openecard.bouncycastle.util.io.pem.PemObject) StringWriter(java.io.StringWriter) DidInfo(org.openecard.crypto.common.sal.did.DidInfo) NoSuchDid(org.openecard.crypto.common.sal.did.NoSuchDid)

Aggregations

IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 PemObject (org.openecard.bouncycastle.util.io.pem.PemObject)1 PemWriter (org.openecard.bouncycastle.util.io.pem.PemWriter)1 SecurityConditionUnsatisfiable (org.openecard.common.SecurityConditionUnsatisfiable)1 WSHelper (org.openecard.common.WSHelper)1 DidInfo (org.openecard.crypto.common.sal.did.DidInfo)1 NoSuchDid (org.openecard.crypto.common.sal.did.NoSuchDid)1