Search in sources :

Example 1 with LdapOperationService

use of org.gluu.persist.ldap.operation.LdapOperationService in project oxTrust by GluuFederation.

the class LdifService method importLdifFileInLdap.

public ResultCode importLdifFileInLdap(Class<?> entryClass, InputStream is) throws LDAPException {
    if (dataSourceTypeService.isLDAP(attributeService.getDnForAttribute(null))) {
        ResultCode result = ResultCode.UNAVAILABLE;
        PersistenceOperationService persistenceOperationService = persistenceManager.getOperationService();
        LdapOperationService ldapOperationService = (LdapOperationService) persistenceOperationService;
        LDAPConnection connection = ldapOperationService.getConnection();
        try {
            LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
            LDIFReader importLdifReader = new LDIFReader(is);
            result = ldifDataUtility.importLdifFile(connection, importLdifReader);
            importLdifReader.close();
        } catch (Exception ex) {
            log.error("Failed to import ldif file: ", ex);
        } finally {
            ldapOperationService.releaseConnection(connection);
        }
        return result;
    } else {
        performImport(entryClass, is);
        return ResultCode.SUCCESS;
    }
}
Also used : LdapOperationService(org.gluu.persist.ldap.operation.LdapOperationService) LDIFReader(com.unboundid.ldif.LDIFReader) PersistenceOperationService(org.gluu.persist.operation.PersistenceOperationService) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) LdifDataUtility(org.gluu.persist.ldap.impl.LdifDataUtility) ResultCode(com.unboundid.ldap.sdk.ResultCode) IOException(java.io.IOException) LDAPException(com.unboundid.ldap.sdk.LDAPException)

Example 2 with LdapOperationService

use of org.gluu.persist.ldap.operation.LdapOperationService in project oxTrust by GluuFederation.

the class CacheRefreshTimer method toLdapProperties.

private Properties toLdapProperties(PersistenceEntryManagerFactory ldapEntryManagerFactory, GluuLdapConfiguration ldapConfiguration) {
    String persistenceType = ldapEntryManagerFactory.getPersistenceType();
    Properties ldapProperties = new Properties();
    ldapProperties.put(persistenceType + "#servers", PropertyUtil.simplePropertiesToCommaSeparatedList(ldapConfiguration.getServers()));
    ldapProperties.put(persistenceType + "#maxconnections", Integer.toString(ldapConfiguration.getMaxConnections()));
    ldapProperties.put(persistenceType + "#useSSL", Boolean.toString(ldapConfiguration.isUseSSL()));
    ldapProperties.put(persistenceType + "#bindDN", ldapConfiguration.getBindDN());
    ldapProperties.put(persistenceType + "#bindPassword", ldapConfiguration.getBindPassword());
    // Copy binary attributes list from main LDAP connection
    PersistenceOperationService persistenceOperationService = ldapEntryManager.getOperationService();
    if (persistenceOperationService instanceof LdapOperationService) {
        ldapProperties.put(persistenceType + "#binaryAttributes", PropertyUtil.stringsToCommaSeparatedList(((LdapOperationService) persistenceOperationService).getConnectionProvider().getBinaryAttributes()));
    }
    return ldapProperties;
}
Also used : LdapOperationService(org.gluu.persist.ldap.operation.LdapOperationService) PersistenceOperationService(org.gluu.persist.operation.PersistenceOperationService) Properties(java.util.Properties)

Example 3 with LdapOperationService

use of org.gluu.persist.ldap.operation.LdapOperationService in project oxAuth by GluuFederation.

the class LdapStatusTimer method logConnectionProviderStatistic.

public void logConnectionProviderStatistic(PersistenceEntryManager ldapEntryManager, String connectionProviderName, String bindConnectionProviderName) {
    PersistenceOperationService persistenceOperationService = ldapEntryManager.getOperationService();
    if (!(persistenceOperationService instanceof LdapOperationService)) {
        return;
    }
    LdapConnectionProvider ldapConnectionProvider = ((LdapOperationService) persistenceOperationService).getConnectionProvider();
    LdapConnectionProvider bindLdapConnectionProvider = ((LdapOperationService) persistenceOperationService).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 : LdapOperationService(org.gluu.persist.ldap.operation.LdapOperationService) LdapConnectionProvider(org.gluu.persist.ldap.operation.impl.LdapConnectionProvider) PersistenceOperationService(org.gluu.persist.operation.PersistenceOperationService)

Aggregations

LdapOperationService (org.gluu.persist.ldap.operation.LdapOperationService)3 PersistenceOperationService (org.gluu.persist.operation.PersistenceOperationService)3 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 ResultCode (com.unboundid.ldap.sdk.ResultCode)1 LDIFReader (com.unboundid.ldif.LDIFReader)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 LdifDataUtility (org.gluu.persist.ldap.impl.LdifDataUtility)1 LdapConnectionProvider (org.gluu.persist.ldap.operation.impl.LdapConnectionProvider)1