static URI getResponderURI(X509CertImpl certImpl) { // Examine the certificate's AuthorityInfoAccess extension AuthorityInfoAccessExtension aia = certImpl.getAuthorityInfoAccessExtension(); if (aia == null) { return null; } List<AccessDescription> descriptions = aia.getAccessDescriptions(); for (AccessDescription description : descriptions) { if (description.getAccessMethod().equals((Object) AccessDescription.Ad_OCSP_Id)) { GeneralName generalName = description.getAccessLocation(); if (generalName.getType() == GeneralNameInterface.NAME_URI) { URIName uri = (URIName) generalName.getName(); return uri.getURI(); } } } return null; }
/** * Creates a CertStore from information included in the AccessDescription * object of a certificate's Authority Information Access Extension. */ static CertStore getInstance(AccessDescription ad) { if (!ad.getAccessMethod().equals((Object) AccessDescription.Ad_CAISSUERS_Id)) { return null; } GeneralNameInterface gn = ad.getAccessLocation().getName(); if (!(gn instanceof URIName)) { return null; } URI uri = ((URIName) gn).getURI(); try { return URICertStore.getInstance (new URICertStore.URICertStoreParameters(uri)); } catch (Exception ex) { if (debug != null) { debug.println("exception creating CertStore: " + ex); ex.printStackTrace(); } return null; } }
static URI getResponderURI(X509CertImpl certImpl) { // Examine the certificate's AuthorityInfoAccess extension AuthorityInfoAccessExtension aia = certImpl.getAuthorityInfoAccessExtension(); if (aia == null) { return null; } List<AccessDescription> descriptions = aia.getAccessDescriptions(); for (AccessDescription description : descriptions) { if (description.getAccessMethod().equals( AccessDescription.Ad_OCSP_Id)) { GeneralName generalName = description.getAccessLocation(); if (generalName.getType() == GeneralNameInterface.NAME_URI) { URIName uri = (URIName) generalName.getName(); return uri.getURI(); } } } return null; }
/** * Creates a CertStore from information included in the AccessDescription * object of a certificate's Authority Information Access Extension. */ static CertStore getInstance(AccessDescription ad) { if (!ad.getAccessMethod().equals( AccessDescription.Ad_CAISSUERS_Id)) { return null; } GeneralNameInterface gn = ad.getAccessLocation().getName(); if (!(gn instanceof URIName)) { return null; } URI uri = ((URIName) gn).getURI(); try { return URICertStore.getInstance(new URICertStoreParameters(uri)); } catch (Exception ex) { if (debug != null) { debug.println("exception creating CertStore: " + ex); ex.printStackTrace(); } return null; } }
/** * Creates a CertStore from information included in the AccessDescription * object of a certificate's Authority Information Access Extension. */ static CertStore getInstance(AccessDescription ad) { if (!ad.getAccessMethod().equals(AccessDescription.Ad_CAISSUERS_Id)) { return null; } GeneralNameInterface gn = ad.getAccessLocation().getName(); if (!(gn instanceof URIName)) { return null; } URI uri = ((URIName) gn).getURI(); try { return URICertStore.getInstance (new URICertStore.URICertStoreParameters(uri)); } catch (Exception ex) { if (debug != null) { debug.println("exception creating CertStore: " + ex); ex.printStackTrace(); } return null; } }
/** * Download Certificates from the given AIA and add them to the * specified Collection. */ // cs.getCertificates(caSelector) returns a collection of X509Certificate's // because of the selector, so the cast is safe @SuppressWarnings("unchecked") private boolean getCerts(AuthorityInfoAccessExtension aiaExt, Collection<X509Certificate> certs) { if (Builder.USE_AIA == false) { return false; } List<AccessDescription> adList = aiaExt.getAccessDescriptions(); if (adList == null || adList.isEmpty()) { return false; } boolean add = false; for (AccessDescription ad : adList) { CertStore cs = URICertStore.getInstance(ad); if (cs != null) { try { if (certs.addAll((Collection<X509Certificate>) cs.getCertificates(caSelector))) { add = true; if (!searchAllCertStores) { return true; } } } catch (CertStoreException cse) { if (debug != null) { debug.println("exception getting certs from CertStore:"); cse.printStackTrace(); } } } } return add; }
/** * Helper method to add one or more OCSP URIs to the Authority Info Access * certificate extension. * * @param locations A list of one or more OCSP responder URIs as strings * * @throws IOException if an encoding error occurs. */ public void addAIAExt(List<String> locations) throws IOException { if (!locations.isEmpty()) { List<AccessDescription> acDescList = new ArrayList<>(); for (String ocspUri : locations) { acDescList.add(new AccessDescription( AccessDescription.Ad_OCSP_Id, new GeneralName(new URIName(ocspUri)))); } addExtension(new AuthorityInfoAccessExtension(acDescList)); } }
/** * Download Certificates from the given AIA and add them to the * specified Collection. */ private boolean getCerts(AuthorityInfoAccessExtension aiaExt, Collection<X509Certificate> certs) { if (Builder.USE_AIA == false) { return false; } List<AccessDescription> adList = aiaExt.getAccessDescriptions(); if (adList == null || adList.isEmpty()) { return false; } boolean add = false; for (AccessDescription ad : adList) { CertStore cs = URICertStore.getInstance(ad); try { if (certs.addAll((Collection<X509Certificate>) cs.getCertificates(caSelector))) { add = true; if (!searchAllCertStores) { return true; } } } catch (CertStoreException cse) { if (debug != null) { debug.println("exception getting certs from CertStore:"); cse.printStackTrace(); } continue; } } return add; }
/** * Download Certificates from the given AIA and add them to the * specified Collection. */ private boolean getCerts(AuthorityInfoAccessExtension aiaExt, Collection<X509Certificate> certs) { if (Builder.USE_AIA == false) { return false; } List<AccessDescription> adList = aiaExt.getAccessDescriptions(); if (adList == null || adList.isEmpty()) { return false; } boolean add = false; for (AccessDescription ad : adList) { CertStore cs = URICertStore.getInstance(ad); if (cs != null) { try { if (certs.addAll((Collection<X509Certificate>) cs.getCertificates(caSelector))) { add = true; if (!searchAllCertStores) { return true; } } } catch (CertStoreException cse) { if (debug != null) { debug.println("exception getting certs from CertStore:"); cse.printStackTrace(); } continue; } } } return add; }