if (bis.available() > 0) {
cert = cf.generateCertificate(bis);
if (!(cert instanceof X509Certificate)) {
LOG.error("Certificate " + filename + " is not of type X509Certificate");
throw new IllegalConfigurationException("Certificate "
+ filename + " is not of type X509Certificate");
}
if (bis.available() > 0) {
LOG.warn("There are more certificates configured in " + filename + ". Only first is parsed");
}
return (X509Certificate)cert;
} else {
LOG.error("No bytes can be read in certificate file " + filename);
throw new IllegalConfigurationException("No bytes can be read in certificate file " + filename);
}
} catch (IllegalConfigurationException ex) {
throw ex;
} catch (Exception ex) {
LOG.error("Failed to read certificate file " + filename, ex);
throw new IllegalConfigurationException("Failed to read certificate file " + filename, ex);
} finally {
try {
bis.close();
} catch (IOException ex) {
LOG.error("Failed to close certificate file " + filename, ex);