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