*
* @throws Exception if failed to initialize all the services
*/
private void initializeSecurityServices() throws Exception {
// we need a socket builder - this is the thing that allows us to provide custom keystore information
SSLSocketBuilder socket_builder = new SSLSocketBuilder();
socket_builder.setUseSSLServerSocketFactory(false);
socket_builder.setSecureSocketProtocol(m_configuration.getConnectorSecuritySocketProtocol());
socket_builder.setKeyStoreAlgorithm(m_configuration.getConnectorSecurityKeystoreAlgorithm());
socket_builder.setKeyStoreType(m_configuration.getConnectorSecurityKeystoreType());
socket_builder.setKeyStorePassword(m_configuration.getConnectorSecurityKeystorePassword());
socket_builder.setKeyPassword(m_configuration.getConnectorSecurityKeystoreKeyPassword());
socket_builder.setTrustStoreAlgorithm(m_configuration.getConnectorSecurityTruststoreAlgorithm());
socket_builder.setTrustStoreType(m_configuration.getConnectorSecurityTruststoreType());
socket_builder.setTrustStorePassword(m_configuration.getConnectorSecurityTruststorePassword());
socket_builder.setClientAuthMode(m_configuration.getConnectorSecurityClientAuthMode());
socket_builder.setServerSocketUseClientMode(false);
try {
// this allows the configured keystore file to be a URL, file path or a resource relative to our classloader
socket_builder.setKeyStoreURL(m_configuration.getConnectorSecurityKeystoreFile());
} catch (Exception e) {
// this probably is due to the fact that the keystore doesn't exist yet - let's prepare one now
createKeyStore();
// now try to set it again, if an exception is still thrown, it's an unrecoverable error
socket_builder.setKeyStoreURL(m_configuration.getConnectorSecurityKeystoreFile());
}
try {
// this allows the configured keystore file to be a URL, file path or a resource relative to our classloader
socket_builder.setTrustStoreURL(m_configuration.getConnectorSecurityTruststoreFile());
} catch (Exception e) {
// this may or may not be a bad thing - let's just log a message but keep going
if (!m_configuration.getConnectorSecurityClientAuthMode().equals(SSLSocketBuilder.CLIENT_AUTH_MODE_NONE)) {
LOG.debug(CommI18NResourceKeys.SERVICE_CONTAINER_TRUSTSTORE_FAILURE);
}