use of com.unboundid.ldap.sdk.LDAPConnection in project keywhiz by square.
the class LdapConnectionFactory method getLDAPConnection.
public LDAPConnection getLDAPConnection(String userDN, String password) throws LDAPException, GeneralSecurityException {
TrustStoreTrustManager trust = new TrustStoreTrustManager(trustStorePath, trustStorePassword.toCharArray(), trustStoreType, false);
LDAPConnectionOptions options = new LDAPConnectionOptions();
options.setSSLSocketVerifier(new HostNameSSLSocketVerifier(false));
SSLUtil sslUtil = new SSLUtil(trust);
SocketFactory factory = new EndpointIdentificationSocketFactory(sslUtil.createSSLSocketFactory("TLSv1.2"));
LDAPConnection ldapConnection = new LDAPConnection(factory, options);
// Connect, retrieve the DN of the user (if any)
ldapConnection.connect(server, port);
ldapConnection.bind(userDN, password);
return ldapConnection;
}
use of com.unboundid.ldap.sdk.LDAPConnection in project zm-mailbox by Zimbra.
the class UBIDLdapContext method getConnection.
private LDAPConnection getConnection(LDAPConnectionPool pool) throws LdapException {
try {
// TODO: this is for backward compatibility with the legacy code - remvoe or enhance
// TODO: should have a timer for each connection pool
long start = 0;
if (isZimbraLdap) {
start = ZimbraPerf.STOPWATCH_LDAP_DC.start();
}
LDAPConnection connection = UBIDLdapOperation.GET_CONNECTION.execute(this, pool);
if (isZimbraLdap) {
ZimbraPerf.STOPWATCH_LDAP_DC.stop(start);
}
LdapConnectionPool.debugCheckOut(pool, connection);
return connection;
} catch (LDAPException e) {
throw mapToLdapException("unable to get connection", e);
}
}
use of com.unboundid.ldap.sdk.LDAPConnection in project cas by apereo.
the class LdapContinuousIntegrationSpnegoKnownClientSystemsFilterActionTests method bootstrap.
@BeforeClass
public static void bootstrap() throws Exception {
final LDAPConnection c = new LDAPConnection("localhost", 10389, "cn=Directory Manager", "password");
LdapIntegrationTestsOperations.populateDefaultEntries(c, "ou=people,dc=example,dc=org");
}
use of com.unboundid.ldap.sdk.LDAPConnection in project oxTrust by GluuFederation.
the class LdifService method importLdifFileInLdap.
public ResultCode importLdifFileInLdap(InputStream is) throws LDAPException {
ResultCode result = ResultCode.UNAVAILABLE;
LDAPConnection connection = ldapEntryManager.getOperationService().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 {
ldapEntryManager.getOperationService().releaseConnection(connection);
}
return result;
}
use of com.unboundid.ldap.sdk.LDAPConnection in project oxCore by GluuFederation.
the class LdapEntryManager method loadLdifFileContent.
public boolean loadLdifFileContent(String ldifFileContent) {
LDAPConnection connection = null;
try {
connection = ldapOperationService.getConnection();
ResultCode result = LdifDataUtility.instance().importLdifFileContent(connection, ldifFileContent);
return ResultCode.SUCCESS.equals(result);
} catch (Exception ex) {
LOG.error("Failed to load ldif file", ex);
return false;
} finally {
if (connection != null) {
ldapOperationService.releaseConnection(connection);
}
}
}
Aggregations