org.jeecg.modules.shiro.vo.DefContants Java Examples
The following examples show how to use
org.jeecg.modules.shiro.vo.DefContants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 退出登录 * @param request * @param response * @return */ @RequestMapping(value = "/logout") public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) { //用户退出逻辑 String token = request.getHeader(DefContants.X_ACCESS_TOKEN); if(oConvertUtils.isEmpty(token)) { return Result.error("退出登录失败!"); } String username = JwtUtil.getUsername(token); LoginUser sysUser = sysBaseAPI.getUserByName(username); if(sysUser!=null) { sysBaseAPI.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null); log.info(" 用户名: "+sysUser.getRealname()+",退出成功! "); //清空用户登录Token缓存 redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); //清空用户登录Shiro权限缓存 redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); return Result.ok("退出登录成功!"); }else { return Result.error("Token无效!"); } }
Example #2
Source File: LoginController.java From teaching with Apache License 2.0 | 6 votes |
/** * 退出登录 * @param request * @param response * @return */ @RequestMapping(value = "/logout") public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) { //用户退出逻辑 String token = request.getHeader(DefContants.X_ACCESS_TOKEN); if(oConvertUtils.isEmpty(token)) { return Result.error("退出登录失败!"); } String username = JwtUtil.getUsername(token); LoginUser sysUser = sysBaseAPI.getUserByName(username); if(sysUser!=null) { sysBaseAPI.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null); log.info(" 用户名: "+sysUser.getRealname()+",退出成功! "); //清空用户登录Token缓存 redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); //清空用户登录Shiro权限缓存 redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); //清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username> redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername())); //调用shiro的logout SecurityUtils.getSubject().logout(); return Result.ok("退出登录成功!"); }else { return Result.error("Token无效!"); } }
Example #3
Source File: LoginController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 退出登录 * @param request * @param response * @return */ @RequestMapping(value = "/logout") public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) { //用户退出逻辑 String token = request.getHeader(DefContants.X_ACCESS_TOKEN); if(oConvertUtils.isEmpty(token)) { return Result.error("退出登录失败!"); } String username = JwtUtil.getUsername(token); LoginUser sysUser = sysBaseAPI.getUserByName(username); if(sysUser!=null) { sysBaseAPI.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null); log.info(" 用户名: "+sysUser.getRealname()+",退出成功! "); //清空用户登录Token缓存 redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); //清空用户登录Shiro权限缓存 redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); //清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username> redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername())); //调用shiro的logout SecurityUtils.getSubject().logout(); return Result.ok("退出登录成功!"); }else { return Result.error("Token无效!"); } }
Example #4
Source File: JwtFilter.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * */ @Override protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String token = httpServletRequest.getHeader(DefContants.X_ACCESS_TOKEN); JwtToken jwtToken = new JwtToken(token); // 提交给realm进行登入,如果错误他会抛出异常并被捕获 getSubject(request, response).login(jwtToken); // 如果没有抛出异常则代表登入成功,返回true return true; }
Example #5
Source File: LoginController.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 退出登录 * @param request * @param response * @return */ @RequestMapping(value = "/logout") public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) { //用户退出逻辑 String token = request.getHeader(DefContants.X_ACCESS_TOKEN); if(oConvertUtils.isEmpty(token)) { return Result.error("退出登录失败!"); } String username = JwtUtil.getUsername(token); LoginUser sysUser = sysBaseAPI.getUserByName(username); if(sysUser!=null) { sysBaseAPI.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null); log.info(" 用户名: "+sysUser.getRealname()+",退出成功! "); //清空用户登录Token缓存 redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); //清空用户登录Shiro权限缓存 redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); //清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username> redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername())); redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE_JWT, sysUser.getUsername())); //调用shiro的logout SecurityUtils.getSubject().logout(); return Result.ok("退出登录成功!"); }else { return Result.error("Token无效!"); } }
Example #6
Source File: JwtFilter.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * */ @Override protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String token = httpServletRequest.getHeader(DefContants.X_ACCESS_TOKEN); JwtToken jwtToken = new JwtToken(token); // 提交给realm进行登入,如果错误他会抛出异常并被捕获 getSubject(request, response).login(jwtToken); // 如果没有抛出异常则代表登入成功,返回true return true; }
Example #7
Source File: Swagger2Config.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * JWT token * @return */ private List<Parameter> setHeaderToken() { ParameterBuilder tokenPar = new ParameterBuilder(); List<Parameter> pars = new ArrayList<>(); tokenPar.name(DefContants.X_ACCESS_TOKEN).description("token").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); pars.add(tokenPar.build()); return pars; }
Example #8
Source File: JwtFilter.java From teaching with Apache License 2.0 | 5 votes |
/** * */ @Override protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String token = httpServletRequest.getHeader(DefContants.X_ACCESS_TOKEN); JwtToken jwtToken = new JwtToken(token); // 提交给realm进行登入,如果错误他会抛出异常并被捕获 getSubject(request, response).login(jwtToken); // 如果没有抛出异常则代表登入成功,返回true return true; }
Example #9
Source File: Swagger2Config.java From teaching with Apache License 2.0 | 5 votes |
/** * JWT token * @return */ private List<Parameter> setHeaderToken() { ParameterBuilder tokenPar = new ParameterBuilder(); List<Parameter> pars = new ArrayList<>(); tokenPar.name(DefContants.X_ACCESS_TOKEN).description("token").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); pars.add(tokenPar.build()); return pars; }
Example #10
Source File: JwtFilter.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * */ @Override protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String token = httpServletRequest.getHeader(DefContants.X_ACCESS_TOKEN); JwtToken jwtToken = new JwtToken(token); // 提交给realm进行登入,如果错误他会抛出异常并被捕获 getSubject(request, response).login(jwtToken); // 如果没有抛出异常则代表登入成功,返回true return true; }
Example #11
Source File: Swagger2Config.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * JWT token * @return */ private List<Parameter> setHeaderToken() { ParameterBuilder tokenPar = new ParameterBuilder(); List<Parameter> pars = new ArrayList<>(); tokenPar.name(DefContants.X_ACCESS_TOKEN).description("token").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); pars.add(tokenPar.build()); return pars; }
Example #12
Source File: Swagger2Config.java From jeecg-boot-with-activiti with MIT License | 2 votes |
/*** * oauth2配置 * 需要增加swagger授权回调地址 * http://localhost:8888/webjars/springfox-swagger-ui/o2c.html * @return */ @Bean SecurityScheme securityScheme() { return new ApiKey(DefContants.X_ACCESS_TOKEN, DefContants.X_ACCESS_TOKEN, "header"); }
Example #13
Source File: Swagger2Config.java From teaching with Apache License 2.0 | 2 votes |
/*** * oauth2配置 * 需要增加swagger授权回调地址 * http://localhost:8888/webjars/springfox-swagger-ui/o2c.html * @return */ @Bean SecurityScheme securityScheme() { return new ApiKey(DefContants.X_ACCESS_TOKEN, DefContants.X_ACCESS_TOKEN, "header"); }
Example #14
Source File: Swagger2Config.java From jeecg-boot with Apache License 2.0 | 2 votes |
/*** * oauth2配置 * 需要增加swagger授权回调地址 * http://localhost:8888/webjars/springfox-swagger-ui/o2c.html * @return */ @Bean SecurityScheme securityScheme() { return new ApiKey(DefContants.X_ACCESS_TOKEN, DefContants.X_ACCESS_TOKEN, "header"); }