/** * {@inheritDoc} */ @Override() public LDAPConnection getConnection() throws LDAPException { return new LDAPConnection(socketFactory, connectionOptions, address, port); }
/** * {@inheritDoc} */ @Override() public LDAPConnection getConnection() throws LDAPException { return new LDAPConnection(socketFactory, connectionOptions, address, port); }
public LDAPConnection getLDAPConnection() throws LDAPException { return new LDAPConnection("localhost", getPort()); }
private static LDAPConnection getConnection(Map<LdapConfigBean, LDAPConnectionPool> map, SSLSocketFactory socketFactory, LdapConfigBean config) throws LDAPException { if (!map.containsKey(config)) { LDAPConnection template = new LDAPConnection(config.getHost(), config.getPort()); if (socketFactory != null) template.setSocketFactory(socketFactory); map.put(config, new LDAPConnectionPool(template, MAX_CONNECTIONS_PER_POOL)); } return map.get(config).getConnection(); }
this.connectionSelected = connectionSelected; connection = new LDAPConnection(socketFactory, connectionOptions);
/** * Unbinds and disconnects from the directory server. * * @throws LDAPException If a problem occurs. */ public void disconnect() throws LDAPException { authDN = null; authPW = null; conn.close(); if (socketFactory == null) { conn = new com.unboundid.ldap.sdk.LDAPConnection(); } else { conn = new com.unboundid.ldap.sdk.LDAPConnection( new LDAPToJavaSocketFactory(socketFactory)); } }
private static LDAPConnection getConnection(Map<LdapConfigBean, LDAPConnectionPool> map, SSLSocketFactory socketFactory, LdapConfigBean config) throws LDAPException { if (!map.containsKey(config)) { LDAPConnection template = new LDAPConnection(config.getHost(), config.getPort()); if (socketFactory != null) template.setSocketFactory(socketFactory); map.put(config, new LDAPConnectionPool(template, MAX_CONNECTIONS_PER_POOL)); } return map.get(config).getConnection(); }
/** * Creates a new LDAP connection which will use the provided socket factory. * * @param socketFactory The socket factory to use when creating the socket * to use for communicating with the server. */ public LDAPConnection(final LDAPSocketFactory socketFactory) { this.socketFactory = socketFactory; if (socketFactory == null) { conn = new com.unboundid.ldap.sdk.LDAPConnection(); } else { conn = new com.unboundid.ldap.sdk.LDAPConnection( new LDAPToJavaSocketFactory(socketFactory)); } authDN = null; authPW = null; constraints = new LDAPConstraints(); searchConstraints = new LDAPSearchConstraints(); }
public LDAPConnection buildLdapConnection() throws GeneralSecurityException, LDAPException { SSLSocketFactory sslSocketFactory = SSL_UTIL.createSSLSocketFactory(); return new LDAPConnection(sslSocketFactory, ldapProperties.getHost(), ldapProperties.getPort()); } }
/** * 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"); } }
numberOfTries++; log.debug(String.format("trial number -> %s" , numberOfTries)); ldapConnection = new LDAPConnection(connectionOptions); ldapConnection.connect(ntDomain, ntPort,connectTimeout); break;
if (socketFactory == null) conn = new com.unboundid.ldap.sdk.LDAPConnection(host, port); conn = new com.unboundid.ldap.sdk.LDAPConnection( new LDAPToJavaSocketFactory(socketFactory), host, port);
public LDAPConnection buildLdapConnection() throws GeneralSecurityException, LDAPException { final LDAPConnection ldapConnection = new LDAPConnection(ldapProperties.getHost(), ldapProperties.getPort()); ldapConnection.processExtendedOperation(new StartTLSExtendedRequest(SSL_UTIL.createSSLContext())); return ldapConnection; }
protected SearchResult execute(SearchRequest request, String bindDN, String password) { LDAPConnection connection = null; try { if (allowAllSocketFactory) { SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager()); connection = new LDAPConnection(sslUtil.createSSLSocketFactory(), serverHost, serverPort); } else { connection = new LDAPConnection(serverHost, serverPort); } if (bindDN != null) { BindResult auth = connection.bind(bindDN, password); if (!auth.getResultCode().isConnectionUsable()) { log.error("Connection not usable, result code : " + auth.getResultCode()); } } return connection.search(request); } catch (LDAPException le) { String message = le.getMessage(); if (!message.startsWith("Unable to bind as user ")) { log.error(le.getMessage(), le); } } catch (GeneralSecurityException gse) { log.error(gse.getMessage(), gse); } finally { if (null != connection) { connection.close(); } } return null; }
SSLSocketFactory socketFactory = new SSLUtil(trustStoreTrustManager).createSSLSocketFactory(); ldapConnection = new LDAPConnection(socketFactory, options); } else { LOGGER.warn("Not using SSL to connect to ldap. This is very insecure - do not use in prod environments!"); ldapConnection = new LDAPConnection(options);
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()); } } }
private void insertTestUsers() throws LDAPException { LDAPConnection connection = null; try { connection = new LDAPConnection("localhost", 10389); // entry tim/sausages List<Attribute> addRequest = new ArrayList<Attribute>(); addRequest.add(new Attribute("objectClass", "top")); addRequest.add(new Attribute("objectClass", "person")); addRequest.add(new Attribute("objectClass", "organizationalPerson")); addRequest.add(new Attribute("objectClass", "inetOrgPerson")); addRequest.add(new Attribute("cn", "Tim Fox")); addRequest.add(new Attribute("sn", "Fox")); addRequest.add(new Attribute("mail", "tim@example.com")); addRequest.add(new Attribute("uid", "tim")); addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw==")); connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest); } finally { if (connection != null) { connection.close(); } } }
private void insertTestUsers() throws LDAPException { LDAPConnection connection = null; try { connection = new LDAPConnection("localhost", 10389); // entry tim/sausages List<Attribute> addRequest = new ArrayList<>(); addRequest.add(new Attribute("objectClass", "top")); addRequest.add(new Attribute("objectClass", "person")); addRequest.add(new Attribute("objectClass", "organizationalPerson")); addRequest.add(new Attribute("objectClass", "inetOrgPerson")); addRequest.add(new Attribute("cn", "Tim Fox")); addRequest.add(new Attribute("sn", "Fox")); addRequest.add(new Attribute("mail", "tim@example.com")); addRequest.add(new Attribute("uid", "tim")); addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw==")); connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest); } finally { if (connection != null) { connection.close(); } } }
ExtendedRequest extRequest = new StartTLSExtendedRequest(context); ldapConnection = new LDAPConnection(ldapProperties.getHost(), ldapProperties.getPort()); ldapConnection.processExtendedOperation(extRequest); BindResult bindResult = ldapConnection.bind(
LDAPConnection connection; try { connection = new LDAPConnection(host, port, accountDn, ldapConfiguration.getString(ACCOUNT_PASSWORD_PROP)); ldapConnectionPool = new LDAPConnectionPool(connection, numConnections); } catch (LDAPException e) {