use of org.apache.jcs.JCS in project nhin-d by DirectProject.
the class DNSCertificateStore method getCertificates.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Collection<X509Certificate> getCertificates(String subjectName) {
String realSubjectName;
int index;
if ((index = subjectName.indexOf("EMAILADDRESS=")) > -1)
realSubjectName = subjectName.substring(index + "EMAILADDRESS=".length());
else
realSubjectName = subjectName;
Collection<X509Certificate> retVal;
JCS cache = getCache();
if (cache != null) {
retVal = (Collection<X509Certificate>) cache.get(realSubjectName);
if (retVal == null || retVal.size() == 0) {
retVal = this.lookupDNS(realSubjectName);
if (retVal == null || retVal.size() == 0) {
LOGGER.info("getCertificates(String subjectName) - Could not find a DNS certificate for subject " + subjectName);
}
}
} else // cache miss
{
retVal = this.lookupDNS(realSubjectName);
if (retVal.size() == 0) {
if (localStoreDelegate != null) {
// last ditch effort is to go to the bootstrap cache
retVal = localStoreDelegate.getCertificates(realSubjectName);
if (retVal == null || retVal.size() == 0) {
LOGGER.info("getCertificates(String subjectName) - Could not find a DNS certificate for subject " + subjectName);
}
} else
LOGGER.info("getCertificates(String subjectName) - Could not find a DNS certificate for subject " + subjectName);
}
}
return retVal;
}
Aggregations