Java Code Examples for cn.hutool.extra.servlet.ServletUtil#getHeader()
The following examples show how to use
cn.hutool.extra.servlet.ServletUtil#getHeader() .
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: AdminUiService.java From zuihou-admin-boot with Apache License 2.0 | 6 votes |
/** * 超管账号登录 * * @param account 账号 * @param password 密码 * @return */ public R<AuthInfo> adminLogin(String account, String password) { String basicHeader = ServletUtil.getHeader(WebUtils.request(), BASIC_HEADER_KEY, StrPool.UTF_8); String[] client = JwtUtil.getClient(basicHeader); GlobalUser user = this.globalUserService.getOne(Wrappers.<GlobalUser>lambdaQuery() .eq(GlobalUser::getAccount, account).eq(GlobalUser::getTenantCode, BizConstant.SUPER_TENANT)); // 密码错误 if (user == null) { throw new BizException(ExceptionCode.JWT_USER_INVALID.getCode(), ExceptionCode.JWT_USER_INVALID.getMsg()); } String passwordMd5 = SecureUtil.md5(password); if (!user.getPassword().equalsIgnoreCase(passwordMd5)) { return R.fail("用户名或密码错误!"); } JwtUserInfo userInfo = new JwtUserInfo(user.getId(), user.getAccount(), user.getName()); AuthInfo authInfo = tokenUtil.createAuthInfo(userInfo, null); log.info("token={}", authInfo.getToken()); return R.success(authInfo); }
Example 2
Source File: AdminUiService.java From zuihou-admin-cloud with Apache License 2.0 | 6 votes |
/** * 超管账号登录 * * @param account 账号 * @param password 密码 * @return */ public R<AuthInfo> adminLogin(String account, String password) { String basicHeader = ServletUtil.getHeader(WebUtils.request(), BASIC_HEADER_KEY, StrPool.UTF_8); String[] client = JwtUtil.getClient(basicHeader); GlobalUser user = this.globalUserService.getOne(Wrappers.<GlobalUser>lambdaQuery() .eq(GlobalUser::getAccount, account).eq(GlobalUser::getTenantCode, BizConstant.SUPER_TENANT)); // 密码错误 if (user == null) { throw new BizException(ExceptionCode.JWT_USER_INVALID.getCode(), ExceptionCode.JWT_USER_INVALID.getMsg()); } String passwordMd5 = SecureUtil.md5(password); if (!user.getPassword().equalsIgnoreCase(passwordMd5)) { return R.fail("用户名或密码错误!"); } JwtUserInfo userInfo = new JwtUserInfo(user.getId(), user.getAccount(), user.getName()); AuthInfo authInfo = tokenUtil.createAuthInfo(userInfo, null); log.info("token={}", authInfo.getToken()); return R.success(authInfo); }
Example 3
Source File: AbstractTokenGranter.java From zuihou-admin-boot with Apache License 2.0 | 5 votes |
/** * 检测 client * * @return */ protected R<String[]> checkClient() { String basicHeader = ServletUtil.getHeader(WebUtils.request(), BASIC_HEADER_KEY, StrPool.UTF_8); String[] client = JwtUtil.getClient(basicHeader); Application application = applicationService.getOne(Wraps.<Application>lbQ().eq(Application::getClientId, client[0]) .eq(Application::getClientSecret, client[1])); if (application == null) { return R.fail("请填写正确的客户端ID或者客户端秘钥"); } if (!application.getStatus()) { return R.fail("客户端[%s]已被禁用", application.getClientId()); } return R.success(client); }
Example 4
Source File: AbstractTokenGranter.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
/** * 检测 client * * @return */ protected R<String[]> checkClient() { String basicHeader = ServletUtil.getHeader(WebUtils.request(), BASIC_HEADER_KEY, StrPool.UTF_8); String[] client = JwtUtil.getClient(basicHeader); Application application = applicationService.getOne(Wraps.<Application>lbQ().eq(Application::getClientId, client[0]) .eq(Application::getClientSecret, client[1])); if (application == null) { return R.fail("请填写正确的客户端ID或者客户端秘钥"); } if (!application.getStatus()) { return R.fail("客户端[%s]已被禁用", application.getClientId()); } return R.success(client); }