use of org.nhindirect.gateway.smtp.config.cert.impl.provider.ConfigServiceCertificateStoreProvider in project nhin-d by DirectProject.
the class WSSmtpAgentConfig method buildPrivateCertStore.
protected void buildPrivateCertStore() {
Provider<CertificateResolver> resolverProvider = null;
Setting setting = null;
String storeType;
try {
setting = cfService.getSettingByName("PrivateStoreType");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting public store type: " + e.getMessage(), e);
}
if (setting == null || setting.getValue() == null || setting.getValue().isEmpty())
// default to WS
storeType = STORE_TYPE_WS;
else
storeType = setting.getValue();
/*
* KeyStore based resolver
*/
if (storeType.equalsIgnoreCase(STORE_TYPE_KEYSTORE)) {
Setting file;
Setting pass;
Setting privKeyPass;
try {
file = cfService.getSettingByName("PrivateStoreFile");
pass = cfService.getSettingByName("PrivateStoreFilePass");
privKeyPass = cfService.getSettingByName("PrivateStorePrivKeyPass");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting private store file settings: " + e.getMessage(), e);
}
resolverProvider = new KeyStoreCertificateStoreProvider((file == null) ? null : file.getValue(), (pass == null) ? null : pass.getValue(), (privKeyPass == null) ? null : privKeyPass.getValue());
} else if (storeType.equalsIgnoreCase(STORE_TYPE_LDAP)) {
resolverProvider = buildLdapCertificateStoreProvider("PrivateStore", "LDAPPrivateCertStore");
} else if (storeType.equalsIgnoreCase(STORE_TYPE_WS)) {
resolverProvider = new ConfigServiceCertificateStoreProvider(cfService, null, new ConfigServiceCertificateStore.DefaultConfigStoreCachePolicy(), this.storeProvider);
} else {
throw new SmtpAgentException(SmtpAgentError.InvalidPrivateCertStoreSettings);
}
privateCertModule = new PrivateCertStoreModule(resolverProvider);
}
use of org.nhindirect.gateway.smtp.config.cert.impl.provider.ConfigServiceCertificateStoreProvider in project nhin-d by DirectProject.
the class WSSmtpAgentConfig method buildPublicCertStore.
/*
* Build the certificate resolver for public certificates
*/
@SuppressWarnings("unchecked")
protected void buildPublicCertStore() {
Provider<CertificateResolver> resolverProvider = null;
Collection<Provider<CertificateResolver>> resolverProviders = new ArrayList<Provider<CertificateResolver>>();
Setting setting = null;
String storeTypes;
try {
setting = cfService.getSettingByName("PublicStoreType");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting public store type: " + e.getMessage(), e);
}
if (setting == null || setting.getValue() == null || setting.getValue().isEmpty())
// default to DNS
storeTypes = STORE_TYPE_DNS + "," + STORE_TYPE_PUBLIC_LDAP;
else
storeTypes = setting.getValue();
/*
* KeyStore based resolver
*/
String[] types = storeTypes.split(",");
for (String storeType : types) {
if (storeType.equalsIgnoreCase(STORE_TYPE_KEYSTORE)) {
Setting file;
Setting pass;
Setting privKeyPass;
try {
file = cfService.getSettingByName("PublicStoreFile");
pass = cfService.getSettingByName("PublicStoreFilePass");
privKeyPass = cfService.getSettingByName("PublicStorePrivKeyPass");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting public store file settings: " + e.getMessage(), e);
}
resolverProvider = new KeyStoreCertificateStoreProvider((file == null) ? "PublicStoreKeyFile" : file.getValue(), (pass == null) ? "DefaultFilePass" : pass.getValue(), (privKeyPass == null) ? "DefaultKeyPass" : privKeyPass.getValue());
} else /*
* DNS resolver
*/
if (storeType.equalsIgnoreCase(STORE_TYPE_DNS)) {
resolverProvider = new DNSCertStoreProvider(Collections.EMPTY_LIST, null, new DNSCertificateStore.DefaultDNSCachePolicy());
} else /*
* Web Services
*/
if (storeType.equalsIgnoreCase(STORE_TYPE_WS)) {
resolverProvider = new ConfigServiceCertificateStoreProvider(cfService, null, new ConfigServiceCertificateStore.DefaultConfigStoreCachePolicy(), this.storeProvider);
} else /*
* Public LDAP resolver
*/
if (storeType.equalsIgnoreCase(STORE_TYPE_PUBLIC_LDAP)) {
resolverProvider = new PublicLdapCertificateStoreProvider(null, new LDAPCertificateStore.DefaultLDAPCachePolicy());
} else /*
* Default to DNS with a default cache policy
*/
{
resolverProvider = new DNSCertStoreProvider(Collections.EMPTY_LIST, null, new DNSCertificateStore.DefaultDNSCachePolicy());
}
resolverProviders.add(resolverProvider);
}
publicCertModule = new PublicCertStoreModule(resolverProviders);
}
Aggregations