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


Java GeneralNames.fromExtensions方法代碼示例

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


在下文中一共展示了GeneralNames.fromExtensions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: extractX509CSRIPAddresses

import org.bouncycastle.asn1.x509.GeneralNames; //導入方法依賴的package包/類
public static List<String> extractX509CSRIPAddresses(PKCS10CertificationRequest certReq) {
   
    List<String> ipAddresses = 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.iPAddress) {
                    try {
                        InetAddress addr = InetAddress.getByAddress(((DEROctetString) name.getName()).getOctets());
                        ipAddresses.add(addr.getHostAddress());
                    } catch (UnknownHostException e) {
                    }
                }
            }
        }
    }
    return ipAddresses;
}
 
開發者ID:yahoo,項目名稱:athenz,代碼行數:22,代碼來源:Crypto.java

示例3: dump

import org.bouncycastle.asn1.x509.GeneralNames; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
	public static void dump(PKCS10CertificationRequest csr) {
		 Attribute[] certAttributes = csr.getAttributes();
		 for (Attribute attribute : certAttributes) {
		     if (attribute.getAttrType().equals(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest)) {
		         Extensions extensions = Extensions.getInstance(attribute.getAttrValues().getObjectAt(0));
//		         Extension ext = extensions.getExtension(Extension.subjectAlternativeName);
		         GeneralNames gns = GeneralNames.fromExtensions(extensions,Extension.subjectAlternativeName);
		         GeneralName[] names = gns.getNames();
		         for(int k=0; k < names.length; k++) {
		             String title = "";
		             if(names[k].getTagNo() == GeneralName.dNSName) {
		                 title = "dNSName";
		             }
		             else if(names[k].getTagNo() == GeneralName.iPAddress) {
		                 title = "iPAddress";
		                 // Deprecated, but I don't see anything better to use.
		                 names[k].toASN1Object();
		             }
		             else if(names[k].getTagNo() == GeneralName.otherName) {
		                 title = "otherName";
		             }
		             System.out.println(title + ": "+ names[k].getName());
		         } 
		     }
		 }
	}
 
開發者ID:att,項目名稱:AAF,代碼行數:28,代碼來源:CSRMeta.java

示例4: extractX509CSREmail

import org.bouncycastle.asn1.x509.GeneralNames; //導入方法依賴的package包/類
public static String extractX509CSREmail(PKCS10CertificationRequest certReq) {
    
    String rfc822 = null;
    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.rfc822Name) {
                    rfc822 = (((DERIA5String) name.getName()).getString());
                    break;
                }
            }
        }
    }
    return rfc822;
}
 
開發者ID:yahoo,項目名稱:athenz,代碼行數:19,代碼來源:Crypto.java


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