Example usage for java.security Certificate toString

List of usage examples for java.security Certificate toString

Introduction

In this page you can find the example usage for java.security Certificate toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.lockss.protocol.BlockingStreamComm.java

private void logKeyStore(KeyStore ks, char[] privateKeyPassWord) {
    log.debug3("start of key store");
    try {//from w ww . j  a  v a  2  s  .c  o m
        for (Enumeration en = ks.aliases(); en.hasMoreElements();) {
            String alias = (String) en.nextElement();
            log.debug3("Next alias " + alias);
            if (ks.isCertificateEntry(alias)) {
                log.debug3("About to Certificate");
                java.security.cert.Certificate cert = ks.getCertificate(alias);
                if (cert == null) {
                    log.debug3(alias + " null cert chain");
                } else {
                    log.debug3("Cert for " + alias + " is " + cert.toString());
                }
            } else if (ks.isKeyEntry(alias)) {
                log.debug3("About to getKey");
                Key privateKey = ks.getKey(alias, privateKeyPassWord);
                log.debug3(alias + " key " + privateKey.getAlgorithm() + "/" + privateKey.getFormat());
            } else {
                log.debug3(alias + " neither key nor cert");
            }
        }
        log.debug3("end of key store");
    } catch (Exception ex) {
        log.error("logKeyStore() threw " + ex);
    }
}

From source file:org.lockss.util.KeyStoreUtil.java

private static void listKeyStore(String domainNames[], KeyStore kss[], String passwords[], int i) {
    log.debug("start of key store for " + domainNames[i]);
    try {//from  ww  w . j ava 2 s.com
        for (Enumeration en = kss[i].aliases(); en.hasMoreElements();) {
            String alias = (String) en.nextElement();
            log.debug("Next alias " + alias);
            if (kss[i].isCertificateEntry(alias)) {
                log.debug("About to getCertificate");
                java.security.cert.Certificate cert = kss[i].getCertificate(alias);
                if (cert == null) {
                    log.debug(alias + " null cert chain");
                } else {
                    log.debug("Cert for " + alias + " is " + cert.toString());
                }
            } else if (kss[i].isKeyEntry(alias)) {
                log.debug("About to getKey");
                Key privateKey = kss[i].getKey(alias, passwords[i].toCharArray());
                log.debug(alias + " key " + privateKey.getAlgorithm() + "/" + privateKey.getFormat());
            } else {
                log.error(alias + " neither key nor cert");
            }
        }
        log.debug("end of key store for " + domainNames[i]);
    } catch (Exception ex) {
        log.error("listKeyStore() threw " + ex);
    }
}