Example usage for java.security.cert X509Certificate getNotBefore

List of usage examples for java.security.cert X509Certificate getNotBefore

Introduction

In this page you can find the example usage for java.security.cert X509Certificate getNotBefore.

Prototype

public abstract Date getNotBefore();

Source Link

Document

Gets the notBefore date from the validity period of the certificate.

Usage

From source file:com.ab.http.AuthSSLX509TrustManager.java

/***
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String
 *      authType)//from   ww  w . jav a  2 s  .  c  o  m
 */
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            Log.i(TAG, "  Server certificate " + (c + 1) + ":");
            Log.i(TAG, "  Subject DN: " + cert.getSubjectDN());
            Log.i(TAG, "  Signature Algorithm: " + cert.getSigAlgName());
            Log.i(TAG, "  Valid from: " + cert.getNotBefore());
            Log.i(TAG, "  Valid until: " + cert.getNotAfter());
            Log.i(TAG, "  Issuer: " + cert.getIssuerDN());
        }
    }
    defaultTrustManager.checkServerTrusted(certificates, authType);
}

From source file:org.ovirt.engine.core.utils.ssl.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[], String authType)
 *///from  w ww.  j  a v a  2  s.com
public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (LOG.isDebugEnabled() && certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            LOG.debug(" Client certificate " + (c + 1) + ":");
            LOG.debug("  Subject DN: " + cert.getSubjectDN());
            LOG.debug("  Signature Algorithm: " + cert.getSigAlgName());
            LOG.debug("  Valid from: " + cert.getNotBefore());
            LOG.debug("  Valid until: " + cert.getNotAfter());
            LOG.debug("  Issuer: " + cert.getIssuerDN());
        }
    }
    defaultTrustManager.checkClientTrusted(certificates, authType);
}

From source file:org.ovirt.engine.core.utils.ssl.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[], String authType)
 *///from  ww  w .j  a  v a2  s . c om
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (LOG.isDebugEnabled() && certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            LOG.debug(" Server certificate " + (c + 1) + ":");
            LOG.debug("  Subject DN: " + cert.getSubjectDN());
            LOG.debug("  Signature Algorithm: " + cert.getSigAlgName());
            LOG.debug("  Valid from: " + cert.getNotBefore());
            LOG.debug("  Valid until: " + cert.getNotAfter());
            LOG.debug("  Issuer: " + cert.getIssuerDN());
        }
    }
    defaultTrustManager.checkServerTrusted(certificates, authType);
}

From source file:io.cloudslang.content.mail.sslconfig.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[], String authType)
 *//*w  w  w  .ja  v  a  2s  . c  om*/
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (LOG.isInfoEnabled() && certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            LOG.info(" Server certificate " + (c + 1) + ":");
            LOG.info("  Subject DN: " + cert.getSubjectDN());
            LOG.info("  Signature Algorithm: " + cert.getSigAlgName());
            LOG.info("  Valid from: " + cert.getNotBefore());
            LOG.info("  Valid until: " + cert.getNotAfter());
            LOG.info("  Issuer: " + cert.getIssuerDN());
            LOG.info("  SN: " + cert.getSerialNumber().toString(16));
        }
    }
    defaultTrustManager.checkServerTrusted(certificates, authType);
}

From source file:gov.va.med.imaging.proxy.ssl.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
 *///from  w  w w.  j  a va  2 s  .com
public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (LOG.isInfoEnabled() && certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            LOG.debug(" Client certificate " + (c + 1) + ":");
            LOG.debug("  Subject DN: " + cert.getSubjectDN());
            LOG.debug("  Signature Algorithm: " + cert.getSigAlgName());
            LOG.debug("  Valid from: " + cert.getNotBefore());
            LOG.debug("  Valid until: " + cert.getNotAfter());
            LOG.debug("  Issuer: " + cert.getIssuerDN());
        }
    }
    defaultTrustManager.checkClientTrusted(certificates, authType);
}

From source file:gov.va.med.imaging.proxy.ssl.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType)
 *//*from  w w  w .j  a va 2 s.  c om*/
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (LOG.isInfoEnabled() && certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            LOG.debug(" Server certificate " + (c + 1) + ":");
            LOG.debug("  Subject DN: " + cert.getSubjectDN());
            LOG.debug("  Signature Algorithm: " + cert.getSigAlgName());
            LOG.debug("  Valid from: " + cert.getNotBefore());
            LOG.debug("  Valid until: " + cert.getNotAfter());
            LOG.debug("  Issuer: " + cert.getIssuerDN());
        }
    }
    defaultTrustManager.checkServerTrusted(certificates, authType);
}

From source file:psiprobe.controllers.certificates.ListCertificatesController.java

/**
 * Adds the to store./*w ww.  j a  va  2 s . c om*/
 *
 * @param certs the certs
 * @param alias the alias
 * @param x509Cert the x509 cert
 */
private void addToStore(List<Cert> certs, String alias, X509Certificate x509Cert) {
    Cert cert = new Cert();

    cert.setAlias(alias);
    cert.setSubjectDistinguishedName(x509Cert.getSubjectDN().toString());
    cert.setNotBefore(x509Cert.getNotBefore());
    cert.setNotAfter(x509Cert.getNotAfter());
    cert.setIssuerDistinguishedName(x509Cert.getIssuerDN().toString());

    certs.add(cert);
}

From source file:org.dataone.proto.trove.mn.http.client.DataHttpClientHandler.java

/**
 * Show details of an X509 certificate, printing the information to STDOUT.
 *
 * @param cert the certificate to be displayed
 *//*from   w w  w.  jav  a2  s .com*/
public void displayCertificate(X509Certificate cert) {
    if (cert == null) {
        return;
    }
    logger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    Principal issuerDN = cert.getIssuerDN();
    logger.debug(" Issuer: " + issuerDN.toString());
    Date notBefore = cert.getNotBefore();
    DateFormat fmt = SimpleDateFormat.getDateTimeInstance();
    logger.debug("   From: " + fmt.format(notBefore));
    Date notAfter = cert.getNotAfter();
    logger.debug("     To: " + fmt.format(notAfter));
    Principal subjectDN = cert.getSubjectDN();
    logger.debug("Subject: " + subjectDN.toString());
    logger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}

From source file:com.thoughtworks.go.security.AuthSSLKeyManagerFactory.java

private void logKeyStore(KeyStore store) throws KeyStoreException {
    LOG.trace("Certificates count: " + store.size());
    Enumeration aliases = store.aliases();
    while (aliases.hasMoreElements()) {
        String alias = (String) aliases.nextElement();
        Certificate[] certs = store.getCertificateChain(alias);
        if (certs != null) {
            LOG.debug("Certificate chain '" + alias + "':");
            for (int c = 0; c < certs.length; c++) {
                if (certs[c] instanceof X509Certificate) {
                    X509Certificate cert = (X509Certificate) certs[c];
                    LOG.trace(" Certificate " + (c + 1) + ":");
                    LOG.trace("  Subject DN: " + cert.getSubjectDN());
                    LOG.trace("  Signature Algorithm: " + cert.getSigAlgName());
                    LOG.trace("  Valid from: " + cert.getNotBefore());
                    LOG.trace("  Valid until: " + cert.getNotAfter());
                    LOG.trace("  Issuer: " + cert.getIssuerDN());
                }//  w w  w.  j  a  v  a 2  s.  co m
            }
        }
    }
}

From source file:com.thoughtworks.go.security.SelfSignedCertificateX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
 *///from   w ww .  ja  va  2s. com
public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (LOG.isDebugEnabled() && certificates != null) {
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            LOG.info(" Client certificate " + (c + 1) + ":");
            LOG.info("  Subject DN: " + cert.getSubjectDN());
            LOG.info("  Signature Algorithm: " + cert.getSigAlgName());
            LOG.info("  Valid from: " + cert.getNotBefore());
            LOG.info("  Valid until: " + cert.getNotAfter());
            LOG.info("  Issuer: " + cert.getIssuerDN());
        }
    }
    defaultTrustManager.checkClientTrusted(certificates, authType);
}