waffle是实现Windows & Active Directory单点登录的一种方式,它能过做一切windows认证 的事情,包括 Negotiate ,NTLM和Kerberos。其实现步骤如下:
1.下载waffle所需的jar文件,下载地址http://dblock.github.com/waffle/;
2.新建一个web项目,将waffle认证和spring-security相关的jar文件添加到web项目中,waffle所需的jar包分别为:
commons-logging-1.1.1.jar、guava-r07.jar、jna.jar、platform.jar、waffle-jacob.jar、waffle-jna.jar;
3、修改web.xml文件的配置为:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/waffle-filter.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
4、在WEB-INF下建立waffle-filter.xml文件,文件内容如下:
<!-- windows authentication provider -->
<bean id="waffleWindowsAuthProvider"
class="waffle.windows.auth.impl.WindowsAuthProviderImpl" />
<!-- collection of security filters -->
<bean id="negotiateSecurityFilterProvider"
class="waffle.servlet.spi.NegotiateSecurityFilterProvider">
<constructor-arg ref="waffleWindowsAuthProvider" />
</bean>
<bean id="basicSecurityFilterProvider" class="waffle.servlet.spi.BasicSecurityFilterProvider">
<constructor-arg ref="waffleWindowsAuthProvider" />
</bean>
<bean id="waffleSecurityFilterProviderCollection"
class="waffle.servlet.spi.SecurityFilterProviderCollection">
<constructor-arg>
<list>
<ref bean="negotiateSecurityFilterProvider" />
<ref bean="basicSecurityFilterProvider" />
</list>
</constructor-arg>
</bean>
<!-- spring filter entry point -->
<sec:http entry-point-ref="negotiateSecurityFilterEntryPoint">
<sec:intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
<sec:custom-filter ref="waffleNegotiateSecurityFilter" position="BASIC_AUTH_FILTER" />
</sec:http>
<bean id="negotiateSecurityFilterEntryPoint"
class="waffle.spring.NegotiateSecurityFilterEntryPoint">
<property name="provider" ref="waffleSecurityFilterProviderCollection" />
</bean>
<!-- spring authentication provider -->
<sec:authentication-manager alias="authenticationProvider" />
<!-- spring security filter -->
<bean id="waffleNegotiateSecurityFilter" class="waffle.spring.NegotiateSecurityFilter">
<property name="Provider" ref="waffleSecurityFilterProviderCollection" />
<property name="AllowGuestLogin" value="true" />
<property name="PrincipalFormat" value="fqn" />
<property name="RoleFormat" value="both" />
</bean>
注意:当访问的时候最好将访问地址写成项目部署所在机器的主机名。
当浏览器发送请求时,首先经过negotiateSecurityFilterEntryPoint处理,若未经认证或认证失败,则会弹出一个页面要求输入用户名和密码,点击确定按钮后,交由waffleNegotiateSecurityFilter处理,waffleNegotiateSecurityFilter调用相应的类和方法判断用户名和密码是否正确,如果正确,在允许访问,此时可通过request.getUserPrincipal()获取登录用户的相关信息。
分享到:
相关推荐
Waffle 是由java编写的项目,它提供了对于项目的用户密码认证可以使用本地window的用户名和密码
python-waffle-charts-with-pywaffle
turtlebot3 waffle pi 的入门教程,适合菜鸟入门使用。
改进Waffle.io并认可到期日 Chrome扩展程序在waffle.io中添加了“到期日”识别功能。 只需在卡片/问题上添加文字,例如“ Due 9/1-做某事”或“问题名称等等”(日期为2016年10月12日)即可。到期-如果卡“很快”...
Waffle是一个Java Web框架,允许基于pojo的操作。 内置了依赖性注入支持。Waffle没有专有的模板语言,也不需要任何XML配置文件。 华夫饼应用程序易于编写和测试。
angular-waffle Bower 组件 华夫饼生成器是一种流行的方法,可以创建大量的胡言乱语,读起来令人不安。 使用此组件填充您的页面(或论文),您通常会在其中使用无聊的 Lorum Ipsum 垃圾。 有关它产生的示例, 这是 ...
legendary-waffle-源码.rar
uPortal华夫菜单服务 RESTful服务,可为每个用户提供适当的菜单项。 用户由JWT标识,并且JWT中嵌入的角色充当针对项目“主”列表的筛选器。 项目主列表是通过以下格式的服务器上的json文件配置的: ...
Buidler + Waffle + TypeChain + OpenZeppelin CLI + Vue(TypeScript) 受到启发 ,这是一个预先配置的入门工具包,它使用最新的和最大的工具集从零到英雄 :flexed_biceps: 在四分之一的时间内,使用10倍的类型...
【博客个人资源】 包含前端、后端、移动开发、操作...Java、Python、Node.js、Spring Boot、Django、Express、MySQL、PostgreSQL、MongoDB、React、Angular、Vue、Bootstrap、Material-UI、Redis、Docker、Kubernetes
为waffle.io启用Velocity Scores(故事点),因此您可以估算每个问题的工作量 waffle.io的Velocity Score的Chrome扩展,从https://gist.github.com/jhubert/8eec558ab8cea9fd4aaa移植,它根据GitHub问题标题的内容...
华夫饼外卖报告启动应用npm installmongoURL=_my_waffle_db_url_ npm start谁在使用华夫饼? 显示Waffle用户的当前列表。 显示当前已创建的华夫板列表。
link rel =" stylesheet " href =" https://unpkg.com/waffle-grid/dist/waffle-grid.min.css " > <!-- or --> < link rel =" stylesheet " href =" ...
Side-Waffle - 海量实用Visual Studio项目模板用于Web和桌面开发
抓住并发布故事 抓取并发布您喜欢的故事。 支持语言:English (UK)
DBeaver常用数据库驱动,亲测好用。 包含JDBC驱动列表(jdbc driver list): CacheDB.jar clickhouse-jdbc-0.2.4.jar commons-codec-1.9.jar commons-logging-1.2.jar guava-19.0.jar ...waffle-jna-1.9.0.jar
super-duper-waffle
expert-octo-waffle
启用waffle.io的Velocity Scores(Story Points),以便估算每个问题的工作量 Waffle.io的Velocity Scores的chrome扩展,从https://gist.github.com/jhubert/8eec558ab8cea9fd4aaa移植,它根据GitHub问题标题的内容...