use of org.nhindirect.stagent.cert.DefaultCertStoreCachePolicy in project nhin-d by DirectProject.
the class XMLSmtpAgentConfig method buildPublicCertStore.
/*
* Build the certificate resolver for public certificates
*/
@SuppressWarnings("unchecked")
private void buildPublicCertStore(Node publicCertNode) {
Provider<CertificateResolver> resolverProvider = null;
if (publicCertNode.getNodeType() == Node.ELEMENT_NODE) {
Element certNode = (Element) publicCertNode;
String storeType = certNode.getAttribute("type");
/*
* KeyStore based resolver
*/
if (storeType.equalsIgnoreCase("keystore")) {
resolverProvider = new KeyStoreCertificateStoreProvider(certNode.getAttribute("file"), certNode.getAttribute("filePass"), certNode.getAttribute("privKeyPass"));
} else /*
* DNS resolver
*/
if (storeType.equalsIgnoreCase("dns")) {
resolverProvider = new DNSCertStoreProvider(Collections.EMPTY_LIST, null, new DefaultCertStoreCachePolicy());
} else /*
* Default to DNS with a default cache policy
*/
{
resolverProvider = new DNSCertStoreProvider(Collections.EMPTY_LIST, null, new DefaultCertStoreCachePolicy());
}
}
resolverProviders.add(resolverProvider);
}
use of org.nhindirect.stagent.cert.DefaultCertStoreCachePolicy in project nhin-d by DirectProject.
the class XMLSmtpAgentConfig method buildLdapCertificateStoreProvider.
/**
* This will build an LdapCertificateStoreProvider to be used to grab certificates from the LDAP store.
* @param anchorStoreNode - The Element node in the xml file that contains anchor information
* @param cacheStoreName - The name of the bootstrap cacheStore used when cache and LDAP are unreachable.
* @return
*/
protected LdapCertificateStoreProvider buildLdapCertificateStoreProvider(Element anchorStoreNode, String cacheStoreName) {
//required
String[] ldapURL = anchorStoreNode.getAttribute("ldapURL").split(",");
String ldapSearchBase = anchorStoreNode.getAttribute("ldapSearchBase");
String ldapSearchAttr = anchorStoreNode.getAttribute("ldapSearchAttr");
String ldapCertAttr = anchorStoreNode.getAttribute("ldapCertAttr");
String ldapCertFormat = anchorStoreNode.getAttribute("ldapCertFormat");
if (ldapURL[0].isEmpty() || ldapSearchBase.isEmpty() || ldapSearchAttr.isEmpty() || ldapCertAttr.isEmpty() || ldapCertFormat.isEmpty()) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat);
}
//optional
String ldapUser = anchorStoreNode.getAttribute("ldapUser");
String ldapPassword = anchorStoreNode.getAttribute("ldapPassword");
String ldapConnTimeout = anchorStoreNode.getAttribute("ldapConnTimeout");
String ldapCertPassphrase = anchorStoreNode.getAttribute("ldapCertPassphrase");
if (ldapCertFormat.equalsIgnoreCase("pkcs12") && ldapCertPassphrase.isEmpty()) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat);
}
LdapStoreConfiguration ldapStoreConfiguration = new LdapStoreConfiguration(ldapURL, ldapSearchBase, ldapSearchAttr, ldapCertAttr, ldapCertFormat);
if (!(ldapUser.isEmpty() && ldapPassword.isEmpty())) {
ldapStoreConfiguration.setEmployLdapAuthInformation(new EmployLdapAuthInformation(ldapUser, ldapPassword));
}
if (!ldapConnTimeout.isEmpty()) {
ldapStoreConfiguration.setLdapConnectionTimeOut(ldapConnTimeout);
}
if (!ldapCertPassphrase.isEmpty()) {
ldapStoreConfiguration.setLdapCertPassphrase(ldapCertPassphrase);
}
LdapCertificateStoreProvider ldapCertificateStoreProvider = new LdapCertificateStoreProvider(ldapStoreConfiguration, null, new DefaultCertStoreCachePolicy());
return ldapCertificateStoreProvider;
}
use of org.nhindirect.stagent.cert.DefaultCertStoreCachePolicy in project nhin-d by DirectProject.
the class CacheableKeyStoreManagerCertificateStore_constructTest method testContrust_providedStoreAndCachePolicy_assertNonEmptyStoreAndCustomPolicy.
public void testContrust_providedStoreAndCachePolicy_assertNonEmptyStoreAndCustomPolicy() throws Exception {
DefaultCertStoreCachePolicy policy = new DefaultCertStoreCachePolicy();
policy.setMaxItems(456);
policy.setSubjectTTL(999);
final BootstrappedKeyStoreProtectionManager mgr = new BootstrappedKeyStoreProtectionManager();
final CacheableKeyStoreManagerCertificateStore store = new CacheableKeyStoreManagerCertificateStore(mgr, policy);
assertNotNull(store.storeMgr);
assertNotNull(store.cachePolicy);
assertEquals(456, store.cachePolicy.getMaxItems());
assertEquals(999, store.cachePolicy.getSubjectTTL());
}
Aggregations