use of org.gluu.persist.ldap.operation.impl.LdapConnectionProvider in project oxTrust by GluuFederation.
the class ManagePersonAuthenticationAction method testLdapConnection.
public String testLdapConnection(GluuLdapConfiguration ldapConfig) {
try {
FileConfiguration configuration = new FileConfiguration(ConfigurationFactory.LDAP_PROPERTIES_FILE);
if (!configuration.isLoaded()) {
configuration = new FileConfiguration(ConfigurationFactory.LDAP_DEFAULT_PROPERTIES_FILE);
}
Properties properties = configuration.getProperties();
properties.setProperty("bindDN", ldapConfig.getBindDN());
properties.setProperty("bindPassword", ldapConfig.getBindPassword());
properties.setProperty("servers", buildServersString(ldapConfig.getServers()));
properties.setProperty("useSSL", Boolean.toString(ldapConfig.isUseSSL()));
LdapConnectionProvider connectionProvider = new LdapConnectionProvider(PropertiesDecrypter.decryptProperties(properties, configurationFactory.getCryptoConfigurationSalt()));
if (connectionProvider.isConnected()) {
connectionProvider.closeConnectionPool();
facesMessages.add(FacesMessage.SEVERITY_INFO, "LDAP Connection Test succeeded!");
return OxTrustConstants.RESULT_SUCCESS;
}
if (connectionProvider.getConnectionPool() != null) {
connectionProvider.closeConnectionPool();
}
} catch (Exception ex) {
log.error("Could not connect to LDAP", ex);
}
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to connect to LDAP server");
return OxTrustConstants.RESULT_FAILURE;
}
use of org.gluu.persist.ldap.operation.impl.LdapConnectionProvider in project oxCore by GluuFederation.
the class LdapEntryManagerFactory method createEntryManager.
@Override
public LdapEntryManager createEntryManager(Properties conf) {
LdapConnectionProvider connectionProvider = new LdapConnectionProvider(conf);
if (!connectionProvider.isCreated()) {
throw new ConfigurationException(String.format("Failed to create LDAP connection pool! Result code: '%s'", connectionProvider.getCreationResultCode()));
}
LOG.debug("Created connectionProvider '{}' with code '{}'", connectionProvider, connectionProvider.getCreationResultCode());
LdapConnectionProvider bindConnectionProvider = new LdapAuthConnectionProvider(conf);
if (!bindConnectionProvider.isCreated()) {
throw new ConfigurationException(String.format("Failed to create LDAP bind connection pool! Result code: '%s'", bindConnectionProvider.getCreationResultCode()));
}
LOG.debug("Created bindConnectionProvider '{}' with code '{}'", bindConnectionProvider, bindConnectionProvider.getCreationResultCode());
LdapEntryManager ldapEntryManager = new LdapEntryManager(new LdapOperationsServiceImpl(connectionProvider, bindConnectionProvider));
LOG.info("Created LdapEntryManager: {}", ldapEntryManager.getOperationService());
return ldapEntryManager;
}
Aggregations