黑白名单的具体实现

如果是黑名单就直接跳向错误提示页面,如果是白名单直接验证通过

//黑白名单功能实现
List criterions = new ArrayList();
criterions.add(Restrictions.eq("mac", mac));
List nodeBlack = blackListService.executeQuery(criterions, null);
List 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);
}

你可能感兴趣的:(WifiDog项目)