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


Java GeneralNames类代码示例

本文整理汇总了Java中org.bouncycastle.asn1.x509.GeneralNames的典型用法代码示例。如果您正苦于以下问题:Java GeneralNames类的具体用法?Java GeneralNames怎么用?Java GeneralNames使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: extractX509CSRDnsNames

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public static List<String> extractX509CSRDnsNames(PKCS10CertificationRequest certReq) {
    
    List<String> dnsNames = new ArrayList<>();
    Attribute[] attributes = certReq.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
    for (Attribute attribute : attributes) {
        for (ASN1Encodable value : attribute.getAttributeValues()) {
            Extensions extensions = Extensions.getInstance(value);
            GeneralNames gns = GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName);
            for (GeneralName name : gns.getNames()) {
                if (name.getTagNo() == GeneralName.dNSName) {
                    dnsNames.add(((DERIA5String) name.getName()).getString());
                }
            }
        }
    }
    return dnsNames;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:18,代码来源:Crypto.java

示例2: matchesDN

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X500Principal subject, GeneralNames targets)
{
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++)
    {
        GeneralName gn = names[i];

        if (gn.getTagNo() == GeneralName.directoryName)
        {
            try
            {
                if (new X500Principal(((ASN1Encodable)gn.getName()).toASN1Primitive().getEncoded()).equals(subject))
                {
                    return true;
                }
            }
            catch (IOException e)
            {
            }
        }
    }

    return false;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:AttributeCertificateIssuer.java

示例3: matchesDN

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X509Principal subject, GeneralNames targets)
{
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++)
    {
        GeneralName gn = names[i];

        if (gn.getTagNo() == GeneralName.directoryName)
        {
            try
            {
                if (new X509Principal(((ASN1Encodable)gn.getName()).toASN1Primitive()
                    .getEncoded()).equals(subject))
                {
                    return true;
                }
            }
            catch (IOException e)
            {
            }
        }
    }

    return false;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:AttributeCertificateHolder.java

示例4: getCRLDistUrls

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
protected Vector getCRLDistUrls(CRLDistPoint crlDistPoints)
{
    Vector urls = new Vector();
    
    if (crlDistPoints != null)
    {
        DistributionPoint[] distPoints = crlDistPoints.getDistributionPoints();
        for (int i = 0; i < distPoints.length; i++)
        {
            DistributionPointName dp_name = distPoints[i].getDistributionPoint();
            if (dp_name.getType() == DistributionPointName.FULL_NAME)
            {
                GeneralName[] generalNames = GeneralNames.getInstance(dp_name.getName()).getNames();
                for (int j = 0; j < generalNames.length; j++)
                {
                    if (generalNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
                    {
                        String url = ((DERIA5String) generalNames[j].getName()).getString();
                        urls.add(url);
                    }
                }
            }
        }
    }
    return urls;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:PKIXCertPathReviewer.java

示例5: matchesDN

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X500Name subject, GeneralNames targets)
{
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++)
    {
        GeneralName gn = names[i];

        if (gn.getTagNo() == GeneralName.directoryName)
        {
            if (X500Name.getInstance(gn.getName()).equals(subject))
            {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:AttributeCertificateIssuer.java

示例6: getRevokedCertificate

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public X509CRLEntryHolder getRevokedCertificate(BigInteger serialNumber)
{
    GeneralNames currentCA = issuerName;
    for (Enumeration en = x509CRL.getRevokedCertificateEnumeration(); en.hasMoreElements();)
    {
        TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)en.nextElement();

        if (entry.getUserCertificate().getValue().equals(serialNumber))
        {
            return new X509CRLEntryHolder(entry, isIndirect, currentCA);
        }

        if (isIndirect && entry.hasExtensions())
        {
            Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);

            if (currentCaName != null)
            {
                currentCA = GeneralNames.getInstance(currentCaName.getParsedValue());
            }
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:X509CRLHolder.java

示例7: getRevokedCertificates

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
/**
 * Return a collection of X509CRLEntryHolder objects, giving the details of the
 * revoked certificates that appear on this CRL.
 *
 * @return the revoked certificates as a collection of X509CRLEntryHolder objects.
 */
public Collection getRevokedCertificates()
{
    TBSCertList.CRLEntry[] entries = x509CRL.getRevokedCertificates();
    List l = new ArrayList(entries.length);
    GeneralNames currentCA = issuerName;

    for (Enumeration en = x509CRL.getRevokedCertificateEnumeration(); en.hasMoreElements();)
    {
        TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)en.nextElement();
        X509CRLEntryHolder crlEntry = new X509CRLEntryHolder(entry, isIndirect, currentCA);

        l.add(crlEntry);

        currentCA = crlEntry.getCertificateIssuer();
    }

    return l;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:X509CRLHolder.java

示例8: loadCRLEntries

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private Set loadCRLEntries()
{
    Set entrySet = new HashSet();
    Enumeration certs = c.getRevokedCertificateEnumeration();

    X500Name previousCertificateIssuer = null; // the issuer
    while (certs.hasMoreElements())
    {
        TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();
        X509CRLEntryObject crlEntry = new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);
        entrySet.add(crlEntry);
        if (isIndirect && entry.hasExtensions())
        {
            Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);

            if (currentCaName != null)
            {
                previousCertificateIssuer = X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
            }
        }
    }

    return entrySet;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:X509CRLObject.java

示例9: CRLDistributionPointsImpl

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public CRLDistributionPointsImpl(X509Certificate cert) throws CertificateException, IOException {
	URINames = new ArrayList<>();
	byte[] extVal = cert.getExtensionValue(Extension.cRLDistributionPoints.getId());
	if (extVal == null)
		return;
	CRLDistPoint crlDistPoint = CRLDistPoint.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
	DistributionPoint[] points = crlDistPoint.getDistributionPoints();
	for (DistributionPoint p : points) {
		GeneralNames tmp = p.getCRLIssuer();
		if (tmp != null) {
			GeneralName[] crlIssers = tmp.getNames();
			for (int i = 0; i < crlIssers.length; i++) {
				if (crlIssers[i].getTagNo() == GeneralName.uniformResourceIdentifier) {
					String issuerUrl = crlIssers[i].toString();
					URINames.add(issuerUrl);
				}
			}
		}
	}
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:21,代码来源:CRLDistributionPointsImpl.java

示例10: SubjectAlternativeNameImpl

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public SubjectAlternativeNameImpl(X509Certificate cert) throws IOException {
	DNSNames = new ArrayList<>();
	byte[] extVal = cert.getExtensionValue(Extension.subjectAlternativeName.getId());
	if (extVal == null)
		return;
	GeneralNames gn = GeneralNames.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
	GeneralName[] names = gn.getNames();
	for (GeneralName name : names) {
		if (name.getTagNo() == GeneralName.dNSName) {
			String dns = name.getName().toString();
			DNSNames.add(dns);
		}
	}
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:15,代码来源:SubjectAlternativeNameImpl.java

示例11: matchesDN

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X500Principal subject, GeneralNames targets)
{
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++)
    {
        GeneralName gn = names[i];

        if (gn.getTagNo() == GeneralName.directoryName)
        {
            try
            {
                if (new X500Principal(((ASN1Encodable)gn.getName()).getEncoded()).equals(subject))
                {
                    return true;
                }
            }
            catch (IOException e)
            {
            }
        }
    }

    return false;
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:26,代码来源:AttributeCertificateIssuer.java

示例12: performTest

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public void performTest()
    throws Exception
{
    DistributionPointName    name = new DistributionPointName(
                                          new GeneralNames(new GeneralName(new X500Name("cn=test"))));
    ReasonFlags reasonFlags = new ReasonFlags(ReasonFlags.cACompromise);

    checkPoint(6, name, true, true, reasonFlags, true, true);

    checkPoint(2, name, false, false, reasonFlags, false, false);

    checkPoint(0, null, false, false, null, false, false);

    try
    {
        IssuingDistributionPoint.getInstance(new Object());

        fail("getInstance() failed to detect bad object.");
    }
    catch (IllegalArgumentException e)
    {
        // expected
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:25,代码来源:IssuingDistributionPointUnitTest.java

示例13: getValue

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
@Override
public Attribute getValue() {
    try {
        X509Certificate cert = (X509Certificate) certificates[0];
        Digest digest = DigestFactory.getInstance().factoryDefault();
        digest.setAlgorithm(DigestAlgorithmEnum.SHA_1);
        byte[] hash = digest.digest(cert.getEncoded());
        X500Name dirName = new X500Name(cert.getSubjectDN().getName());
        GeneralName name = new GeneralName(dirName);
        GeneralNames issuer = new GeneralNames(name);
        ASN1Integer serial = new ASN1Integer(cert.getSerialNumber());
        IssuerSerial issuerSerial = new IssuerSerial(issuer, serial);
        ESSCertID essCertId = new ESSCertID(hash, issuerSerial);
        return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(new ASN1Encodable[]{new DERSequence(essCertId), new DERSequence(DERNull.INSTANCE)})));

    } catch (CertificateEncodingException ex) {
        throw new SignerException(ex.getMessage());
    }
}
 
开发者ID:demoiselle,项目名称:signer,代码行数:20,代码来源:SigningCertificate.java

示例14: getValue

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
@Override
	public Attribute getValue() throws SignerException {
		try {
			X509Certificate cert = (X509Certificate) certificates[0];
			X509Certificate issuerCert = (X509Certificate) certificates[1];
			Digest digest = DigestFactory.getInstance().factoryDefault();
			digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
			byte[] certHash = digest.digest(cert.getEncoded());
			X500Name dirName = new X500Name(issuerCert.getSubjectX500Principal().getName());
			GeneralName name = new GeneralName(dirName);
			GeneralNames issuer = new GeneralNames(name);
			ASN1Integer serialNumber = new ASN1Integer(cert.getSerialNumber());
			IssuerSerial issuerSerial = new IssuerSerial(issuer, serialNumber);
			AlgorithmIdentifier algId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256);// SHA-256
			ESSCertIDv2 essCertIDv2 = new ESSCertIDv2(algId, certHash, issuerSerial);
//			return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(essCertIDv2)));
			return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(
					new ASN1Encodable[] { new DERSequence(essCertIDv2) })));
		} catch (CertificateEncodingException ex) {
			throw new SignerException(ex.getMessage());
		}
	}
 
开发者ID:demoiselle,项目名称:signer,代码行数:23,代码来源:SigningCertificateV2.java

示例15: getGeneralNamesString

import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
/**
 * Get a formatted string value for the supplied general names object.
 * 
 * @param generalNames General names
 * @return Formatted string
 * @throws IOException
 */
private String getGeneralNamesString(GeneralNames generalNames, LinkClass linkClass)
    throws IOException
{
	GeneralName[] names = generalNames.getNames();
	StringBuilder strBuff = new StringBuilder();
	strBuff.append("<ul>");
	for (GeneralName name : names)
	{
		strBuff.append("<li>");
		strBuff.append(getGeneralNameString(name, linkClass));
		strBuff.append("</li>");
	}
	strBuff.append("</ul>");
	return strBuff.toString();
}
 
开发者ID:gavioto,项目名称:portecle,代码行数:23,代码来源:X509Ext.java


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