首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 笔记本电脑 | 北大青鸟 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室Linux频道
中国IT教育
Google
首页 资讯动态 认证考试 新手入门 核心技术 高级技术 J2EE J2ME Java&XML 开源技术 其他技术 RSS订阅 论坛 专题
您现在的位置: 中国IT实验室 >> Java >> J2EE >> J2ee核心 >> 正文

封装JNDI操作LDAP服务器的工具类(1)


  目标:使用者只需要会使用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;
  }
  }
【责编:admin】

中国IT教育

相关产品和培训
文章评论
 友情推荐链接
 认证培训
 专题推荐

 ·算法分析与设计之五大常用算法
 ·开发必备 漫谈Java加密保护
 ·嵌入式开发--ARM技术专题
 ·C/C++指针,认真了解,灵活运用
 ·.NET开发:C#实用基础教程
 ·软件测试工具QTP学习专题
 ·嵌入式开发单片机解决方案专题
 ·Java开发环境 Greenfoot 程序员手册
 ·C++对象布局及多态实现的探索
 ·常见排序算法的实现
 今日更新
 社区讨论
 博客论点
 频道精选
 Java 频道导航