LDAP operation encapsulation class
Target: The user only needs to use List and Map data structures to encapsulate LDAP operations.
Class: There are three main categories
1 Env class contains LDAP connection information
2 LdapConnectionFactory class ldap connection factory, providing methods for initializing and obtaining ldap connections
3 LdapOperUtils ldap processing tool class provides various methods for operating ldap.
Connection attribute class for LDAP
The code copy is as follows:
package com.common.ldapconnection;
import org.apache.log4j.Logger;
/**
* <p>Function Description: Connection properties of LDAP</p>
* @author liaowufeng
* @version 1.0
*/
public class Env {
// The log that calls log4j is used to output
private Logger log = Logger.getLogger(Env.class.getName());
// No matter what fixed writing method of LDAP server is used, the factory class in the JNDI service provider is specified
public String factory ;
// Service connection address
public String url ;
// Username and password for logging into LDAP
public String adminUID ;
// Log in to LDAP user password
public String adminPWD ;
// Certificate library required for secure access
public String sslTrustStore;
// Secure channel access
public String securityProtocol ;
// Connect TimeOut
public String timeOut;
/**
* Constructor
*/
public Env() {
}
/**
* Constructor
* @param factory LDAP factory class
* @param url LDAP URL
* @param adminUID LDAP User
* @param adminPWD LDAP Password
*/
public Env(String factory, String url, String adminUID, String adminPWD) {
this.factory = factory;
this.url = url;
this.adminUID = adminUID;
this.adminPWD = adminPWD;
}
/**
* Constructor
* @param factory LDAP factory class name
* @param url LDAP URL
* @param adminUID LDAP User
* @param adminPWD LDAP Password
* @param sslTrustStore Certificate required for secure access
* @param securityProtocol secure channel access
*/
public Env(String factory, String url, String adminUID, String adminPWD,
String sslTrustStore,
String securityProtocol) {
this.factory = factory;
this.url = url;
this.adminUID = adminUID;
this.adminPWD = adminPWD;
this.sslTrustStore = sslTrustStore;
this.securityProtocol = securityProtocol;
}
/**
* Constructor
* @param factory LDAP factory class name
* @param url LDAP URL
* @param adminUID LDAP User
* @param adminPWD LDAP Password
* @param sslTrustStore Certificate required for secure access
* @param securityProtocol secure channel access
*/
public Env(String factory, String url, String adminUID, String adminPWD,
String timeOut,
String sslTrustStore,
String securityProtocol) {
this.factory = factory;
this.url = url;
this.adminUID = adminUID;
this.adminPWD = adminPWD;
this.timeOut = timeOut;
this.sslTrustStore = sslTrustStore;
this.securityProtocol = securityProtocol;
}
}