Java Code Examples for org.bouncycastle.asn1.x509.GeneralName#getInstance()
The following examples show how to use
org.bouncycastle.asn1.x509.GeneralName#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SFTrustManager.java From snowflake-jdbc with Apache License 2.0 | 5 votes |
/** * Gets OCSP URLs associated with the certificate. * * @param bcCert Bouncy Castle Certificate * @return a set of OCSP URLs */ private Set<String> getOcspUrls(Certificate bcCert) throws IOException { TBSCertificate bcTbsCert = bcCert.getTBSCertificate(); Extensions bcExts = bcTbsCert.getExtensions(); if (bcExts == null) { throw new IOException("Failed to get Tbs Certificate."); } Set<String> ocsp = new HashSet<>(); for (Enumeration<?> en = bcExts.oids(); en.hasMoreElements(); ) { ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) en.nextElement(); Extension bcExt = bcExts.getExtension(oid); if (Extension.authorityInfoAccess.equals(bcExt.getExtnId())) { // OCSP URLS are included in authorityInfoAccess DLSequence seq = (DLSequence) bcExt.getParsedValue(); for (ASN1Encodable asn : seq) { ASN1Encodable[] pairOfAsn = ((DLSequence) asn).toArray(); if (pairOfAsn.length == 2) { ASN1ObjectIdentifier key = (ASN1ObjectIdentifier) pairOfAsn[0]; if (OIDocsp.equals(key)) { // ensure OCSP and not CRL GeneralName gn = GeneralName.getInstance(pairOfAsn[1]); ocsp.add(gn.getName().toString()); } } } } } return ocsp; }
Example 2
Source File: ExtensionType.java From xipki with Apache License 2.0 | 4 votes |
public AdmissionExtension.AdmissionSyntaxOption toXiAdmissionSyntax(boolean critical) throws CertprofileException { List<AdmissionExtension.AdmissionsOption> admissionsList = new LinkedList<>(); for (AdmissionsType at : getContentsOfAdmissions()) { List<AdmissionExtension.ProfessionInfoOption> professionInfos = new LinkedList<>(); for (ProfessionInfoType pi : at.getProfessionInfos()) { NamingAuthority namingAuthorityL3 = null; if (pi.getNamingAuthority() != null) { namingAuthorityL3 = buildNamingAuthority(pi.getNamingAuthority()); } List<DescribableOid> oidTypes = pi.getProfessionOids(); List<ASN1ObjectIdentifier> oids = null; if (CollectionUtil.isNotEmpty(oidTypes)) { oids = new LinkedList<>(); for (DescribableOid k : oidTypes) { oids.add(new ASN1ObjectIdentifier(k.getOid())); } } RegistrationNumber rnType = pi.getRegistrationNumber(); AdmissionExtension.RegistrationNumberOption rno = (rnType == null) ? null : new AdmissionExtension.RegistrationNumberOption( rnType.getRegex(), rnType.getConstant()); AdmissionExtension.ProfessionInfoOption pio = new AdmissionExtension.ProfessionInfoOption(namingAuthorityL3, pi.getProfessionItems(), oids, rno, pi.getAddProfessionInfo()); professionInfos.add(pio); } GeneralName admissionAuthority = null; if (at.getNamingAuthority() != null) { admissionAuthority = GeneralName.getInstance( asn1PrimitivefromByteArray(at.getAdmissionAuthority())); } NamingAuthority namingAuthority = null; if (at.getNamingAuthority() != null) { namingAuthority = buildNamingAuthority(at.getNamingAuthority()); } AdmissionExtension.AdmissionsOption admissionsOption = new AdmissionExtension.AdmissionsOption( admissionAuthority, namingAuthority, professionInfos); admissionsList.add(admissionsOption); } GeneralName tmpAdmissionAuthority = null; if (admissionAuthority != null) { tmpAdmissionAuthority = GeneralName.getInstance(admissionAuthority); } return new AdmissionExtension.AdmissionSyntaxOption( critical, tmpAdmissionAuthority, admissionsList); }