封裝jndi操作ldap伺服器的工具類_java

來源:互聯網
上載者:User

LDAP操作封裝類

目標:使用者只需要會使用List,Map 資料結構,將對LDAP的操作進行封裝

類:主要有三個類
1 Env類 包含LDAP的串連資訊
2 LdapConnectionFactory類 ldap串連工廠,提供初始化及擷取ldap串連的方法
3 LdapOperUtils ldap的處理工具類,提供了各種操作ldap的方法。

串連LDAP的串連屬性類

複製代碼 代碼如下:

package com.common.ldapconnection;

import org.apache.log4j.Logger;

/**
 * <p>功能描述:串連LDAP的串連屬性</p>
 * @author liaowufeng
 * @version 1.0
 */
public class Env {

    // 調用log4j的日誌,用於輸出
    private Logger log = Logger.getLogger(Env.class.getName());

    // 無論用什麼LDAP伺服器的固定寫法,指定了JNDI服務提供者中工廠類
    public String factory ;
    // 服務串連地址
    public String url ;
    // 登陸LDAP的使用者名稱和密碼
    public String adminUID ;
    // 登陸LDAP使用者密碼
    public String adminPWD ;
    // 安全訪問需要的認證庫
    public String sslTrustStore;
    // 安全通道訪問
    public String securityProtocol ;
    // 串連TimeOut
    public String timeOut;

    /**
     * 建構函式
     */
    public Env() {
    }

    /**
     * 建構函式
     * @param factory LDAP工廠類
     * @param url     LDAP URL
     * @param adminUID LDAP 使用者
     * @param adminPWD LDAP 密碼
     */
    public Env(String factory, String url, String adminUID, String adminPWD) {
        this.factory = factory;
        this.url = url;
        this.adminUID = adminUID;
        this.adminPWD = adminPWD;
    }

    /**
     * 建構函式
     * @param factory LDAP 工廠類名
     * @param url     LDAP URL
     * @param adminUID LDAP 使用者
     * @param adminPWD LDAP 密碼
     * @param sslTrustStore  安全訪問需要的認證
     * @param securityProtocol 安全通道訪問
     */
    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;
    }

    /**
     * 建構函式
     * @param factory LDAP 工廠類名
     * @param url     LDAP URL
     * @param adminUID LDAP 使用者
     * @param adminPWD LDAP 密碼
     * @param sslTrustStore  安全訪問需要的認證
     * @param securityProtocol 安全通道訪問
     */
    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;
    }
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.