use of java.security.cert.X509CRL in project robovm by robovm.
the class PKIXCRLUtil method findCRLs.
public Set findCRLs(X509CRLStoreSelector crlselect, ExtendedPKIXParameters paramsPKIX, Date currentDate) throws AnnotatedException {
Set initialSet = new HashSet();
// get complete CRL(s)
try {
initialSet.addAll(findCRLs(crlselect, paramsPKIX.getAdditionalStores()));
initialSet.addAll(findCRLs(crlselect, paramsPKIX.getStores()));
initialSet.addAll(findCRLs(crlselect, paramsPKIX.getCertStores()));
} catch (AnnotatedException e) {
throw new AnnotatedException("Exception obtaining complete CRLs.", e);
}
Set finalSet = new HashSet();
Date validityDate = currentDate;
if (paramsPKIX.getDate() != null) {
validityDate = paramsPKIX.getDate();
}
// based on RFC 5280 6.3.3
for (Iterator it = initialSet.iterator(); it.hasNext(); ) {
X509CRL crl = (X509CRL) it.next();
if (crl.getNextUpdate().after(validityDate)) {
X509Certificate cert = crlselect.getCertificateChecking();
if (cert != null) {
if (crl.getThisUpdate().before(cert.getNotAfter())) {
finalSet.add(crl);
}
} else {
finalSet.add(crl);
}
}
}
return finalSet;
}
use of java.security.cert.X509CRL in project jdk8u_jdk by JetBrains.
the class Pair method printCRL.
private void printCRL(CRL crl, PrintStream out) throws Exception {
if (rfc) {
X509CRL xcrl = (X509CRL) crl;
out.println("-----BEGIN X509 CRL-----");
out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(xcrl.getEncoded()));
out.println("-----END X509 CRL-----");
} else {
out.println(crl.toString());
}
}
use of java.security.cert.X509CRL in project jdk8u_jdk by JetBrains.
the class CertUtils method getCRLFromFile.
/**
* Get a DER-encoded X.509 CRL from a file.
*
* @param crlFilePath path to file containing DER-encoded CRL
* @return X509CRL
* @throws IOException on error
*/
public static X509CRL getCRLFromFile(String crlFilePath) throws IOException {
X509CRL crl = null;
try {
File crlFile = new File(System.getProperty("test.src", "."), crlFilePath);
if (!crlFile.canRead())
throw new IOException("File " + crlFile.toString() + " is not a readable file.");
FileInputStream crlFileInputStream = new FileInputStream(crlFile);
CertificateFactory cf = CertificateFactory.getInstance("X509");
crl = (X509CRL) cf.generateCRL(crlFileInputStream);
} catch (Exception e) {
e.printStackTrace();
throw new IOException("Can't construct X509CRL: " + e.getMessage());
}
return crl;
}
use of java.security.cert.X509CRL in project oxAuth by GluuFederation.
the class CRLCertificateVerifier method requestCRL.
public X509CRL requestCRL(String url) throws IOException, MalformedURLException, CertificateException, CRLException {
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
try {
con.setUseCaches(false);
InputStream in = new BoundedInputStream(con.getInputStream(), maxCrlSize);
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
X509CRL crl = (X509CRL) certificateFactory.generateCRL(in);
log.debug("CRL size: " + crl.getEncoded().length + " bytes");
return crl;
} finally {
IOUtils.closeQuietly(in);
}
} catch (IOException ex) {
log.error("Failed to download CRL from '" + url + "'", ex);
} finally {
if (con != null) {
con.disconnect();
}
}
return null;
}
use of java.security.cert.X509CRL in project jdk8u_jdk by JetBrains.
the class GenerationTests method test_create_signature_x509_crt_crl.
static void test_create_signature_x509_crt_crl() throws Exception {
System.out.println("* Generating signature-x509-crt-crl.xml");
List<Object> xds = new ArrayList<Object>();
CertificateFactory cf = CertificateFactory.getInstance("X.509");
xds.add(signingCert);
FileInputStream fis = new FileInputStream(CRL);
X509CRL crl = (X509CRL) cf.generateCRL(fis);
fis.close();
xds.add(crl);
KeyInfo crt_crl = kifac.newKeyInfo(Collections.singletonList(kifac.newX509Data(xds)));
test_create_signature_external(dsaSha1, crt_crl, signingKey, new X509KeySelector(ks), false);
System.out.println();
}
Aggregations