From fb73a4c88fc384ad174318b8889d2c133f7ddfa6 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Fri, 7 Jul 2023 17:23:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9contentType=E7=BC=96=E7=A0=81?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ops/framework/security/core/utils/SecurityUtils.java | 6 ++++-- .../ops/framework/web/config/OrionWebAutoConfiguration.java | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/utils/SecurityUtils.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/utils/SecurityUtils.java index 57a3d4de..98c6539f 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/utils/SecurityUtils.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/utils/SecurityUtils.java @@ -22,6 +22,8 @@ import java.util.Collections; */ public class SecurityUtils { + private static final int BEARER_PREFIX_LEN = 7; + private SecurityUtils() { } @@ -36,10 +38,10 @@ public class SecurityUtils { if (Strings.isEmpty(authorization)) { return null; } - if (!authorization.contains(Const.BEARER) || authorization.length() <= 7) { + if (!authorization.contains(Const.BEARER) || authorization.length() <= BEARER_PREFIX_LEN) { return null; } - return authorization.substring(7).trim(); + return authorization.substring(BEARER_PREFIX_LEN).trim(); } /** diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java index 8f78a9b1..47a0e3b2 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java @@ -26,6 +26,7 @@ import org.springframework.web.filter.CorsFilter; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -94,7 +95,9 @@ public class OrionWebAutoConfiguration implements WebMvcConfigurer { SerializerFeature.WriteNullListAsEmpty, SerializerFeature.IgnoreNonFieldGetter ); + config.setCharset(StandardCharsets.UTF_8); converter.setFastJsonConfig(config); + converter.setDefaultCharset(StandardCharsets.UTF_8); return converter; }