您的位置:首页 > 其它

黑白名单的具体实现

2014-08-19 17:29 113 查看
如果是黑名单就直接跳向错误提示页面,如果是白名单直接验证通过

//黑白名单功能实现

List<Criterion> criterions = new ArrayList<Criterion>();

criterions.add(Restrictions.eq("mac", mac));

List<BlackList> nodeBlack = blackListService.executeQuery(criterions, null);

List<WhiteList> nodeWhite = whiteListService.executeQuery(criterions, null);

if(nodeBlack!=null){

sendRedirect("../commons/blackList.html");

}

if(nodeWhite!=null){

HttpSession session = super.getSession();

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String nowTime = simpleDateFormat.format(new Date());

token = new MD5Code().getMD5ofStr(nowTime + UUID.randomUUID());

tokens = new Token(token);

String redirectUrl = "http://" + session.getAttribute("gw_address") + ":" + session.getAttribute("gw_port") + "/wifidog/auth?" + "token=" + token + "&url=" + session.getAttribute("url");

logger.info(redirectUrl);

session.setAttribute("gw_address", null);

session.setAttribute("gw_port", null);

session.setAttribute("url", null);

session.setAttribute("title", null);

// 保存token

tokenService.save(tokens);

getSession().setAttribute("loginType", 0);

sendRedirect(redirectUrl);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: