class DefaultLdapConfigurationService implements LdapConfigurationService {

  @Override
  public void checkConnection(AmbariLdapConfiguration ambariLdapConfiguration) throws AmbariLdapException {
    LOGGER.info("Trying to connect to the LDAP server using provided configuration...");
    LdapConnectionTemplate ldapConnectionTemplate = ldapConnectionTemplateFactory.create(ambariLdapConfiguration);

    // check if the connection from the connection pool of the template is connected
    Boolean isConnected = ldapConnectionTemplate.execute(new ConnectionCallback<Boolean>() {
      @Override
      public Boolean doWithConnection(LdapConnection connection) throws LdapException {
        return connection.isConnected() && connection.isAuthenticated();
      }
    });

    if (!isConnected) {
      LOGGER.error("Could not connect to the LDAP server");
      throw new AmbariLdapException("Could not connect to the LDAP server. Configuration: " + ambariLdapConfiguration);
    }

    LOGGER.info("Successfully conencted to the LDAP.");

  }

  @Inject public  DefaultLdapConfigurationService();

}