ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码
当前位置:首页 >> 软件工程 >> 使用Vaptcha防止恶意访问

使用Vaptcha防止恶意访问(2/2)

来源:网络整理     时间:2018-09-12     关键词:

本篇文章主要介绍了" 使用Vaptcha防止恶意访问",主要涉及到方面的内容,对于软件工程感兴趣的同学可以参考一下: 背景:一般网站都会涉及注册、登录、发送邮件、验证码之类的功能,为了方便用户使用手机号注册及找回密码,前段时间增加了发送手机验证码的模块;上线运行也没什么问题。一...

private Vaptcha vaptcha = new Vaptcha(VaptchaConfig.VID, VaptchaConfig.KEY);

public ActionForward getvaptcha(ActionMapping mapping, ActionForm form,
		HttpServletRequest request,HttpServletResponse response){
	String challenge = vaptcha.getChallenge(null); 
	this.responseWrite(response, challenge);
	return null;
}
/**
	 * response 方式输出信息至客户端
	 * @param response
	 * @param msg
	 * @throws IOException 
	 */
	protected void responseWrite(HttpServletResponse response,Object msg) {
		if(msg == null) return;
		response.setCharacterEncoding("utf-8");
		PrintWriter pw;
		try {
			pw = response.getWriter();
			pw.write(msg.toString());
			pw.flush();
			pw.close();
			System.out.println(msg);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

5、二次验证

boolean vliStatus = vaptcha.validate(request.getParameter("challenge"),
					request.getParameter("token"), 
					null);
....自己的逻辑代码

这样就有效防止了某些恶意访问了

更多信息请访问官网:https://www.vaptcha.com/document/install

PS:附件为Vaptcha公共类库

以上就介绍了 使用Vaptcha防止恶意访问,包括了方面的内容,希望对软件工程有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_4588643_2.html

相关图片

相关文章