use of java.security.cert.CRL in project j2objc by google.
the class CRLTest method testGetType02.
/**
* Test #2 for <code>getType()</code> method<br>
* Assertion: returns <code>CRL</code> type
*/
public final void testGetType02() {
CRL crl = new MyCRL(null);
assertNull(crl.getType());
}
use of java.security.cert.CRL in project j2objc by google.
the class myCertificateFactory method testCertificateFactory11.
/*
* Test for <code> generateCertificate(InputStream inStream) </code><code>
* generateCertificates(InputStream inStream) </code><code>
* generateCRL(InputStream inStream) </code><code>
* generateCRLs(InputStream inStream) </code>
* methods
* Assertion: throw CertificateException and CRLException when inStream
* contains incompatible datas
*/
public void testCertificateFactory11() throws IOException {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
MyCertificate mc = createMC();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(mc);
oos.flush();
oos.close();
Certificate cer;
Collection<?> colCer;
CRL crl;
Collection<?> colCrl;
byte[] arr = os.toByteArray();
ByteArrayInputStream is;
for (int i = 0; i < certFs.length; i++) {
is = new ByteArrayInputStream(arr);
try {
cer = certFs[i].generateCertificate(is);
assertNull("Not null certificate was created", cer);
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCer = certFs[i].generateCertificates(is);
if (colCer != null) {
assertTrue("Not empty certificate Collection was created", colCer.isEmpty());
}
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
crl = certFs[i].generateCRL(is);
assertNull("Not null CRL was created", crl);
} catch (CRLException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCrl = certFs[i].generateCRLs(is);
if (colCrl != null) {
assertTrue("Not empty CRL Collection was created", colCrl.isEmpty());
}
} catch (CRLException e) {
}
}
}
use of java.security.cert.CRL in project java-chassis by ServiceComb.
the class KeyStoreUtil method createCRL.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static CRL[] createCRL(String crlfile) {
InputStream is = null;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
is = new FileInputStream(crlfile);
Collection c = cf.generateCRLs(is);
CRL[] crls = (CRL[]) c.toArray(new CRL[c.size()]);
return crls;
} catch (CertificateException e) {
throw new IllegalArgumentException("bad cert file.");
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("crl file not found.");
} catch (CRLException e) {
throw new IllegalArgumentException("bad crl file.");
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
ignore();
}
}
}
}
use of java.security.cert.CRL in project jruby-openssl by jruby.
the class Lookup method loadCRLFile.
/**
* c: X509_LOOKUP_load_crl_file
*/
public int loadCRLFile(final String file, final int type) throws Exception {
if (file == null)
return 1;
BufferedReader reader = null;
try {
InputStream in = wrapJRubyNormalizedInputStream(file);
CRL crl;
if (type == X509_FILETYPE_PEM) {
reader = new BufferedReader(new InputStreamReader(in));
int count = 0;
for (; ; ) {
crl = PEMInputOutput.readX509CRL(reader, null);
if (crl == null)
break;
if (store.addCRL(crl) == 0)
return 0;
count++;
}
return count;
} else if (type == X509_FILETYPE_ASN1) {
crl = SecurityHelper.getCertificateFactory("X.509").generateCRL(in);
// }
return store.addCRL(crl);
} else {
X509Error.addError(X509_R_BAD_X509_FILETYPE);
// NOTE: really?
return 0;
}
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception ignored) {
}
}
}
}
Aggregations