@Override public com.google.common.base.Optional<Boolean> isHealthy() { try { final LdapConnection connection = connectionPool.getConnection(); try { if (connection.isConnected() && connection.isAuthenticated()) { connection.bind(); try { return com.google.common.base.Optional.of(true); } finally { connection.unBind(); } } } finally { connectionPool.releaseConnection(connection); } } catch (LdapException e) { LOG.warn("LdapException caught when checking health", e); exceptionNotifier.notify(String.format("LdapException caught when checking health (%s)", e.getMessage()), e); } return com.google.common.base.Optional.of(false); }
final LdapConnection connection = connectionPool.getConnection();
/** * Calls the PoolMgr to get an Admin connection to the LDAP server. * * @return ldap connection. * @throws LdapException If we had an issue getting an LDAP connection */ public LdapConnection getAdminConnection() throws LdapException { try { return adminPool.getConnection(); } catch ( Exception e ) { throw new LdapException( e ); } }
/** * Calls the PoolMgr to get an Log connection to the LDAP server. * * @return ldap connection. * @throws LdapException If we had an issue getting an LDAP connection */ public LdapConnection getLogConnection() throws LdapException { try { return logPool.getConnection(); } catch ( Exception e ) { throw new LdapException( e ); } }
/** * Calls the PoolMgr to get an User connection to the LDAP server. * * @return ldap connection. * @throws LdapException If we had an issue getting an LDAP connection */ public LdapConnection getUserConnection() throws LdapException { try { return userPool.getConnection(); } catch ( Exception e ) { throw new LdapException( e ); } }
@NotNull private LdapConnection connect() throws ExternalIdentityException { try { if (adminPool == null) { return adminConnectionFactory.makeObject(); } else { return adminPool.getConnection(); } } catch (Exception e) { String msg = "Error while connecting to the ldap server."; log.error(msg, e); throw new ExternalIdentityException(msg, e); } }
@JsonIgnore public LdapConnection getConnection(final IOUtils.CloseableContext context, final Long timeOut) throws LdapException { LdapConnection connection; if (connectionPool != null) connection = connectionPool.getConnection(); else connection = new LdapNetworkConnection(config); if (context != null) context.add(connection); if (timeOut != null) connection.setTimeOut(timeOut); return connection; }
/** * {@inheritDoc} */ @Override public DeleteResponse delete( DeleteRequest deleteRequest ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connection.delete( deleteRequest ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public AddResponse add( AddRequest addRequest ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connection.add( addRequest ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public DeleteResponse delete( DeleteRequest deleteRequest ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connection.delete( deleteRequest ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public <T> T execute( ConnectionCallback<T> connectionCallback ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connectionCallback.doWithConnection( connection ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public PasswordWarning authenticate( Dn userDn, char[] password ) throws PasswordException { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return authenticateConnection( connection, userDn, password ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public DeleteResponse delete( DeleteRequest deleteRequest ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connection.delete( deleteRequest ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public ModifyResponse modify( ModifyRequest modifyRequest ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connection.modify( modifyRequest ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
@Override public com.google.common.base.Optional<Boolean> isHealthy() { try { final LdapConnection connection = connectionPool.getConnection(); try { if (connection.isConnected() && connection.isAuthenticated()) { connection.bind(); try { return com.google.common.base.Optional.of(true); } finally { connection.unBind(); } } } finally { connectionPool.releaseConnection(connection); } } catch (LdapException e) { LOG.warn("LdapException caught when checking health", e); exceptionNotifier.notify(String.format("LdapException caught when checking health (%s)", e.getMessage()), e); } return com.google.common.base.Optional.of(false); }
/** * {@inheritDoc} */ @Override public <T> T execute( ConnectionCallback<T> connectionCallback ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connectionCallback.doWithConnection( connection ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public ModifyResponse modify( ModifyRequest modifyRequest ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connection.modify( modifyRequest ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * {@inheritDoc} */ @Override public ModifyResponse modify( ModifyRequest modifyRequest ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); return connection.modify( modifyRequest ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }
/** * Gets the pooled {@link LdapConnectionPool}, authenticated as admin user. * The caller is reponsible for releasing the connection, use releasePooledConnection(). * * @param ldapServer the LDAP server instance, used to obtain the port used * @return the pooled admin connection * @throws LdapException the exception */ public static LdapConnection getPooledAdminConnection( LdapServer ldapServer ) throws LdapException { LdapConnection ldapConnection = getAdminPool( ldapServer ).getConnection(); ldapConnection.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( ldapServer.getDirectoryService().getSchemaManager() ) ); return ldapConnection; }
/** * {@inheritDoc} */ @Override public <T> T lookup( Dn dn, String[] attributes, EntryMapper<T> entryMapper ) { LdapConnection connection = null; try { connection = connectionPool.getConnection(); Entry entry = attributes == null ? connection.lookup( dn ) : connection.lookup( dn, attributes ); return entry == null ? null : entryMapper.map( entry ); } catch ( LdapException e ) { throw new LdapRuntimeException( e ); } finally { returnLdapConnection( connection ); } }