use of java.security.cert.X509CRL in project robovm by robovm.
the class X509CRLSelector2Test method testMatchLjava_security_cert_X509CRL.
/**
* match(CRL crl) method testing. Tests if the null object matches to the
* selector or not.
*/
public void testMatchLjava_security_cert_X509CRL() {
X509CRLSelector selector = new X509CRLSelector();
assertFalse("The null object should not match", selector.match((X509CRL) null));
}
use of java.security.cert.X509CRL in project robovm by robovm.
the class CMSUtils method getCRLsFromStore.
static List getCRLsFromStore(CertStore certStore) throws CertStoreException, CMSException {
List crls = new ArrayList();
try {
for (Iterator it = certStore.getCRLs(null).iterator(); it.hasNext(); ) {
X509CRL c = (X509CRL) it.next();
crls.add(CertificateList.getInstance(ASN1Primitive.fromByteArray(c.getEncoded())));
}
return crls;
} catch (IllegalArgumentException e) {
throw new CMSException("error processing crls", e);
} catch (IOException e) {
throw new CMSException("error processing crls", e);
} catch (CRLException e) {
throw new CMSException("error encoding crls", e);
}
}
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;
}
Aggregations