首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

CAS通过用户名与ip限制密码输入异常次数(转)

2013-03-06 
CAS通过用户名与ip限制密码输入错误次数(转)之前自己通过修改源码实现了以用户名为单位限制其密码输入次数

CAS通过用户名与ip限制密码输入错误次数(转)
之前自己通过修改源码实现了以用户名为单位限制其密码输入次数,但这样做不是很合理,如果是同一ip不同用户名呢?于是就想把也通过ip限制的功能加上。今天无意逛官网时竟然发现CAS里面有类似的功能,可以通过用户名或ip来做登录限制。没有仔细查看文档的结果就是做了一点无用功。下面介绍下开启cas限制密码输入次数的功能。有两种方法:一是把状态保存到内存中,二是通过Inspektr来管理。下面主要介绍保存到内存的方法(使用3.4.10版本的cas):

在WEB-INF\spring-configuration下创建throttleInterceptorTrigger.xml配置文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="throttleInterceptor"
/>

<bean id="throttleInterceptorJobDetail"
p:targetMethod="decrementCounts" />

<bean id="periodicThrottleCleanerTrigger"
p:startDelay="0"
p:repeatInterval="20000" />
</beans>

其中failureThreshold为同一ip或同一用户允许错误次数

到cas-servlet.xml配置文件修改FlowHandlerMappingbean,如下:

<bean p:flowRegistry-ref="flowRegistry" p:order="2">
        <property name="interceptors">
        <list>        
        <ref local="localeChangeInterceptor" />        
        <ref bean="throttleInterceptor" />  
        </list>          
        </property>
    </bean>完成


热点排行