Search in sources :

Example 6 with JCS

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;
}
Also used : JCS(org.apache.jcs.JCS) X509Certificate(java.security.cert.X509Certificate)

Aggregations

JCS (org.apache.jcs.JCS)6 X509Certificate (java.security.cert.X509Certificate)5 CacheException (org.apache.jcs.access.exception.CacheException)3 Thumbprint (org.nhindirect.stagent.cert.Thumbprint)1