Java Code Examples for org.apache.directory.ldap.client.api.LdapConnectionConfig#setUseTls()
The following examples show how to use
org.apache.directory.ldap.client.api.LdapConnectionConfig#setUseTls() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LDAPConnectionService.java From guacamole-client with Apache License 2.0 | 5 votes |
/** * Creates a new instance of LdapNetworkConnection, configured as required * to use the given encryption method to communicate with the LDAP server * at the given hostname and port. The returned LdapNetworkConnection is * configured for use but is not yet connected nor bound to the LDAP * server. It will not be bound until a bind operation is explicitly * requested, and will not be connected until it is used in an LDAP * operation (such as a bind). * * @param host * The hostname or IP address of the LDAP server. * * @param port * The TCP port that the LDAP server is listening on. * * @param encryptionMethod * The encryption method that should be used to communicate with the * LDAP server. * * @return * A new instance of LdapNetworkConnection which uses the given * encryption method to communicate with the LDAP server at the given * hostname and port. * * @throws GuacamoleException * If the requested encryption method is actually not implemented (a * bug). */ private LdapNetworkConnection createLDAPConnection(String host, int port, EncryptionMethod encryptionMethod) throws GuacamoleException { LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(host); config.setLdapPort(port); // Map encryption method to proper connection and socket factory switch (encryptionMethod) { // Unencrypted LDAP connection case NONE: logger.debug("Connection to LDAP server without encryption."); break; // LDAP over SSL (LDAPS) case SSL: logger.debug("Connecting to LDAP server using SSL/TLS."); config.setUseSsl(true); break; // LDAP + STARTTLS case STARTTLS: logger.debug("Connecting to LDAP server using STARTTLS."); config.setUseTls(true); break; // The encryption method, though known, is not actually // implemented. If encountered, this would be a bug. default: throw new GuacamoleUnsupportedException("Unimplemented encryption method: " + encryptionMethod); } return new LdapNetworkConnection(config); }
Example 2
Source File: LDAPApi.java From mamute with Apache License 2.0 | 5 votes |
private LdapConnection connection(String username, String password) throws LdapException { // Manually build the configuration since the convenience constructor in // the LdapNetworkConnection doesn't let us specify a TLS setting LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(host); config.setLdapPort(port); config.setUseTls(useTls); config.setUseSsl(useSsl); LdapNetworkConnection conn = new LdapNetworkConnection(config); conn.bind(username, password); return conn; }
Example 3
Source File: LDAPConnectionService.java From guacamole-client with Apache License 2.0 | 5 votes |
/** * Creates a new instance of LdapNetworkConnection, configured as required * to use the given encryption method to communicate with the LDAP server * at the given hostname and port. The returned LdapNetworkConnection is * configured for use but is not yet connected nor bound to the LDAP * server. It will not be bound until a bind operation is explicitly * requested, and will not be connected until it is used in an LDAP * operation (such as a bind). * * @param host * The hostname or IP address of the LDAP server. * * @param port * The TCP port that the LDAP server is listening on. * * @param encryptionMethod * The encryption method that should be used to communicate with the * LDAP server. * * @return * A new instance of LdapNetworkConnection which uses the given * encryption method to communicate with the LDAP server at the given * hostname and port. * * @throws GuacamoleException * If the requested encryption method is actually not implemented (a * bug). */ private LdapNetworkConnection createLDAPConnection(String host, int port, EncryptionMethod encryptionMethod) throws GuacamoleException { LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(host); config.setLdapPort(port); // Map encryption method to proper connection and socket factory switch (encryptionMethod) { // Unencrypted LDAP connection case NONE: logger.debug("Connection to LDAP server without encryption."); break; // LDAP over SSL (LDAPS) case SSL: logger.debug("Connecting to LDAP server using SSL/TLS."); config.setUseSsl(true); break; // LDAP + STARTTLS case STARTTLS: logger.debug("Connecting to LDAP server using STARTTLS."); config.setUseTls(true); break; // The encryption method, though known, is not actually // implemented. If encountered, this would be a bug. default: throw new GuacamoleUnsupportedException("Unimplemented encryption method: " + encryptionMethod); } return new LdapNetworkConnection(config); }