b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

ldap认证_ldap认证服务器_ldap认证服务器搭建

电脑杂谈  发布时间:2017-02-23 04:55:02  来源:网络整理

最近在项目中使用公司的LDAP做身份认证,积累了一些经验,与大家分享一下。ldap认证

首选报告一下我们项目的概况,我们的项目是用java开发的,基于 spring 的web应用。主要相关软件或库的版本为:

java:1.6,maven:3.0.4,tomcat:7,spring framework:3.2.2.RELEASE,spring security:3.1.3.RELEASE

我的想法是这样的,当用户第一次登录系统时无需注册,只要输入LDAP绑定公司的域账户和密码就完成身份认证动作,然后会自动将用户信息(从LDAP中查询的用户中文名、邮箱等)插入中,并且赋予用户一个默认的角色。然后加载用户所属角色的权限,通过 spring security 结合用户所有的权限对用户访问的资源进行控制。

首先,要在 pom.xml 中设置下面的 dependencies 来集成 LDAP 相关操作。

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-ldap</artifactId>
            <version>${springsecurity-version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

在 web.xml 中做如下配置:

    <!-- Enables Spring Security -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class> 
            org.springframework.web.filter.DelegatingFilterProxy 
        </filter-class>
    </filter>

    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    </filter-mapping>

DelegatingFilterProxy做的事情是代理Filter的方法,从application context里获得bean。ldap认证 这让bean可以获得spring web application context的生命周期支持,使配置较为轻便。

下面我要配置 applicationContext-security.xml 文件,所有 spring security 相关的配置都应该写在这里。详细配置的意义可以参考 xml schema 文件:


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-33983-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...