use of com.unboundid.ldap.sdk.LDAPException in project oxTrust by GluuFederation.
the class LdifService method exportLDIFFile.
public void exportLDIFFile(List<String> checkedItems, OutputStream output) throws LDAPException {
List<SearchResultEntry> result = null;
LDAPConnection connection = ldapEntryManager.getOperationService().getConnection();
try {
LdifDataUtility ldifDataUtility = LdifDataUtility.instance();
result = ldifDataUtility.getAttributeResultEntryLDIF(connection, checkedItems, attributeService.getDnForAttribute(null));
} catch (Exception ex) {
log.error("Failed to export ldif file: ", ex);
} finally {
ldapEntryManager.getOperationService().releaseConnection(connection);
}
if (result != null && result.size() > 0) {
// Write all of the matching entries to LDIF.
LDIFWriter ldifWriter;
try {
ldifWriter = new LDIFWriter(output);
for (SearchResultEntry entry : result) {
ldifWriter.writeEntry(entry);
}
ldifWriter.close();
} catch (IOException e) {
throw new BaseMappingException("Error writing to file, try again", e);
}
}
}
use of com.unboundid.ldap.sdk.LDAPException in project oxCore by GluuFederation.
the class LdapConnectionProvider method createSSLConnectionPoolWithPreviousProtocols.
private LDAPConnectionPool createSSLConnectionPoolWithPreviousProtocols(SSLUtil sslUtil, BindRequest bindRequest, LDAPConnectionOptions connectionOptions, int maxConnections) throws LDAPException {
for (int i = 1; i < SSL_PROTOCOLS.length; i++) {
String protocol = SSL_PROTOCOLS[i];
try {
FailoverServerSet failoverSet = new FailoverServerSet(this.addresses, this.ports, sslUtil.createSSLSocketFactory(protocol), connectionOptions);
LDAPConnectionPool connectionPool = new LDAPConnectionPool(failoverSet, bindRequest, maxConnections);
LOG.info("Server supports: '" + protocol + "'");
return connectionPool;
} catch (GeneralSecurityException ex) {
LOG.debug("Server not supports: '" + protocol + "'", ex);
} catch (LDAPException ex) {
// Error when LDAP server not supports specified encryption
if (ex.getResultCode() != ResultCode.SERVER_DOWN) {
throw ex;
}
LOG.debug("Server not supports: '" + protocol + "'", ex);
}
}
return null;
}
use of com.unboundid.ldap.sdk.LDAPException in project oxCore by GluuFederation.
the class LdapOperationsServiceImpl method scrollSimplePagedResultsControl.
private ASN1OctetString scrollSimplePagedResultsControl(LDAPConnection ldapConnection, String dn, Filter filter, SearchScope scope, Control[] controls, int startIndex) throws LDAPException, InvalidSimplePageControlException {
SearchRequest searchRequest = new SearchRequest(dn, scope, filter, "dn");
int currentStartIndex = startIndex;
ASN1OctetString cookie = null;
do {
int pageSize = Math.min(currentStartIndex, 100);
searchRequest.setControls(new Control[] { new SimplePagedResultsControl(pageSize, cookie, true) });
setControls(searchRequest, controls);
SearchResult searchResult = ldapConnection.search(searchRequest);
currentStartIndex -= searchResult.getEntryCount();
try {
SimplePagedResultsControl c = SimplePagedResultsControl.get(searchResult);
if (c != null) {
cookie = c.getCookie();
}
} catch (LDAPException ex) {
LOG.error("Error while accessing cookie", ex);
throw new InvalidSimplePageControlException(ex.getResultCode(), "Error while accessing cookie");
}
} while ((cookie != null) && (cookie.getValueLength() > 0) && (currentStartIndex > 0));
return cookie;
}
use of com.unboundid.ldap.sdk.LDAPException in project admin-console-beta by connexta.
the class TestLdapServer method startListening.
public TestLdapServer startListening(String ldifPath) {
try {
realServer = new InMemoryDirectoryServer(serverConfig);
realServer.startListening();
} catch (LDAPException e) {
fail(e.getMessage());
}
loadLdifFile(ldifPath);
return this;
}
use of com.unboundid.ldap.sdk.LDAPException in project admin-console-beta by connexta.
the class TestLdapServer method getInstance.
public static TestLdapServer getInstance() {
TestLdapServer object = new TestLdapServer();
try {
InMemoryListenerConfig ldapConfig = InMemoryListenerConfig.createLDAPConfig(getBaseDistinguishedName(), null, getLdapPort(), object.getServerSSLContext().getSocketFactory());
InMemoryListenerConfig ldapsConfig = InMemoryListenerConfig.createLDAPSConfig("ldaps", getLdapSecurePort(), object.getServerSSLContext().getServerSocketFactory());
object.serverConfig = new InMemoryDirectoryServerConfig(getBaseDistinguishedName());
object.serverConfig.setListenerConfigs(ldapConfig, ldapsConfig);
} catch (LDAPException e) {
fail(e.getMessage());
}
return object;
}
Aggregations