當前位置: 首頁>>代碼示例>>Java>>正文


Java X509Certificate.getSigAlgName方法代碼示例

本文整理匯總了Java中java.security.cert.X509Certificate.getSigAlgName方法的典型用法代碼示例。如果您正苦於以下問題:Java X509Certificate.getSigAlgName方法的具體用法?Java X509Certificate.getSigAlgName怎麽用?Java X509Certificate.getSigAlgName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.cert.X509Certificate的用法示例。


在下文中一共展示了X509Certificate.getSigAlgName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: checkConstraints

import java.security.cert.X509Certificate; //導入方法依賴的package包/類
private void checkConstraints(Set<CryptoPrimitive> primitives,
        CertConstraintParameters cp) throws CertPathValidatorException {

    X509Certificate cert = cp.getCertificate();
    String algorithm = cert.getSigAlgName();

    // Check signature algorithm is not disabled
    if (!permits(primitives, algorithm, null)) {
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on disabled "+
                        "signature algorithm: " + algorithm,
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }

    // Check key algorithm is not disabled
    if (!permits(primitives, cert.getPublicKey().getAlgorithm(), null)) {
        throw new CertPathValidatorException(
                "Algorithm constraints check failed on disabled "+
                        "public key algorithm: " + algorithm,
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
    }

    // Check the certificate and key constraints
    algorithmConstraints.permits(cp);

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:27,代碼來源:DisabledAlgorithmConstraints.java

示例3: run

import java.security.cert.X509Certificate; //導入方法依賴的package包/類
private static void run(String keyAlg, int keySize,
                String expectedSigAlg, String sigAlg) throws Exception {
    String alias = keyAlg + keySize + System.currentTimeMillis();
    String cmd = "-keystore ks -storepass changeit" +
            " -keypass changeit -alias " + alias +
            " -keyalg " + keyAlg + " -keysize " + keySize +
            " -genkeypair -dname CN=" + alias + " -debug";
    if (sigAlg != null) {
        cmd += " -sigalg " + sigAlg;
    }
    Main.main(cmd.split(" "));

    KeyStore ks = KeyStore.getInstance(
            new File("ks"), "changeit".toCharArray());
    X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
    String actualSigAlg = cert.getSigAlgName();
    if (!actualSigAlg.equals(expectedSigAlg)) {
        throw new Exception("Failure at " + alias + ": expected "
                + expectedSigAlg + ", actually " + actualSigAlg);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:DefaultSignatureAlgorithm.java

示例4: printX509Cert

import java.security.cert.X509Certificate; //導入方法依賴的package包/類
/**
 * Prints a certificate in a human readable format.
 */
private void printX509Cert(X509Certificate cert, PrintStream out)
    throws Exception
{

    MessageFormat form = new MessageFormat
            (rb.getString(".PATTERN.printX509Cert.with.weak"));
    PublicKey pkey = cert.getPublicKey();
    String sigName = cert.getSigAlgName();
    // No need to warn about sigalg of a trust anchor
    if (!isTrustedCert(cert)) {
        sigName = withWeak(sigName);
    }
    Object[] source = {cert.getSubjectDN().toString(),
                    cert.getIssuerDN().toString(),
                    cert.getSerialNumber().toString(16),
                    cert.getNotBefore().toString(),
                    cert.getNotAfter().toString(),
                    getCertFingerPrint("SHA-1", cert),
                    getCertFingerPrint("SHA-256", cert),
                    sigName,
                    withWeak(pkey),
                    cert.getVersion()
                    };
    out.println(form.format(source));

    if (cert instanceof X509CertImpl) {
        X509CertImpl impl = (X509CertImpl)cert;
        X509CertInfo certInfo = (X509CertInfo)impl.get(X509CertImpl.NAME
                                                       + "." +
                                                       X509CertImpl.INFO);
        CertificateExtensions exts = (CertificateExtensions)
                certInfo.get(X509CertInfo.EXTENSIONS);
        if (exts != null) {
            printExtensions(rb.getString("Extensions."), exts, out);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:41,代碼來源:Main.java

示例5: checkWeak

import java.security.cert.X509Certificate; //導入方法依賴的package包/類
private void checkWeak(String label, Certificate cert)
        throws KeyStoreException {
    if (cert instanceof X509Certificate) {
        X509Certificate xc = (X509Certificate)cert;
        // No need to check the sigalg of a trust anchor
        String sigAlg = isTrustedCert(cert) ? null : xc.getSigAlgName();
        checkWeak(label, sigAlg, xc.getPublicKey());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:Main.java

示例6: getSignatureAlgorithm

import java.security.cert.X509Certificate; //導入方法依賴的package包/類
public String getSignatureAlgorithm() {
    X509Certificate cert = getCertificateList().get(0);
    return cert.getSigAlgName();
}
 
開發者ID:Hitachi-Data-Systems,項目名稱:Open-DM,代碼行數:5,代碼來源:SSLCertChain.java

示例7: printX509Cert

import java.security.cert.X509Certificate; //導入方法依賴的package包/類
/**
 * Prints a certificate in a human readable format.
 */
private void printX509Cert(X509Certificate cert, PrintStream out)
    throws Exception
{
    /*
    out.println("Owner: "
                + cert.getSubjectDN().toString()
                + "\n"
                + "Issuer: "
                + cert.getIssuerDN().toString()
                + "\n"
                + "Serial number: " + cert.getSerialNumber().toString(16)
                + "\n"
                + "Valid from: " + cert.getNotBefore().toString()
                + " until: " + cert.getNotAfter().toString()
                + "\n"
                + "Certificate fingerprints:\n"
                + "\t MD5:  " + getCertFingerPrint("MD5", cert)
                + "\n"
                + "\t SHA1: " + getCertFingerPrint("SHA1", cert));
    */

    MessageFormat form = new MessageFormat
            (rb.getString(".PATTERN.printX509Cert"));
    Object[] source = {cert.getSubjectDN().toString(),
                    cert.getIssuerDN().toString(),
                    cert.getSerialNumber().toString(16),
                    cert.getNotBefore().toString(),
                    cert.getNotAfter().toString(),
                    getCertFingerPrint("MD5", cert),
                    getCertFingerPrint("SHA1", cert),
                    getCertFingerPrint("SHA-256", cert),
                    cert.getSigAlgName(),
                    cert.getVersion()
                    };
    out.println(form.format(source));

    if (cert instanceof X509CertImpl) {
        X509CertImpl impl = (X509CertImpl)cert;
        X509CertInfo certInfo = (X509CertInfo)impl.get(X509CertImpl.NAME
                                                       + "." +
                                                       X509CertImpl.INFO);
        CertificateExtensions exts = (CertificateExtensions)
                certInfo.get(X509CertInfo.EXTENSIONS);
        if (exts != null) {
            printExtensions(rb.getString("Extensions."), exts, out);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:52,代碼來源:Main.java


注:本文中的java.security.cert.X509Certificate.getSigAlgName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。