♻️ 重构代码:公共字符串替换
This commit is contained in:
1 parent
2f6d6d087e
commit
542e022216
5 files changed
+11
-6
No files matched your search
+2
-1
@@ -23,6 +23,7 @@ import com.pig4cloud.pigx.common.core.constant.CommonConstant;
|
||||
import com.pig4cloud.pigx.common.security.util.AuthUtils;
|
||||
import lombok.Builder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
@@ -63,7 +64,7 @@ public class MobileLoginSuccessHandler implements AuthenticationSuccessHandler {
|
||||
*/
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
String header = request.getHeader("Authorization");
|
||||
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
|
||||
if (header == null || !header.startsWith(BASIC_)) {
|
||||
throw new UnapprovedClientAuthenticationException("请求头中client信息为空");
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ package com.pig4cloud.pigx.common.security.util;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
@@ -71,7 +72,7 @@ public class AuthUtils {
|
||||
*/
|
||||
public static String[] extractAndDecodeHeader(HttpServletRequest request)
|
||||
throws IOException {
|
||||
String header = request.getHeader("Authorization");
|
||||
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
|
||||
if (header == null || !header.startsWith(BASIC_)) {
|
||||
throw new RuntimeException("请求头中client信息为空");
|
||||
|
||||
Reference in new issue
Block a user