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;
}
}
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;
}
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());
}
}
}
Aggregations