/** * Returns the issuer distinguished name of this CRL. * * @return the issuer distinguished name of this CRL. */ public X500Principal getIssuerX500Principal() { try { // TODO if there is no X.509 certificate provider installed // should we try to access Harmony X509CRLImpl via classForName? CertificateFactory factory = CertificateFactory .getInstance("X.509"); X509CRL crl = (X509CRL) factory .generateCRL(new ByteArrayInputStream(getEncoded())); return crl.getIssuerX500Principal(); } catch (Exception e) { throw new RuntimeException("Failed to get X500Principal issuer", e); } }
crl = (X509CRL)cf.generateCRL(crlBuffer); Log.debug("ClientTrustManager: adding CRL for "+crl.getIssuerDN()); crls.add(crl);
/** * Load a CRL. Does NOT Close the stream. * * @return non-null * @since 0.9.25 public since 0.9.26 */ public static X509CRL loadCRL(InputStream in) throws GeneralSecurityException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); return (X509CRL) cf.generateCRL(in); }
try { crl = (X509CRL) this.certificateFactory .generateCRL(new ByteArrayInputStream(encodedCrl)); } catch (CRLException e) { throw new RuntimeException("CRL parse error: "
/** * Downloads a CRL from given HTTP/HTTPS/FTP URL, e.g. * http://crl.infonotary.com/crl/identity-ca.crl */ public static X509CRL downloadCRLFromWeb(String crlURL) throws IOException, CertificateException, CRLException { try (InputStream crlStream = new URL(crlURL).openStream()) { return (X509CRL) CertificateFactory.getInstance("X.509").generateCRL(crlStream); } }
/** * Downloads a CRL from given LDAP url, e.g. * ldap://ldap.infonotary.com/dc=identity-ca,dc=infonotary,dc=com */ private static X509CRL downloadCRLFromLDAP(String ldapURL) throws CertificateException, NamingException, CRLException, CertificateVerificationException { Hashtable<String, String> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, ldapURL); // https://docs.oracle.com/javase/jndi/tutorial/ldap/connect/create.html // don't wait forever behind corporate proxy env.put("com.sun.jndi.ldap.connect.timeout", "1000"); DirContext ctx = new InitialDirContext(env); Attributes avals = ctx.getAttributes(""); Attribute aval = avals.get("certificateRevocationList;binary"); byte[] val = (byte[]) aval.get(); if (val == null || val.length == 0) { throw new CertificateVerificationException("Can not download CRL from: " + ldapURL); } else { InputStream inStream = new ByteArrayInputStream(val); CertificateFactory cf = CertificateFactory.getInstance("X.509"); return (X509CRL) cf.generateCRL(inStream); } }
rv = (X509CRL)cf.generateCRL(bais); } catch (IllegalArgumentException iae) { throw new GeneralSecurityException("cert error", iae);
/** * Parses a CRL from an InputStream. * * @param input The InputStream holding the unparsed CRL. * @return the parsed CRL object * @throws CertificateException thrown when no provider has been found for X509 * @throws CRLException thrown during parsing the CRL */ static CRL parseCrlFromStream(InputStream input) throws CertificateException, CRLException { return CertificateFactory.getInstance("X.509").generateCRL(input); }
/** * Parses a CRL from an InputStream. * * @param input The InputStream holding the unparsed CRL. * @return the parsed CRL object * @throws CertificateException thrown when no provider has been found for X509 * @throws CRLException thrown during parsing the CRL */ static CRL parseCrlFromStream(InputStream input) throws CertificateException, CRLException { return CertificateFactory.getInstance("X.509").generateCRL(input); }
/** * * @param is * @return * @throws CRLException * @throws CertificateException */ private X509CRL getInstance(InputStream is) throws CRLException, CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X509"); X509CRL crl = (X509CRL) cf.generateCRL(is); return crl; }
/** * * @param is source for creating instance * @return X509CRL * @throws CRLException exception * @throws CertificateException exception */ private X509CRL getInstance(InputStream is) throws CRLException, CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X509"); X509CRL crl = (X509CRL) cf.generateCRL(is); return crl; }
public X509CRL readCRL(File crlFile) throws FileNotFoundException, CRLException, IOException { try (InputStream is = Files.newInputStream(crlFile.toPath())) { return (X509CRL)certFactory.generateCRL(is); } }
/** * Downloads a CRL from given URL * * @param url the web address with given CRL * @throws IOException * @throws CertificateException * @throws CRLException */ private X509CRL downloadCRL(URL url) throws IOException, CertificateException, CRLException { try (InputStream crlStream = url.openStream()) { CertificateFactory cf = CertificateFactory.getInstance("X.509"); return (X509CRL) cf.generateCRL(crlStream); } }
private void initCRL(File file) { try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); FileInputStream fis = new FileInputStream(file); X509CRL crl = (X509CRL) certFactory.generateCRL(fis); revocationLists.add(crl); logger.info("CRL initialized from " + file + ": " + (crl.getRevokedCertificates() == null ? "no revoked certificates" : crl.getRevokedCertificates().size() + " certificates revoked")); } catch (Exception e) { logger.warn("Could not read CRL file {: {}", file, e.getMessage()); } }
public void loadCRLCertStore(URL url) throws Exception { CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509CRL crl = (X509CRL)cf.generateCRL(url.openStream()); this.crlCertStore = CertStore.getInstance( "Collection", new CollectionCertStoreParameters(Collections.singletonList(crl)) ); }
/** {@inheritDoc} */ public X509CRL read(final InputStream in) throws IOException, CryptException { try { return (X509CRL) getX509CertificateFactory().generateCRL(in); } catch (CRLException e) { throw new CryptException("Failed reading X.509 CRL.", e); } } }
private X509CRL unmarshalX509CRL(Element elem) throws MarshalException { try (ByteArrayInputStream bs = unmarshalBase64Binary(elem)) { return (X509CRL)cf.generateCRL(bs); } catch (CRLException e) { throw new MarshalException("Cannot create X509CRL", e); } catch (IOException e) { throw new MarshalException("Error closing stream", e); } }
public static X509CRL parseCrl(InputStream crlStream) throws CertificateException, CRLException { Args.notNull(crlStream, "crlStream"); X509CRL crl = (X509CRL) getCertFactory().generateCRL(crlStream); if (crl == null) { throw new CRLException("the given one is not a valid X.509 CRL"); } return crl; }
public static X509CRL parseCrl(InputStream crlStream) throws CertificateException, CRLException { requireNonNull("crlStream", crlStream); X509CRL crl = (X509CRL) getCertFactory().generateCRL(crlStream); if (crl == null) { throw new CRLException("the given one is not a valid X.509 CRL"); } return crl; }
public static X509CRL parseCrl(final InputStream crlStream) throws CertificateException, CRLException { ParamUtil.requireNonNull("crlStream", crlStream); X509CRL crl = (X509CRL) getCertFactory().generateCRL(crlStream); if (crl == null) { throw new CRLException( "the given one is not a valid X.509 CRL"); } return crl; }