當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。