关于spring acegi框架的 验证码的加入

用spring的acegi框架做安全验证时还要对验证码进行验证的操作
这时候要对它的源码做下修改了。。。
protected void onPreAuthentication(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws AuthenticationException, IOException
{
String randNum = httpservletrequest.getParameter( "check" );
String rand = (String) httpservletrequest.getSession().getAttribute( "validateCodeRecruit" );
if (rand == null || !rand.equals(randNum)) {

throw new AuthenticationaaException("错误");

}
在这个方法中添加你的验证代码 进行验证码的验证操作
这时 创建一个异常类继承AuthenticationException类
在出现错误时 构造一个子类的对象进行跑出 ,,,这时候就会扑捉到错误 通过对error中是否为空可以知道是不是成功,,,,
我使用的是acegi-security-1.0.5的版本,,,修改的是AbstractProcessingFilter这个抽象类。。。

你可能感兴趣的:(web)