| | |
| | | import com.arcsoft.face.toolkit.ImageFactory; |
| | | import com.arcsoft.face.toolkit.ImageInfo; |
| | | import com.fgkj.actions.ActionUtil; |
| | | import com.fgkj.dao.impl.User_infImpl; |
| | | import com.fgkj.dao.impl.User_limitImpl; |
| | | import com.fgkj.dto.*; |
| | | import com.fgkj.services.User_infService; |
| | | import com.fgkj.services.User_permitgroupService; |
| | |
| | | HashMap map = getGson().fromJson(json, HashMap.class); |
| | | String uKeyId = (String) map.get("uKeyId"); |
| | | String fileData = (String) map.get("fileData"); |
| | | //获取人脸识别摄像头次数 |
| | | int loginFails = (int) map.get("loginFails"); |
| | | |
| | | /*====获取图片并校验活体,角度,像素大小====*/ |
| | | //由于图片字符串是由base64编码的,解码成字节数组 |
| | |
| | | model.setCode(0); |
| | | model.setMsg("uKey对应的用户没有对应的人脸库人像"); |
| | | } else { |
| | | ImageInfo imageInfo2 = ImageFactory.getRGBData(new File(filePath)); |
| | | model = FaceIdentifyUtil.faceCompare(faceEngine, imageInfo, imageInfo2); |
| | | //todo model.getCode()==0为人脸识别失败进行次数统计 |
| | | |
| | | |
| | | /*===用户登录信息 ===*/ |
| | | User_infService userInfService = new User_infService(); |
| | | User_inf u = userInfService.searchByUKeyId(uKeyId); |
| | | // model.setMsg("index-outline.jsp"); |
| | | // 将登陆成功的用户存入session |
| | | ActionUtil.getSession().setAttribute("user", u); |
| | | |
| | | //设置session不活动时间为30分 |
| | | ActionUtil.getSession().setMaxInactiveInterval(60 * 30); |
| | | ActionUtil.getSession().setAttribute("ip", ActionUtil.getRequest().getRemoteAddr()); |
| | | User_permitgroupService upgs = new User_permitgroupService(); |
| | | ServiceModel model1 = upgs.serchItem(u); |
| | | //System.out.println(model.getData()); |
| | | if (model1.getCode() == 1) { |
| | | ActionUtil.getSession().setAttribute("permits", ActionUtil.tojson(model1.getData())); |
| | | } else { |
| | | model.setCode(0); |
| | | model.setMsg("还未分配权限"); |
| | | //限制用户Dao |
| | | User_limitImpl limitImpl = new User_limitImpl(); |
| | | User_limit user_limit = new User_limit(u.getUId()); |
| | | //查询是否为限制用户 是否需要解除限制 |
| | | List limitList = limitImpl.serchByInfo(user_limit); |
| | | if (limitList.size()>=1){ |
| | | for (int i = 0; i < limitList.size(); i++) { |
| | | User_limit limit = (User_limit) limitList.get(i); |
| | | long now = new Date().getTime(); |
| | | long login = limit.getLoginTime().getTime()+limit.getLimitDuration()*1000; |
| | | //如果限制时间已到,先删除限制的数据 |
| | | if (now>=login){ |
| | | limitImpl.del(limit); |
| | | } |
| | | } |
| | | } |
| | | //将新登录的用户存入application |
| | | userInfService.setApplication(u); |
| | | //再次确认是否为限制用户 |
| | | limitList = limitImpl.serchByInfo(user_limit); |
| | | if (limitList.size()>=1){ |
| | | model.setCode(0); |
| | | model.setMsg("识别失败次数已达"+loginFails+"次"); |
| | | }else{ |
| | | ImageInfo imageInfo2 = ImageFactory.getRGBData(new File(filePath)); |
| | | model = FaceIdentifyUtil.faceCompare(faceEngine, imageInfo, imageInfo2); |
| | | //人脸识别失败5次 |
| | | if (loginFails==5&&model.getCode()==0){ |
| | | //添加进入限制用户 |
| | | boolean bl = limitImpl.add(user_limit); |
| | | if (bl){ |
| | | System.out.println(u.getUName()+"识别失败次数达到"+loginFails+"次,添加到限制用户中"); |
| | | } |
| | | model.setCode(0); |
| | | model.setMsg("识别失败次数已达"+loginFails+"次"); |
| | | } |
| | | //用户信息前移判断是否为限制用户 |
| | | // model.setMsg("index-outline.jsp"); |
| | | // 将登陆成功的用户存入session |
| | | ActionUtil.getSession().setAttribute("user", u); |
| | | |
| | | //设置session不活动时间为30分 |
| | | ActionUtil.getSession().setMaxInactiveInterval(60 * 30); |
| | | ActionUtil.getSession().setAttribute("ip", ActionUtil.getRequest().getRemoteAddr()); |
| | | User_permitgroupService upgs = new User_permitgroupService(); |
| | | ServiceModel model1 = upgs.serchItem(u); |
| | | //System.out.println(model.getData()); |
| | | if (model1.getCode() == 1) { |
| | | ActionUtil.getSession().setAttribute("permits", ActionUtil.tojson(model1.getData())); |
| | | } else { |
| | | model.setCode(0); |
| | | model.setMsg("还未分配权限"); |
| | | } |
| | | //将新登录的用户存入application |
| | | userInfService.setApplication(u); |
| | | }//判断是否为限制用户end |
| | | } |
| | | } |
| | | } |