Method readCertsFromHarddrive
File certDir = new File(this._merlinsCertificatesDir);
ArrayList al = new ArrayList();
String[] names = certDir.list();
for (int i = 0; i < names.length; i++) {
String currentFileName = names[i];
if (currentFileName.endsWith(".crt")) {
al.add(names[i]);
}
}
CertificateFactory cf = null;
try {
cf = CertificateFactory.getInstance("X.509");
} catch (CertificateException ex) {
throw new StorageResolverException("empty", ex);
}
if (cf == null) {
throw new StorageResolverException("empty");
}
for (int i = 0; i < al.size(); i++) {
String filename = certDir.getAbsolutePath() + File.separator
+ (String) al.get(i);
File file = new File(filename);
boolean added = false;
String dn = null;
try {
FileInputStream fis = new FileInputStream(file);
X509Certificate cert =
(X509Certificate) cf.generateCertificate(fis);
fis.close();
//add to ArrayList
cert.checkValidity();
this._certs.add(cert);
dn = cert.getSubjectDN().getName();
added = true;
} catch (FileNotFoundException ex) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
} catch (IOException ex) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
} catch (CertificateNotYetValidException ex) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
} catch (CertificateExpiredException ex) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
} catch (CertificateException ex) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
}
if (added) {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Added certificate: " + dn);
}
}