Spring Security 登录密码验证过程(UsernamePasswordAuthenticationFilter)

本文深入剖析Spring Security的登录密码验证流程,着重讲解UsernamePasswordAuthenticationFilter的作用,以及从web.xml配置到自定义UserDetailsService接口的实现,详细阐述了认证过程,包括密码加盐验证的步骤。
摘要由CSDN通过智能技术生成

Spring-Security主要是一个由一堆Filter组成的过滤器链,每个Filter做自己的事情。今天我跟一下登录的密码认证过程,主要是UsernamePasswordAuthenticationFilter这个类

1.web.xml中配置security

    <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>

2. spring-security.xml  这里定义了一个ValidateCodeAuthenticationFilter,这个filter继承自   UsernamePasswordAuthenticationFilter,在做认证的时候调用UsernamePasswordAuthenticationFilter中的attemptAuthentication方法,

<beans:bean id="validateCodeAuthenticationFilter" class="com.*.interceptors.ValidateCodeAuthenticationFilter">  
   <beans:property name="authe
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值