基于验证方式的系统安全设计
2014-03-21夏小翔
【 摘 要 】 本文给出了关于系统安全方式的集中设计及实现,主要是通过验证方式来保证系统的安全,给出了用户验证和一般性字符验证的设计及实现。
【 关键词 】 验证方式;用户验证;脚本验证
System Security Design Based on Verification Method
Xia Xiao-xiang
(Computer Department,Ezhou Vocational University HubeiEzhou 436000)
【 Abstract 】 This paper presents and realizes the centralized design about the system security, we ensure the safety of the system through the verification method, we have gaven the design and implementation of user authentication and general character verification.
【 Keywords 】 authentication way; user authentication; script authentication
1 引言
电子商务技术已越来越广泛地应用于各行各业,信息安全的重要性也越来越明显,我们可以通过设定密码、利用数字签名等方式实现系统的安全。本文着重介绍一下通过验证技术来实现系统的安全。
2 用户验证技术的设计
对于用户验证在每个页面中几乎都会存在,主要是为了判断但前收集客户对页面的访问是否合法,本系统的主要页面的左侧的菜单树在没有登录的情况下也是可以进行访问的,但是不能进行已登录用户的一些功能,比如查询个人话费信息等。在用户登录就将用户的相关信息存放到session中去,下面我们以电话查询方式来说明用户验证的实现,实现代码如下:
HttpSession session=request.getSession();
if(rs.next()) { //rs为查询后结果集
session.setAttribute("canLogin", "yes"); //设置canLogin为yes
session.setAttribute("custom", rs.getString("userName"));
//设置当前客户端名字为从数据库中读取的客户姓名
session.setAttribute("phonenum", phoneNum);
//设置当前客户的手机号码为用户登录时的电话号码
}
else
session.setAttribute("canLogin","no");//登录失败则设置canLogin为no
在每个action进行处理相关查询的时候,先从session中读取canLogin,如果为yes则进行相关的查询操作,如果为no则提示用户应该先登录。
HttpSession session=request.getSession();
String can=(String)session.getAttribute("canLogin");
phonenum=(String)session.getAttribute("phonenum");
String act = request.getParameter("act");
//这里的act是处理相应的操作
if(can!=null&&can.equals("yes"))//客户已经正确登录
{
if (act.trim().equalsIgnoreCase("detail")) {
detail(request);
}
else if (act.trim().equalsIgnoreCase("yu")) {
yu(request);
}
else if (act.trim().equalsIgnoreCase("money")) {
money(request);
}
}
else if(can==null||can.equals("no"))//用户没有登录
{
url = "/pages/loginFirst.jsp";//将页面发送到loginFirst.jsp
}
3 Javascript脚本验证技术的设计
Javascript脚本验证是很有用的一种验证方式,并且很多验证函数可以被多个页面所共享。
我们对空格方式的验证技术,主要是通过函数压缩技术来实现空格的读取及识别。……