Search in sources :

Example 1 with LDAPConnectionProvider

use of org.gluu.site.ldap.LDAPConnectionProvider in project oxAuth by GluuFederation.

the class LdapStatusTimer method logConnectionProviderStatistic.

public void logConnectionProviderStatistic(LdapEntryManager ldapEntryManager, String connectionProviderName, String bindConnectionProviderName) {
    LDAPConnectionProvider ldapConnectionProvider = ldapEntryManager.getLdapOperationService().getConnectionProvider();
    LDAPConnectionProvider bindLdapConnectionProvider = ldapEntryManager.getLdapOperationService().getBindConnectionProvider();
    if (ldapConnectionProvider == null) {
        log.error("{} is empty", connectionProviderName);
    } else {
        if (ldapConnectionProvider.getConnectionPool() == null) {
            log.error("{} is empty", connectionProviderName);
        } else {
            log.info("{} statistics: {}", connectionProviderName, ldapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
        }
    }
    if (bindLdapConnectionProvider == null) {
        log.error("{} is empty", bindConnectionProviderName);
    } else {
        if (bindLdapConnectionProvider.getConnectionPool() == null) {
            log.error("{} is empty", bindConnectionProviderName);
        } else {
            log.info("{} statistics: {}", bindConnectionProviderName, bindLdapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
        }
    }
}
Also used : LDAPConnectionProvider(org.gluu.site.ldap.LDAPConnectionProvider)

Example 2 with LDAPConnectionProvider

use of org.gluu.site.ldap.LDAPConnectionProvider in project oxCore by GluuFederation.

the class LdapSampleEntryManager method createBindConnectionProvider.

private LDAPConnectionProvider createBindConnectionProvider(Properties bindConnectionProperties, Properties connectionProperties) {
    LDAPConnectionProvider bindConnectionProvider = createConnectionProvider(bindConnectionProperties);
    if (ResultCode.INAPPROPRIATE_AUTHENTICATION.equals(bindConnectionProvider.getCreationResultCode())) {
        log.warn("It's not possible to create authentication LDAP connection pool using anonymous bind. Attempting to create it using binDN/bindPassword");
        bindConnectionProvider = createConnectionProvider(connectionProperties);
    }
    return bindConnectionProvider;
}
Also used : LDAPConnectionProvider(org.gluu.site.ldap.LDAPConnectionProvider)

Example 3 with LDAPConnectionProvider

use of org.gluu.site.ldap.LDAPConnectionProvider in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method testLdapConnection.

public String testLdapConnection() {
    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", this.ldapConfig.getBindDN());
        properties.setProperty("bindPassword", this.ldapConfig.getBindPassword());
        properties.setProperty("servers", buildServersString(this.ldapConfig.getServers()));
        properties.setProperty("useSSL", Boolean.toString(this.ldapConfig.isUseSSL()));
        LDAPConnectionProvider connectionProvider = new LDAPConnectionProvider(PropertiesDecrypter.decryptProperties(properties, configurationFactory.getCryptoConfigurationSalt()));
        if (connectionProvider.isConnected()) {
            connectionProvider.closeConnectionPool();
            return OxTrustConstants.RESULT_SUCCESS;
        }
        connectionProvider.closeConnectionPool();
        return OxTrustConstants.RESULT_FAILURE;
    } catch (Exception ex) {
        log.error("Could not connect to LDAP", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) Properties(java.util.Properties) LDAPConnectionProvider(org.gluu.site.ldap.LDAPConnectionProvider) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 4 with LDAPConnectionProvider

use of org.gluu.site.ldap.LDAPConnectionProvider in project oxTrust by GluuFederation.

the class Configuration method createLdapEntryManager.

private LdapEntryManager createLdapEntryManager() {
    Properties connectionProperties = (Properties) this.ldapConfiguration.getProperties();
    Properties decryptedConnectionProperties = PropertiesDecrypter.decryptProperties(connectionProperties, this.cryptoConfigurationSalt);
    LDAPConnectionProvider connectionProvider = new LDAPConnectionProvider(decryptedConnectionProperties);
    LdapEntryManager ldapEntryManager = new LdapEntryManager(new OperationsFacade(connectionProvider, null));
    logger.debug("Created LdapEntryManager: {}", ldapEntryManager);
    return ldapEntryManager;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) OperationsFacade(org.gluu.site.ldap.OperationsFacade) Properties(java.util.Properties) LDAPConnectionProvider(org.gluu.site.ldap.LDAPConnectionProvider)

Example 5 with LDAPConnectionProvider

use of org.gluu.site.ldap.LDAPConnectionProvider in project oxTrust by GluuFederation.

the class LdapStatusTimer method logConnectionProviderStatistic.

public void logConnectionProviderStatistic(LdapEntryManager ldapEntryManager, String connectionProviderName, String bindConnectionProviderName) {
    LDAPConnectionProvider ldapConnectionProvider = ldapEntryManager.getLdapOperationService().getConnectionProvider();
    LDAPConnectionProvider bindLdapConnectionProvider = ldapEntryManager.getLdapOperationService().getBindConnectionProvider();
    if (ldapConnectionProvider == null) {
        log.error("{} is empty", connectionProviderName);
    } else {
        if (ldapConnectionProvider.getConnectionPool() == null) {
            log.error("{} is empty", connectionProviderName);
        } else {
            log.info("{} statistics: {}", connectionProviderName, ldapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
        }
    }
    if (bindLdapConnectionProvider == null) {
        log.error("{} is empty", bindConnectionProviderName);
    } else {
        if (bindLdapConnectionProvider.getConnectionPool() == null) {
            log.error("{} is empty", bindConnectionProviderName);
        } else {
            log.info("{} statistics: {}", bindConnectionProviderName, bindLdapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
        }
    }
}
Also used : LDAPConnectionProvider(org.gluu.site.ldap.LDAPConnectionProvider)

Aggregations

LDAPConnectionProvider (org.gluu.site.ldap.LDAPConnectionProvider)8 Properties (java.util.Properties)5 OperationsFacade (org.gluu.site.ldap.OperationsFacade)3 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)3 FileConfiguration (org.xdi.util.properties.FileConfiguration)2 IOException (java.io.IOException)1 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)1 JsonParseException (org.codehaus.jackson.JsonParseException)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)1 BeforeClass (org.testng.annotations.BeforeClass)1 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)1