Example usage for java.security.cert X509Certificate getIssuerDN

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

Introduction

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

Prototype

public abstract Principal getIssuerDN();

Source Link

Document

Denigrated, replaced by #getIssuerX500Principal() .

Usage

From source file:org.openhealthtools.openatna.net.LoggedX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[], String)
 */// w w w  .  ja  v a2  s.  c  o m
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (log.isInfoEnabled() && certificates != null) {
        String certificateChain = "Server Certificate Chain: \n";
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            certificateChain += "\n Server certificate " + (c + 1) + ":" + "\n  Subject DN: "
                    + cert.getSubjectDN() + "\n  Signature Algorithm: " + cert.getSigAlgName()
                    + "\n  Valid from: " + cert.getNotBefore() + "\n  Valid until: " + cert.getNotAfter()
                    + "\n  Issuer: " + cert.getIssuerDN();
        }
        log.info(certificateChain);
    }
    // This will throw a CertificateException if it is not trusted.
    try {
        this.defaultTrustManager.checkServerTrusted(certificates, authType);
    } catch (CertificateException e) {
        log.error("Something wrong with the server certificate: (auth type: " + authType + ")", e);
        throw e;
    }
}

From source file:org.wso2.carbon.certificate.mgt.core.impl.CertificateManagementServiceImplTests.java

@Test(description = "This test case tests DN verification of a Certificate against the keystore")
public void testVerifySubjectDN() throws DeviceManagementException, KeystoreException {
    DeviceConfigurationManager.getInstance().initConfig();
    X509Certificate x509Certificate = managementService.generateX509Certificate();
    log.info(x509Certificate.getIssuerX500Principal().getName());
    managementService.verifySubjectDN(x509Certificate.getIssuerDN().getName());
}

From source file:org.openhealthtools.openatna.net.LoggedX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[], String)
 *//*ww  w . ja v a2s .co  m*/
public void checkClientTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (log.isInfoEnabled() && certificates != null) {
        String s = "\n========== checking client certificate chain ==========";
        for (int c = 0; c < certificates.length; c++) {
            X509Certificate cert = certificates[c];
            s += "\n Client certificate " + (c + 1) + ":";
            s += "\n  Subject DN: " + cert.getSubjectDN();
            s += "\n  Signature Algorithm: " + cert.getSigAlgName();
            s += "\n  Valid from: " + cert.getNotBefore();
            s += "\n  Valid until: " + cert.getNotAfter();
            s += "\n  Issuer: " + cert.getIssuerDN();
        }
        s += "\n=======================================================";
        log.info(s);
    }
    // This will throw a CertificateException if it is not trusted.
    try {
        this.defaultTrustManager.checkClientTrusted(certificates, authType);
    } catch (CertificateException e) {
        log.error("Something wrong with the client certificate (auth type: \" + authType +\")", e);
        throw e;
    }
}

From source file:edu.duke.cabig.c3pr.web.security.SecureWebServiceHandler.java

/**
 * Returns the issuer's certificate for the given certificate, and validates
 * the chain at the same time.//from   www.  j a va2 s  . c  o m
 * 
 * @param cert
 * @param crypto
 * @return
 * @throws WSSecurityException
 */
private X509Certificate getIssuerCert(X509Certificate cert, Crypto crypto) throws WSSecurityException {
    String issuerdn = cert.getIssuerDN().getName();
    String[] aliases = crypto.getAliasesForDN(issuerdn);
    if (aliases != null && aliases.length > 0) {
        final X509Certificate[] certificates = crypto.getCertificates(aliases[0]);
        crypto.validateCertPath(certificates);
        return certificates[0];
    } else {
        return null;
    }
}

From source file:com.otterca.persistence.dao.X509CertificateDaoDatastore.java

/**
 * Generate standard key./*from  w  w  w .java2s  . com*/
 * 
 * @param cert
 * @return
 */
public Key generateKey(X509Certificate cert) {
    return KeyFactory.createKey(KIND, cert.getIssuerDN() + ":" + cert.getSerialNumber().toString(16));
}

From source file:au.edu.monash.merc.capture.util.httpclient.ssl.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
 *//*from  w  w  w. ja va  2  s  .c o  m*/
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.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);
}

From source file:au.edu.monash.merc.capture.util.httpclient.ssl.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType)
 *///from w w w .  ja  v a 2  s .  co  m
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());
        }
    }
    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)
 *///from   ww w  . j  av  a 2  s.  c  o m
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:psiprobe.controllers.certificates.ListCertificatesController.java

/**
 * Adds the to store./*w w w .  j av a  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.ovirt.engine.core.utils.ssl.AuthSSLX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[], String authType)
 *//*  ww  w.j  a  v a 2s.  c  o m*/
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);
}