From 5a9621840c957db0545a9a0ac80d784e3d647a96 Mon Sep 17 00:00:00 2001
From: xubinbin <1323875150@qq.com>
Date: Tue, 12 Dec 2023 16:37:06 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A7=E5=88=B6?=
=?UTF-8?q?=E5=8F=B0=E8=BE=93=E5=87=BA=E6=97=A5=E5=BF=97=E6=A0=BC=E5=BC=8F?=
=?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA=E7=BA=BF=E7=A8=8B?=
=?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=8C=E8=B0=83=E7=94=A8=E7=B1=BB=E7=9A=84?=
=?UTF-8?q?=E5=85=A8=E7=B1=BB=E8=B7=AF=E5=BE=84=E4=BB=A5=E5=8F=8A=E6=97=A5?=
=?UTF-8?q?=E5=AD=90=E8=BE=93=E5=87=BA=E8=A1=8C=E7=9A=84=E8=A1=8C=E5=8F=B7?=
=?UTF-8?q?=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/resources/logback-spring.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml
index 76b4ba3e..04fa958a 100644
--- a/src/main/resources/logback-spring.xml
+++ b/src/main/resources/logback-spring.xml
@@ -4,8 +4,8 @@
-
-
+
From 360fe689b1df765ca6754d32921c1ee18f9e9c00 Mon Sep 17 00:00:00 2001
From: xubinbin <1323875150@qq.com>
Date: Tue, 12 Dec 2023 16:41:15 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=97=B6=E7=9A=84=E5=AE=8C=E5=85=A8=E9=99=90?=
=?UTF-8?q?=E5=AE=9A=E7=B1=BB=E5=90=8D=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=AE=9A?=
=?UTF-8?q?=E4=BD=8D=E6=97=A5=E5=BF=97=E4=BD=8D=E7=BD=AE=E3=80=82=20ps?=
=?UTF-8?q?=EF=BC=9A2023-12-12=2016:30:58.779=20[Thread-10]=20=20INFO=20--?=
=?UTF-8?q?-=20gov.nist.javax.sip.stack.UDPMessageChannel=20:=2081=20Done?=
=?UTF-8?q?=20processing=20MESSAGE=20sip:44010200492000000003@4401020049?=
=?UTF-8?q?=20SIP/2.0=20=E6=97=A5=E5=BF=97=E4=B8=AD=E7=9A=84=E2=80=9Cgov.n?=
=?UTF-8?q?ist.javax.sip.stack.UDPMessageChannel=E2=80=9D=E5=86=85?=
=?UTF-8?q?=E5=AE=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../iot/vmp/gb28181/conf/StackLoggerImpl.java | 176 +++++++++++-------
1 file changed, 104 insertions(+), 72 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java
index 5e67bdba..bab02856 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java
@@ -1,8 +1,8 @@
package com.genersoft.iot.vmp.gb28181.conf;
import gov.nist.core.StackLogger;
-import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.spi.LocationAwareLogger;
import org.springframework.stereotype.Component;
import java.util.Properties;
@@ -10,100 +10,132 @@ import java.util.Properties;
@Component
public class StackLoggerImpl implements StackLogger {
- private final static Logger logger = LoggerFactory.getLogger(StackLoggerImpl.class);
+ /**
+ * 完全限定类名(Fully Qualified Class Name),用于定位日志位置
+ */
+ private static final String FQCN = StackLoggerImpl.class.getName();
- @Override
- public void logStackTrace() {
+ /**
+ * 获取栈中类信息(以便底层日志记录系统能够提取正确的位置信息(方法名、行号))
+ * @return LocationAwareLogger
+ */
+ private static LocationAwareLogger getLocationAwareLogger() {
+ return (LocationAwareLogger) LoggerFactory.getLogger(new Throwable().getStackTrace()[4].getClassName());
+ }
- }
- @Override
- public void logStackTrace(int traceLevel) {
- System.out.println("traceLevel: " + traceLevel);
- }
+ /**
+ * 封装打印日志的位置信息
+ * @param level 日志级别
+ * @param message 日志事件的消息
+ */
+ private static void log(int level, String message) {
+ LocationAwareLogger locationAwareLogger = getLocationAwareLogger();
+ locationAwareLogger.log(null, FQCN, level, message, null, null);
+ }
- @Override
- public int getLineCount() {
- return 0;
- }
+ /**
+ * 封装打印日志的位置信息
+ * @param level 日志级别
+ * @param message 日志事件的消息
+ */
+ private static void log(int level, String message, Throwable throwable) {
+ LocationAwareLogger locationAwareLogger = getLocationAwareLogger();
+ locationAwareLogger.log(null, FQCN, level, message, null, throwable);
+ }
- @Override
- public void logException(Throwable ex) {
+ @Override
+ public void logStackTrace() {
- }
+ }
- @Override
- public void logDebug(String message) {
-// logger.debug(message);
- }
+ @Override
+ public void logStackTrace(int traceLevel) {
+ System.out.println("traceLevel: " + traceLevel);
+ }
- @Override
- public void logDebug(String message, Exception ex) {
-// logger.debug(message);
- }
+ @Override
+ public int getLineCount() {
+ return 0;
+ }
- @Override
- public void logTrace(String message) {
- logger.trace(message);
- }
+ @Override
+ public void logException(Throwable ex) {
- @Override
- public void logFatalError(String message) {
-// logger.error(message);
- }
+ }
- @Override
- public void logError(String message) {
-// logger.error(message);
- }
+ @Override
+ public void logDebug(String message) {
+ log(LocationAwareLogger.INFO_INT, message);
+ }
- @Override
- public boolean isLoggingEnabled() {
- return true;
- }
+ @Override
+ public void logDebug(String message, Exception ex) {
+ log(LocationAwareLogger.INFO_INT, message, ex);
+ }
- @Override
- public boolean isLoggingEnabled(int logLevel) {
- return true;
- }
+ @Override
+ public void logTrace(String message) {
+ log(LocationAwareLogger.INFO_INT, message);
+ }
- @Override
- public void logError(String message, Exception ex) {
-// logger.error(message);
- }
+ @Override
+ public void logFatalError(String message) {
+ log(LocationAwareLogger.INFO_INT, message);
+ }
- @Override
- public void logWarning(String message) {
- logger.warn(message);
- }
+ @Override
+ public void logError(String message) {
+ log(LocationAwareLogger.INFO_INT, message);
+ }
- @Override
- public void logInfo(String message) {
- logger.info(message);
- }
+ @Override
+ public boolean isLoggingEnabled() {
+ return true;
+ }
- @Override
- public void disableLogging() {
+ @Override
+ public boolean isLoggingEnabled(int logLevel) {
+ return true;
+ }
- }
+ @Override
+ public void logError(String message, Exception ex) {
+ log(LocationAwareLogger.INFO_INT, message, ex);
+ }
- @Override
- public void enableLogging() {
+ @Override
+ public void logWarning(String message) {
+ log(LocationAwareLogger.INFO_INT, message);
+ }
- }
+ @Override
+ public void logInfo(String message) {
+ log(LocationAwareLogger.INFO_INT, message);
+ }
- @Override
- public void setBuildTimeStamp(String buildTimeStamp) {
+ @Override
+ public void disableLogging() {
- }
+ }
- @Override
- public void setStackProperties(Properties stackProperties) {
+ @Override
+ public void enableLogging() {
- }
+ }
- @Override
- public String getLoggerName() {
- return null;
- }
+ @Override
+ public void setBuildTimeStamp(String buildTimeStamp) {
+
+ }
+
+ @Override
+ public void setStackProperties(Properties stackProperties) {
+
+ }
+
+ @Override
+ public String getLoggerName() {
+ return null;
+ }
}
From 42a2772d1aa7493bcc4fac3e24ee8eda4eebc23d Mon Sep 17 00:00:00 2001
From: xubinbin <1323875150@qq.com>
Date: Tue, 12 Dec 2023 17:09:04 +0800
Subject: [PATCH 3/3] =?UTF-8?q?bugfix=EF=BC=9A=E8=AF=B7=E6=B1=82=E5=A4=B4?=
=?UTF-8?q?=E5=B8=A6token=EF=BC=8C=20SecurityUtils=20=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E7=94=A8=E6=88=B7id=20=E4=B8=80=E7=9B=B4=E4=B8=BA0=20#1195?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../iot/vmp/conf/security/JwtAuthenticationFilter.java | 1 +
.../com/genersoft/iot/vmp/conf/security/JwtUtils.java | 1 +
.../com/genersoft/iot/vmp/conf/security/dto/JwtUser.java | 9 +++++++++
3 files changed, 11 insertions(+)
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java
index f35b5bd8..f45f89a1 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java
@@ -78,6 +78,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
// 构建UsernamePasswordAuthenticationToken,这里密码为null,是因为提供了正确的JWT,实现自动登录
User user = new User();
+ user.setId(jwtUser.getUserId());
user.setUsername(jwtUser.getUserName());
user.setPassword(jwtUser.getPassword());
Role role = new Role();
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java
index 65e9de37..3df75936 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java
@@ -144,6 +144,7 @@ public class JwtUtils implements InitializingBean {
jwtUser.setUserName(username);
jwtUser.setPassword(user.getPassword());
jwtUser.setRoleId(user.getRole().getId());
+ jwtUser.setUserId(user.getId());
return jwtUser;
} catch (InvalidJwtException e) {
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java b/src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java
index 8921a308..df29c333 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java
@@ -21,6 +21,7 @@ public class JwtUser {
EXCEPTION
}
+ private int userId;
private String userName;
private String password;
@@ -29,6 +30,14 @@ public class JwtUser {
private TokenStatus status;
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(int userId) {
+ this.userId = userId;
+ }
+
public String getUserName() {
return userName;
}