/** * Indicates whether this connection is currently established. * * @return {@code true} if this connection is currently established, or * {@code false} if not. */ public boolean isConnected() { return conn.isConnected(); }
/** * fall back to connect using IP itself * @return */ private LDAPConnection tryGettingConnectionWithDirectIP() throws LDAPException { LDAPConnection ldapConnection = new LDAPConnection(); try{ hostIps.forEach( ip->{ try{ ldapConnection.connect(ip, ntPort,connectTimeout); throw new BreakLoopException(); }catch(LDAPException exception){ log.debug("unable to connect using" + ip + ", trying next ip"); } } ); }catch(BreakLoopException br){ log.info("got connected using IP"); } if(ldapConnection.isConnected()) return ldapConnection; else{ throw new LDAPException(ResultCode.CONNECT_ERROR,"unable to connect using IP"); } }
@Override public RolesProviderHealth checkHealth() { boolean isHealthy = true; Map<String, Object> details = new LinkedHashMap<>(); try { LDAPConnection ldapConnection = connectionPool.getConnection(); if (!ldapConnection.isConnected()) { isHealthy = false; } connectionPool.getHealthCheck().ensureConnectionValidForContinuedUse(ldapConnection); } catch (LDAPException e) { details.put("exception", e); isHealthy = false; } details.put("bindDn", ldapConfiguration.getBindDn()); details.put("connectionTimeoutMS", ldapConfiguration.getConnectionTimeoutMS()); details.put("poolMaxConnectionAgeMS", ldapConfiguration.getPoolMaxConnectionAgeMS()); details.put("ppolSize", ldapConfiguration.getPoolSize()); details.put("port", ldapConfiguration.getPort()); details.put("responseTimeInMS", ldapConfiguration.getResponseTimeoutMS()); details.put("server", ldapConfiguration.getServer()); details.put("trustStore", ldapConfiguration.getTrustStore()); details.put("useSSL", ldapConfiguration.getUseSSL()); return new RolesProviderHealth(isHealthy, details); } }
public AuthToken auth(String username, String password, String token) throws AuthException { String ldapHost = config.get(Config.LDAP_HOST); try { LDAPConnection connection = new LDAPConnection( ldapHost, Integer.valueOf(config.get(Config.LDAP_PORT)), username + "@" + ldapHost, password); if (connection.isConnected()) { return new LDAPToken(connection, username, token); } else { connection.close(); throw new AuthException("Connection not connected."); } } catch (LDAPException e) { throw new AuthException(e.getExceptionMessage()); } } }
if ((conn == null) || (! conn.isConnected()))
startTLSRequest = null; if (isConnected())
(! connectionOptions.useSynchronousMode()) && isConnected())
Collections.unmodifiableSet(EnumSet.noneOf(OperationType.class))); if (! connection.isConnected())
(! connectionOptions.useSynchronousMode()) && isConnected())
startTLSRequest = null; if (isConnected())
new LinkedBlockingQueue<LDAPConnection>(numConnections); if (! connection.isConnected())
new LinkedBlockingQueue<LDAPConnection>(numConnections); if (! connection.isConnected())
if (conn != null) if (conn.isConnected()) else if (conn.isConnected())
BindResult bindResult = null; if (!ldapConnection.isConnected()) { ldapConnection.connect( ldapConfiguration.getServer(), ldapConfiguration.getPort());
if (conn != null) if (conn.isConnected()) else if (conn.isConnected())
if (isConnected() && (! unbindRequestSent))
if (isConnected() && (! unbindRequestSent))