session记录次数

 

1.对于不同的id,进行记录次数。当次数超过一定次数,作出相应的处理。

例如:当超过5次(含有)作出处理

counter为常量 可以定义成员属性 private int counter ;

errorTime错误的次数,private int errorTime = 1.

counter = Integer.parseInt(context.getProperty("validate.pin.counter"));// 5 times

if(session.getAttribute(Constant.VALIDATE_PIN) != null ){

errorTime = Integer.parseInt(session.getAttribute(Constant.VALIDATE_PIN).toString());

info(method,"get error time form session --------" + errorTime);

if(errorTime >= counter){

info(method,"user enter pinNo " + pinNo + "more than 5 times ");

isShow = "Show";

return INPUT;

}

}

errorTime++;

session.setAttribute(Constant.VALIDATE_PIN, errorTime);

 

2.对于相同的id,进行记录次数。当次数超过一定次数,作出相应的处理。

例如:当超过5次(含有)作出处理

private int counter;

Map<String, Integer> countMap = (Map<String, Integer>) session

.getAttribute(Constant.SELF_SERVICE_ACTION.FORGOTPASS_COUNTMAP);

if (countMap == null) {

countMap = new HashMap<String, Integer>();

}

Iterator iterator = countMap.entrySet().iterator();

boolean isExist = false;

counter = Integer.parseInt(context.getProperty("forgot.password.Counter"));// 5 times

while (iterator.hasNext()) {

Map.Entry<String, Integer> entry = (Map.Entry<String, Integer>) iterator

.next();

String keyCustId = (String) entry.getKey();

Integer valCount = (Integer) entry.getValue();

if (keyCustId.equals(ssoUser.getCustId())) {

valCount++;

if (valCount.intValue() >= counter) {

info(method,"custId or emailAddress invalid more than 5 times lead to forgotssoId page");

try {

questionList = selfServiceManager.getQuestionList();

return "forgotssoId";

} catch (SelfServiceManagerException e) {

error(method, "get question exception by manager", e);

ctx.put(errorMessage, getText("error.forgot.password.exception.questionlist"));

return ERROR;

}

}

countMap.put(keyCustId, valCount);

isExist = true;//不在5次的范围内

break;

}

}

if (!isExist) {

debug(method, "First time a user submitted with custid is"

+ ssoUser.getCustId());

countMap.put(ssoUser.getCustId(),

Constant.SELF_SERVICE_ACTION.FORGOTPASS_INIT_COUNTER);

}

 

session.setAttribute(Constant.SELF_SERVICE_ACTION.FORGOTPASS_COUNTMAP, countMap);//放到session

 

 

Author:lyuan

Date : 3/5/2010, 3:57 PM

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值