use of org.nhindirect.stagent.module.PrivateCertStoreModule in project nhin-d by DirectProject.
the class RESTSmtpAgentConfig method buildPrivateCertStore.
protected void buildPrivateCertStore() {
Provider<CertificateResolver> resolverProvider = null;
Setting setting = null;
String storeType;
try {
setting = settingsService.getSetting("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 = settingsService.getSetting("PrivateStoreFile");
pass = settingsService.getSetting("PrivateStoreFilePass");
privKeyPass = settingsService.getSetting("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 ConfigServiceRESTCertificateStoreProvider(certificateService, null, new ConfigServiceCertificateStore.DefaultConfigStoreCachePolicy(), this.storeProvider);
} else {
throw new SmtpAgentException(SmtpAgentError.InvalidPrivateCertStoreSettings);
}
privateCertModule = new PrivateCertStoreModule(resolverProvider);
}
use of org.nhindirect.stagent.module.PrivateCertStoreModule 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.stagent.module.PrivateCertStoreModule in project nhin-d by DirectProject.
the class XMLSmtpAgentConfig method buildPrivateCertStore.
/*
* Build the certificates store that hold private certificates.
*/
protected void buildPrivateCertStore(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 if (storeType.equalsIgnoreCase("ldap")) {
resolverProvider = buildLdapCertificateStoreProvider(certNode, "LDAPPrivateCertStore");
} else {
throw new SmtpAgentException(SmtpAgentError.InvalidPrivateCertStoreSettings);
}
}
privateCertModule = new PrivateCertStoreModule(resolverProvider);
;
}
Aggregations