|
|
@@ -61,14 +61,12 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|
|
StringBuilder strBuilder = new StringBuilder();
|
|
|
String inputStr;
|
|
|
while ((inputStr = streamReader.readLine()) != null) strBuilder.append(inputStr);
|
|
|
- Systemmanager sysUser = JsonUtils.toBean(CenturyDecryptUtil.decryptForJson(strBuilder.toString(),request), Systemmanager.class);
|
|
|
+ Systemmanager sysUser = JsonUtils.toBean(CenturyDecryptUtil.decryptForJson(strBuilder.toString(), request), Systemmanager.class);
|
|
|
assert sysUser != null;
|
|
|
String username = sysUser.getUsername();
|
|
|
username = username != null ? username : "";
|
|
|
String password = sysUser.getPassword();
|
|
|
password = password != null ? password : "";
|
|
|
-// String lockPwd = EncryptionUtils.encryptSHA(username + password);
|
|
|
-// UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, lockPwd);
|
|
|
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);
|
|
|
setDetails(request, authRequest);
|
|
|
return getAuthenticationManager().authenticate(authRequest);
|
|
|
@@ -98,7 +96,7 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|
|
String token = JwtUtil.TOKEN_PREFIX + JwtUtil.generateToken(authResult.getName(), sb.toString());
|
|
|
// 将token添加到header中
|
|
|
response.setHeader(JwtUtil.TOKEN_HEADER, token);
|
|
|
- ResponseUtils.writeSucceed(response, HttpServletResponse.SC_OK, "用户认证通过!", true ,token);
|
|
|
+ ResponseUtils.writeSucceed(response, HttpServletResponse.SC_OK, "用户认证通过!", true, token);
|
|
|
log.info("登录成功,username: {}, token: {}", authResult.getName(), token);
|
|
|
}
|
|
|
|
|
|
@@ -146,17 +144,17 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|
|
|
|
|
//判断异常类
|
|
|
if (failed instanceof InternalAuthenticationServiceException) {
|
|
|
- ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "认证服务不正常!", false);
|
|
|
+ ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "认证服务不正常!", false);
|
|
|
} else if (failed instanceof UsernameNotFoundException) {
|
|
|
- ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户账户不存在!", false);
|
|
|
+ ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户账户不存在!", false);
|
|
|
} else if (failed instanceof BadCredentialsException) {
|
|
|
- ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, loginPWDFail_msg, false);
|
|
|
+ ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, loginPWDFail_msg == null ? failed.getMessage() : loginPWDFail_msg, false);
|
|
|
} else if (failed instanceof LockedException) {
|
|
|
- ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户账户已被锁!", false);
|
|
|
+ ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户账户已被锁!", false);
|
|
|
} else if (failed instanceof CredentialsExpiredException) {
|
|
|
- ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户密码已失效!", false);
|
|
|
+ ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户密码已失效!", false);
|
|
|
} else if (failed instanceof DisabledException) {
|
|
|
- ResponseUtils.writeFiled(response, HttpServletResponse.SC_FORBIDDEN, "用户账户已被锁!", false);
|
|
|
+ ResponseUtils.writeFiled(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "用户账户已被锁!", false);
|
|
|
}
|
|
|
}
|
|
|
}
|