use of org.apache.jcs.access.exception.CacheException in project nhin-d by DirectProject.
the class CacheableKeyStoreManagerCertificateStore method applyCachePolicy.
private void applyCachePolicy(CertStoreCachePolicy policy) {
if (getCache() != null) {
try {
ICompositeCacheAttributes attributes = cache.getCacheAttributes();
attributes.setMaxObjects(policy.getMaxItems());
attributes.setUseLateral(false);
attributes.setUseRemote(false);
cache.setCacheAttributes(attributes);
IElementAttributes eattributes = cache.getDefaultElementAttributes();
eattributes.setMaxLifeSeconds(policy.getSubjectTTL());
eattributes.setIsEternal(false);
eattributes.setIsLateral(false);
eattributes.setIsRemote(false);
cache.setDefaultElementAttributes(eattributes);
} catch (CacheException e) {
// no-op
}
}
}
use of org.apache.jcs.access.exception.CacheException in project nhin-d by DirectProject.
the class CacheableKeyStoreManagerCertificateStore method getCertificates.
///CLOVER:ON
/**
* {@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;
final JCS cache = getCache();
if (cache != null) {
retVal = (Collection<X509Certificate>) cache.get(realSubjectName);
if (retVal == null || retVal.size() == 0)
retVal = super.getCertificates(subjectName);
} else
// cache miss
retVal = super.getCertificates(subjectName);
if (retVal == null || retVal.size() == 0) {
LOGGER.info("getCertificates(String subjectName) - Could not find a PKCS11 certificate for subject " + subjectName);
} else {
try {
if (cache != null)
cache.put(realSubjectName, retVal);
} catch (CacheException e) {
/*
* no-opss
*/
}
}
return retVal;
}
use of org.apache.jcs.access.exception.CacheException in project nhin-d by DirectProject.
the class DNSCertificateStore method applyCachePolicy.
private void applyCachePolicy(CertStoreCachePolicy policy) {
if (getCache() != null) {
try {
ICompositeCacheAttributes attributes = cache.getCacheAttributes();
attributes.setMaxObjects(policy.getMaxItems());
attributes.setUseLateral(false);
attributes.setUseRemote(false);
cache.setCacheAttributes(attributes);
IElementAttributes eattributes = cache.getDefaultElementAttributes();
eattributes.setMaxLifeSeconds(policy.getSubjectTTL());
eattributes.setIsEternal(false);
eattributes.setIsLateral(false);
eattributes.setIsRemote(false);
cache.setDefaultElementAttributes(eattributes);
} catch (CacheException e) {
// TODO: Handle exception
}
}
}
use of org.apache.jcs.access.exception.CacheException in project nhin-d by DirectProject.
the class ConfigServiceCertificateStore method lookupFromConfigStore.
private Collection<X509Certificate> lookupFromConfigStore(String subjectName) {
String domain;
org.nhind.config.Certificate[] certificates;
try {
certificates = proxy.getCertificatesForOwner(subjectName, null);
} catch (Exception e) {
throw new NHINDException("WebService error getting certificates by subject: " + e.getMessage(), e);
}
if (certificates == null || certificates.length == 0) {
// try again with the domain name
int index;
if ((index = subjectName.indexOf("@")) > -1)
domain = subjectName.substring(index + 1);
else
domain = subjectName;
try {
certificates = proxy.getCertificatesForOwner(domain, null);
} catch (Exception e) {
throw new NHINDException("WebService error getting certificates by domain: " + e.getMessage(), e);
}
}
if (certificates == null || certificates.length == 0)
return Collections.emptyList();
Collection<X509Certificate> retVal = new ArrayList<X509Certificate>();
for (org.nhind.config.Certificate cert : certificates) {
X509Certificate storeCert = CertStoreUtils.certFromData(mgr, cert.getData());
retVal.add(storeCert);
if (localStoreDelegate != null) {
if (localStoreDelegate.contains(storeCert))
localStoreDelegate.update(storeCert);
else
localStoreDelegate.add(storeCert);
}
}
// add to JCS and cache
try {
if (cache != null)
cache.put(subjectName, retVal);
} catch (CacheException e) {
/*
* TODO: handle exception
*/
}
return retVal;
}
use of org.apache.jcs.access.exception.CacheException in project nhin-d by DirectProject.
the class ConfigServiceRESTCertificateStore method applyCachePolicy.
private void applyCachePolicy(CertStoreCachePolicy policy) {
if (getCache() != null) {
try {
ICompositeCacheAttributes attributes = cache.getCacheAttributes();
attributes.setMaxObjects(policy.getMaxItems());
attributes.setUseLateral(false);
attributes.setUseRemote(false);
cache.setCacheAttributes(attributes);
IElementAttributes eattributes = cache.getDefaultElementAttributes();
eattributes.setMaxLifeSeconds(policy.getSubjectTTL());
eattributes.setIsEternal(false);
eattributes.setIsLateral(false);
eattributes.setIsRemote(false);
cache.setDefaultElementAttributes(eattributes);
} catch (CacheException e) {
// TODO: Handle exception
}
}
}
Aggregations