| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.code.kaptcha.Constants; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.beetl.ShiroExtUtil; |
| | | import com.stylefeng.guns.core.common.exception.InvalidKaptchaException; |
| | | import com.stylefeng.guns.core.log.LogManager; |
| | | import com.stylefeng.guns.core.log.factory.LogTaskFactory; |
| | |
| | | import com.stylefeng.guns.modular.system.dao.UserMapper; |
| | | import com.stylefeng.guns.modular.system.model.User; |
| | | import com.stylefeng.guns.modular.system.service.IMenuService; |
| | | import com.stylefeng.guns.modular.system.service.ITEnterpriseWithdrawalService; |
| | | import com.stylefeng.guns.modular.system.service.IUserService; |
| | | import com.stylefeng.guns.modular.system.util.HttpRequestUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushURL; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | @Resource |
| | | private RedisTemplate<String, String> redisTemplate; |
| | | |
| | | @Autowired |
| | | private IShiro shiro; |
| | |
| | | |
| | | private Map<String, Integer> loginFailures = new HashMap<>(); |
| | | |
| | | @Resource |
| | | private ITEnterpriseWithdrawalService enterpriseWithdrawalService; |
| | | |
| | | |
| | | /** |
| | | * 跳转到主页 |
| | |
| | | @RequestMapping(value = "/", method = RequestMethod.GET) |
| | | public String index(Model model, HttpServletRequest request) throws UnsupportedEncodingException { |
| | | //session中解析用户数据 |
| | | //设置共享session |
| | | HttpSession session = (HttpSession) redisTemplate.opsForValue().get(request.getSession().getId()); |
| | | if (null != session) { |
| | | session = request.getSession(); |
| | | redisTemplate.opsForValue().set(request.getSession().getId(), session, 2, TimeUnit.DAYS); |
| | | } |
| | | HttpSession session = request.getSession(); |
| | | String onconParam = edu.yale.its.tp.cas.client.Util.getOnconParam(session); |
| | | onconParam = new String(Base64.decodeBase64(onconParam), "UTF-8"); |
| | | LoginUser loginUser = JSON.parseObject(onconParam, LoginUser.class); |
| | |
| | | //获取菜单列表 |
| | | User user = userMapper.getByAccount(loginUser.getImUser()); |
| | | if (null == user) { |
| | | logOut(); |
| | | logOut(request); |
| | | return null; |
| | | } |
| | | ShiroUser shiroUser = shiro.shiroUser(user); |
| | | List<Integer> roleList = shiroUser.getRoleList(); |
| | |
| | | model.addAttribute("avatar", avatar); |
| | | model.addAttribute("userName", user.getName()); |
| | | model.addAttribute("type", 0); |
| | | String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId(); |
| | | ShiroExtUtil.map.put(sessionId, shiroUser); |
| | | redisTemplate.opsForValue().set(loginUser.getOnconUUID(), JSON.toJSONString(shiroUser), 10, TimeUnit.HOURS); |
| | | return "/index.html"; |
| | | } |
| | | |
| | |
| | | * 退出登录 |
| | | */ |
| | | @RequestMapping(value = "/logout", method = RequestMethod.GET) |
| | | public String logOut() { |
| | | HttpUtil.get("https://testsso1.teamshub.com/logout?logouturl=https%3A%2F%2Fsso.teamshub.com%2Flogout%3F%0Alogoutat%3Dhttp%253A%252F%252F127.0.0.1%253A8010%252F"); |
| | | public String logOut(HttpServletRequest request) { |
| | | request.getSession().invalidate(); |
| | | HttpUtil.get("https://passport.teamshub.com/logout?logouturl=https%3A%2F%2Fsso.teamshub.com%2Flogout%3F%0Alogoutat%3Dhttps%253A%252F%252Ftraffic.qytzt.cn%253A443%252F"); |
| | | return REDIRECT + "/"; |
| | | } |
| | | |