当前位置: 首页>>代码示例>>Java>>正文


Java X509Certificate.getNotAfter方法代码示例

本文整理汇总了Java中java.security.cert.X509Certificate.getNotAfter方法的典型用法代码示例。如果您正苦于以下问题:Java X509Certificate.getNotAfter方法的具体用法?Java X509Certificate.getNotAfter怎么用?Java X509Certificate.getNotAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.cert.X509Certificate的用法示例。


在下文中一共展示了X509Certificate.getNotAfter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCertMessage

import java.security.cert.X509Certificate; //导入方法依赖的package包/类
private String getCertMessage(X509Certificate cert, String host) { 
    CertificateFailure[] certFailures = getCertFailures();
    Object[] param = new Object[7];
    param[0] = host;
    param[1] = cert.getSubjectDN().getName();
    param[2] = cert.getNotBefore();
    param[3] = cert.getNotAfter();
    param[4] = cert.getIssuerDN().getName();
    param[5] = getFingerprint(cert, "SHA1");      // NOI18N
    param[6] = getFingerprint(cert, "MD5");       // NOI18N

    String message = NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_BadCertificate", param); // NOI18N
    for (CertificateFailure certFailure : certFailures) {
        message = certFailure.message + message;
    }
    return message;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SvnClientExceptionHandler.java

示例2: getCertificateInfoList

import java.security.cert.X509Certificate; //导入方法依赖的package包/类
@Override
public List<CertificateBasicInfoModel> getCertificateInfoList() throws Exception {
    reloadTrustManager();
    ArrayList<CertificateBasicInfoModel> list = new ArrayList<>();
    Enumeration<String> aliases = this.keyStore.aliases();
    while (aliases.hasMoreElements()) {
        String alias = aliases.nextElement();
        if ("X.509".equals(this.keyStore.getCertificate(alias).getType())) {
            X509Certificate certificate = (X509Certificate) this.keyStore.getCertificate(alias);
            try {
                CertificateBasicInfoModel infoModel = new CertificateBasicInfoModel(
                        alias, getSha1Fingerprint(certificate), certificate.getIssuerDN().getName(),
                        certificate.getNotBefore(), certificate.getNotAfter(), certificate.getSigAlgName(),
                        certificateToString(certificate));

                list.add(infoModel);
            } catch (NoSuchAlgorithmException | CertificateEncodingException e) {
                LOG.error("Failed to add certificate basic info model", e);
            }
        } else {
            list.add(new CertificateBasicInfoModel(alias));
        }
    }
    return list;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:26,代码来源:X509TrustManagerFactory.java

示例3: getCertificateValidityString

import java.security.cert.X509Certificate; //导入方法依赖的package包/类
public static String getCertificateValidityString(X509Certificate cert, Resources res) {
    try {
        cert.checkValidity();
    } catch (CertificateExpiredException ce) {
        return "EXPIRED: ";
    } catch (CertificateNotYetValidException cny) {
        return "NOT YET VALID: ";
    }
    Date certNotAfter = cert.getNotAfter();
    Date now = new Date();
    long timeLeft = certNotAfter.getTime() - now.getTime(); // Time left in ms
    // More than 72h left, display days
    // More than 3 months display months
    if (timeLeft > 90l * 24 * 3600 * 1000) {
        long months = getMonthsDifference(now, certNotAfter);
        return res.getString(R.string.months_left, months);
    } else if (timeLeft > 72 * 3600 * 1000) {
        long days = timeLeft / (24 * 3600 * 1000);
        return res.getString(R.string.days_left, days);
    } else {
        long hours = timeLeft / (3600 * 1000);
        return res.getString(R.string.hours_left, hours);
    }
}
 
开发者ID:akashdeepsingh9988,项目名称:Cybernet-VPN,代码行数:25,代码来源:X509Utils.java

示例4: DataValidade

import java.security.cert.X509Certificate; //导入方法依赖的package包/类
/**
 * Método  que retorna a Data De Validade Do Certificado Digital
 *
 * @param certificado
 * @return
 * @throws CertificadoException
 */
public static Date DataValidade(Certificado certificado) throws CertificadoException {

    KeyStore keyStore = getKeyStore(certificado);
    X509Certificate certificate = getCertificate(certificado, keyStore);
    return certificate.getNotAfter();

}
 
开发者ID:Samuel-Oliveira,项目名称:Java_Certificado,代码行数:15,代码来源:CertificadoService.java

示例5: getValidNotAfter

import java.security.cert.X509Certificate; //导入方法依赖的package包/类
public Date getValidNotAfter() {
    X509Certificate cert = getCertificateList().get(0);
    return cert.getNotAfter();
}
 
开发者ID:Hitachi-Data-Systems,项目名称:Open-DM,代码行数:5,代码来源:SSLCertChain.java

示例6: getValidityPeriod

import java.security.cert.X509Certificate; //导入方法依赖的package包/类
/**
 * Checks how many days a given certificate is still valid. 
 * If the certificate is not valid any more, a negative number will be returned according to the number
 * of days the certificate is already expired.
 * 
 * @param certificate The X509Certificiate to be checked for validity period
 * @return The number of days the given certificate is still valid, a negative number if already expired.
 */
public static short getValidityPeriod(X509Certificate certificate) {
	Date today = Calendar.getInstance().getTime();
	Date certificateExpirationDate = certificate.getNotAfter();
	long diff = certificateExpirationDate.getTime() - today.getTime();
	
	return (short) TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
}
 
开发者ID:V2GClarity,项目名称:RISE-V2G,代码行数:16,代码来源:SecurityUtils.java


注:本文中的java.security.cert.X509Certificate.getNotAfter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。