当前位置: 首页>>代码示例>>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;未经允许,请勿转载。