org.apache.directory.ldap.client.api.LdapConnection.isConnected()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.apache.directory.ldap.client.api.LdapConnection.isConnected()方法的一些代码示例,展示了LdapConnection.isConnected()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LdapConnection.isConnected()方法的具体详情如下:
包路径:org.apache.directory.ldap.client.api.LdapConnection
类名称:LdapConnection
方法名:isConnected

LdapConnection.isConnected介绍

[英]Check if the connection is established
[中]检查是否建立了连接

代码示例

代码示例来源:origin: HubSpot/Singularity

@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);
}

代码示例来源:origin: HubSpot/Singularity

checkState(connection.isConnected(), "not connected");
checkState(connection.isAuthenticated(), "not authenticated");
connection.bind();

代码示例来源:origin: apache/jackrabbit-oak

/**
   * Returns true if {@code connection} is connected
   *
   * @param connection The connection to validate
   * @return True, if the connection is still valid
   */
  @Override
  public boolean validate( LdapConnection connection ) {
    return connection.isConnected();
  }
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-all

/**
 * {@inheritDoc}
 */
@Override
public boolean isConnected()
{
  return connection.isConnected();
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-api

/**
 * {@inheritDoc}
 */
@Override
public boolean isConnected()
{
  return connection.isConnected();
}

代码示例来源:origin: org.apache.directory.api/api-all

/**
 * {@inheritDoc}
 */
@Override
public boolean isConnected()
{
  return connection.isConnected();
}

代码示例来源:origin: org.apache.directory.client.ldap/ldap-client-api

/**
 * Check if we are authenticated
 *
 * @return <code>true</code> if we are connected.
 */
public boolean isAuthenticated()
{
  return isConnected() && authenticated.get();
}

代码示例来源:origin: org.apache.directory.client.ldap/ldap-client-api

/**
 * {@inheritDoc}
 */
public boolean validateObject( Object obj )
{
  LOG.debug( "validating {}", obj );
  LdapConnection connection = ( LdapConnection ) obj;
  return connection.isConnected();
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-api

/**
   * Returns true if <code>connection</code> is connected, and authenticated.
   * 
   * @param connection The connection to validate
   * @return True, if the connection is still valid
   */
  @Override
  public boolean validate( LdapConnection connection )
  {
    return connection.isConnected() && connection.isAuthenticated();
  }
}

代码示例来源:origin: org.apache.kerby/ldap-backend

/**
 * Close the connection for stop()
 */
private void closeConnection() throws IOException {
  if (connection.isConnected()) {
    connection.close();
  }
}

代码示例来源:origin: org.apache.directory.api/api-all

/**
   * Returns true if <code>connection</code> is connected, and authenticated.
   * 
   * @param connection The connection to validate
   * @return True, if the connection is still valid
   */
  @Override
  public boolean validate( LdapConnection connection )
  {
    return connection.isConnected() && connection.isAuthenticated();
  }
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-all

/**
   * Returns true if <code>connection</code> is connected, and authenticated.
   * 
   * @param connection The connection to validate
   * @return True, if the connection is still valid
   */
  @Override
  public boolean validate( LdapConnection connection )
  {
    return connection.isConnected() && connection.isAuthenticated();
  }
}

代码示例来源:origin: apache/directory-kerby

/**
 * Close the connection for stop()
 */
private void closeConnection() throws IOException {
  if (connection.isConnected()) {
    connection.close();
  }
}

代码示例来源:origin: apache/jackrabbit-oak

/**
   * Returns true if {@code connection} is connected, authenticated, and
   * a lookup on the rootDSE returns a non-null response.
   *
   * @param connection The connection to validate
   * @return True, if the connection is still valid
   */
  public boolean validate(LdapConnection connection) {
    try {
      return connection.isConnected()
          && (connection.lookup(Dn.ROOT_DSE, SchemaConstants.NO_ATTRIBUTE) != null);
    } catch (LdapException e) {
      log.info("validating failed: {}", e);
      return false;
    }
  }
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-api

/**
 * {@inheritDoc}
 * 
 * There is nothing to do to activate a connection.
 */
@Override
public void activateObject( PooledObject<LdapConnection> connection ) throws LdapException
{
  if ( LOG.isDebugEnabled() )
  {
    LOG.debug( I18n.msg( I18n.MSG_04146_ACTIVATING, connection ) );
  }
  
  if ( !connection.getObject().isConnected() || !connection.getObject().isAuthenticated() )
  {
    if ( LOG.isDebugEnabled() )
    {
      LOG.debug( I18n.msg( I18n.MSG_04147_REBIND_CONNECTION_DROPPED, connection ) );
    }
    
    connectionFactory.bindConnection( connection.getObject() );
  }
}

代码示例来源:origin: org.apache.directory.api/api-all

/**
 * {@inheritDoc}
 * 
 * There is nothing to do to activate a connection.
 */
@Override
public void activateObject( PooledObject<LdapConnection> connection ) throws LdapException
{
  if ( LOG.isDebugEnabled() )
  {
    LOG.debug( I18n.msg( I18n.MSG_04146_ACTIVATING, connection ) );
  }
  
  if ( !connection.getObject().isConnected() || !connection.getObject().isAuthenticated() )
  {
    if ( LOG.isDebugEnabled() )
    {
      LOG.debug( I18n.msg( I18n.MSG_04147_REBIND_CONNECTION_DROPPED, connection ) );
    }
    
    connectionFactory.bindConnection( connection.getObject() );
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
  public void testValidate() throws Exception {
    LdapConnection connection = Mockito.mock(LdapConnection.class);
    when(connection.isConnected()).thenReturn(true);
    when(connection.lookup(Dn.ROOT_DSE, SchemaConstants.NO_ATTRIBUTE)).thenReturn(Mockito.mock(Entry.class));

    assertTrue(validator.validate(connection));
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testValidateLookupReturnsNull() throws Exception {
  LdapConnection connection = Mockito.mock(LdapConnection.class);
  when(connection.isConnected()).thenReturn(true);
  when(connection.lookup(Dn.ROOT_DSE, SchemaConstants.NO_ATTRIBUTE)).thenReturn(null);
  assertFalse(validator.validate(connection));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testValidateNotConnectedLookupReturnsNull() throws Exception {
  LdapConnection connection = Mockito.mock(LdapConnection.class);
  when(connection.isConnected()).thenReturn(false);
  when(connection.lookup(Dn.ROOT_DSE, SchemaConstants.NO_ATTRIBUTE)).thenReturn(null);
  assertFalse(validator.validate(connection));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testValidateNotConnected() {
  LdapConnection connection = Mockito.mock(LdapConnection.class);
  when(connection.isConnected()).thenReturn(false);
  assertFalse(validator.validate(connection));
}

相关文章