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


Java Principal.equals方法代码示例

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


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

示例1: getCertificateChain

import java.security.Principal; //导入方法依赖的package包/类
public static List<X509Certificate> getCertificateChain(
        List<X509Certificate> certs, X509Certificate leaf) {
    List<X509Certificate> unusedCerts = new ArrayList<>(certs);
    List<X509Certificate> result = new ArrayList<>(1);
    result.add(leaf);
    unusedCerts.remove(leaf);
    X509Certificate root = leaf;
    while (!root.getSubjectDN().equals(root.getIssuerDN())) {
        Principal targetDn = root.getIssuerDN();
        boolean issuerFound = false;
        for (int i = 0; i < unusedCerts.size(); i++) {
            X509Certificate unusedCert = unusedCerts.get(i);
            if (targetDn.equals(unusedCert.getSubjectDN())) {
                issuerFound = true;
                unusedCerts.remove(i);
                result.add(unusedCert);
                root = unusedCert;
                break;
            }
        }
        if (!issuerFound) {
            break;
        }
    }
    return result;
}
 
开发者ID:F8LEFT,项目名称:FApkSigner,代码行数:27,代码来源:V1SchemeVerifier.java

示例2: getCertificateChain

import java.security.Principal; //导入方法依赖的package包/类
public ArrayList<X509Certificate> getCertificateChain(PKCS7 block)
    throws IOException
{
    X509Certificate userCert;
    userCert = block.getCertificate(certificateSerialNumber, issuerName);
    if (userCert == null)
        return null;

    ArrayList<X509Certificate> certList = new ArrayList<X509Certificate>();
    certList.add(userCert);

    X509Certificate[] pkcsCerts = block.getCertificates();
    if (pkcsCerts == null
        || userCert.getSubjectDN().equals(userCert.getIssuerDN())) {
        return certList;
    }

    Principal issuer = userCert.getIssuerDN();
    int start = 0;
    while (true) {
        boolean match = false;
        int i = start;
        while (i < pkcsCerts.length) {
            if (issuer.equals(pkcsCerts[i].getSubjectDN())) {
                // next cert in chain found
                certList.add(pkcsCerts[i]);
                // if selected cert is self-signed, we're done
                // constructing the chain
                if (pkcsCerts[i].getSubjectDN().equals(
                                        pkcsCerts[i].getIssuerDN())) {
                    start = pkcsCerts.length;
                } else {
                    issuer = pkcsCerts[i].getIssuerDN();
                    X509Certificate tmpCert = pkcsCerts[start];
                    pkcsCerts[start] = pkcsCerts[i];
                    pkcsCerts[i] = tmpCert;
                    start++;
                }
                match = true;
                break;
            } else {
                i++;
            }
        }
        if (!match)
            break;
    }

    return certList;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:51,代码来源:SignerInfo.java

示例3: getCertificateChain

import java.security.Principal; //导入方法依赖的package包/类
public ArrayList<X509Certificate> getCertificateChain(PKCS7 block)
    throws IOException
{
    X509Certificate userCert;
    userCert = block.getCertificate(certificateSerialNumber, issuerName);
    if (userCert == null)
        return null;

    ArrayList<X509Certificate> certList = new ArrayList<>();
    certList.add(userCert);

    X509Certificate[] pkcsCerts = block.getCertificates();
    if (pkcsCerts == null
        || userCert.getSubjectDN().equals(userCert.getIssuerDN())) {
        return certList;
    }

    Principal issuer = userCert.getIssuerDN();
    int start = 0;
    while (true) {
        boolean match = false;
        int i = start;
        while (i < pkcsCerts.length) {
            if (issuer.equals(pkcsCerts[i].getSubjectDN())) {
                // next cert in chain found
                certList.add(pkcsCerts[i]);
                // if selected cert is self-signed, we're done
                // constructing the chain
                if (pkcsCerts[i].getSubjectDN().equals(
                                        pkcsCerts[i].getIssuerDN())) {
                    start = pkcsCerts.length;
                } else {
                    issuer = pkcsCerts[i].getIssuerDN();
                    X509Certificate tmpCert = pkcsCerts[start];
                    pkcsCerts[start] = pkcsCerts[i];
                    pkcsCerts[i] = tmpCert;
                    start++;
                }
                match = true;
                break;
            } else {
                i++;
            }
        }
        if (!match)
            break;
    }

    return certList;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:SignerInfo.java


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