@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); }
checkState(connection.isConnected(), "not connected"); checkState(connection.isAuthenticated(), "not authenticated"); connection.bind();
/** * {@inheritDoc} */ @Override public void bind( Dn name ) throws LdapException { connection.bind( name ); bindCalled = true; }
/** * {@inheritDoc} */ @Override public BindResponse bind( BindRequest bindRequest ) throws LdapException { BindResponse response = connection.bind( bindRequest ); bindCalled = true; return response; }
/** * {@inheritDoc} */ @Override public void bind() throws LdapException { connection.bind(); bindCalled = true; }
/** * {@inheritDoc} */ @Override public void bind( String name, String credentials ) throws LdapException { connection.bind( name, credentials ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name, String credentials ) throws LdapException { connection.bind( name, credentials ); }
/** * {@inheritDoc} */ @Override public BindResponse bind( BindRequest bindRequest ) throws LdapException { return connection.bind( bindRequest ); }
/** * {@inheritDoc} */ @Override public void bind( String name ) throws LdapException { connection.bind( name ); }
/** * {@inheritDoc} */ @Override public BindResponse bind( BindRequest bindRequest ) throws LdapException { return connection.bind( bindRequest ); }
/** * {@inheritDoc} */ @Override public void bind( String name ) throws LdapException { connection.bind( name ); bindCalled = true; }
/** * {@inheritDoc} */ @Override public void bind( Dn name, String credentials ) throws LdapException { connection.bind( name, credentials ); bindCalled = true; }
/** * {@inheritDoc} */ @Override public void bind() throws LdapException { connection.bind(); }
/** * {@inheritDoc} */ @Override public void bind( String name ) throws LdapException { connection.bind( name ); }
/** * {@inheritDoc} */ @Override public BindResponse bind( BindRequest bindRequest ) throws LdapException { return connection.bind( bindRequest ); }
/** * {@inheritDoc} */ @Override public void bind() throws LdapException { connection.bind(); }
/** * {@inheritDoc} */ @Override public void bind( String name, String credentials ) throws LdapException { connection.bind( name, credentials ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name, String credentials ) throws LdapException { connection.bind( name, credentials ); }
/** * {@inheritDoc} */ public Object makeObject() throws Exception { LOG.debug( "creating a LDAP connection" ); LdapConnection connection = new LdapConnection( config ); connection.bind( config.getName(), config.getCredentials() ); return connection; }
@JsonIgnore public Entry getEntry(final LdapConnection connection, final String filter, final String... attributes) throws LdapException, CursorException, IOException { connection.bind(); try (final EntryCursor cursor = connection.search(baseDn, filter, SearchScope.SUBTREE, attributes)) { if (!cursor.next()) return null; return cursor.get(); } }