use of java.security.cert.CRLException in project Openfire by igniterealtime.
the class ClientTrustManager method loadCRL.
private void loadCRL() {
File crlFile = new File(JiveGlobals.getProperty("xmpp.client.certificate.crl", "resources" + File.separator + "security" + File.separator + "crl.pem"));
if (!crlFile.isFile()) {
Log.debug("ClientTrustmanager: crl file not found " + crlFile.toString());
useCRLs = false;
return;
}
long modified = crlFile.lastModified();
if (modified > crlLastUpdated) {
crlLastUpdated = modified;
Log.debug("ClientTrustManager: Updating CRLs");
useCRLs = false;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509CRL crl;
FileInputStream crlStream = new FileInputStream(crlFile);
BufferedInputStream crlBuffer = new BufferedInputStream(crlStream);
//remove existing CRLs
crls.clear();
while (crlBuffer.available() > 0) {
crl = (X509CRL) cf.generateCRL(crlBuffer);
Log.debug("ClientTrustManager: adding CRL for " + crl.getIssuerDN());
crls.add(crl);
}
useCRLs = true;
} catch (FileNotFoundException e) {
// Its ok if the file wasnt found- maybe we dont have any CRL's
Log.debug("ClientTrustManager: CRL file not found: " + crlFile.toString());
} catch (IOException e) {
//Thrown bot the input streams
Log.error("ClientTrustManager: IOException while parsing CRLs", e);
} catch (CertificateException e) {
//Thrown by CertificateFactory.getInstance(...)
Log.error("ClientTrustManager: ", e);
} catch (CRLException e) {
Log.error("ClientTrustManager: CRLException while parsing CRLs", e);
}
}
}
use of java.security.cert.CRLException 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.CRLException in project robovm by robovm.
the class X509CRLObject method verify.
public void verify(PublicKey key, String sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
if (!c.getSignatureAlgorithm().equals(c.getTBSCertList().getSignature())) {
throw new CRLException("Signature algorithm on CertificateList does not match TBSCertList.");
}
Signature sig;
if (sigProvider != null) {
sig = Signature.getInstance(getSigAlgName(), sigProvider);
} else {
sig = Signature.getInstance(getSigAlgName());
}
sig.initVerify(key);
sig.update(this.getTBSCertList());
if (!sig.verify(this.getSignature())) {
throw new SignatureException("CRL does not verify with supplied public key.");
}
}
use of java.security.cert.CRLException in project robovm by robovm.
the class CRLExceptionTest method testCRLException06.
/**
* Test for <code>CRLException(String, Throwable)</code> constructor
* Assertion: constructs CRLException when <code>cause</code> is null
* <code>msg</code> is null
*/
public void testCRLException06() {
CRLException tE = new CRLException(null, null);
assertNull("getMessage() must return null", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.cert.CRLException in project robovm by robovm.
the class CRLExceptionTest method testCRLException03.
/**
* Test for <code>CRLException(String)</code> constructor Assertion:
* constructs CRLException when <code>msg</code> is null
*/
public void testCRLException03() {
String msg = null;
CRLException tE = new CRLException(msg);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
Aggregations