From a74ef4f1e64d1ec3c6841f86f322f9b7a9c74b89 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 23 May 2022 10:16:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conf/security/LoginSuccessHandler.java | 3 +++ .../vmp/conf/security/WebSecurityConfig.java | 19 ++++++++++++------- .../cmd/KeepaliveNotifyMessageHandler.java | 6 ++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java index 9690c6d1..2d7e8a1b 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java @@ -11,6 +11,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +/** + * @author lin + */ @Component public class LoginSuccessHandler implements AuthenticationSuccessHandler { diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java index 47cfdaba..a4bbdbac 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java @@ -20,6 +20,7 @@ import java.util.List; /** * 配置Spring Security + * @author lin */ @Configuration @EnableWebSecurity @@ -132,15 +133,19 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { .anyRequest().authenticated() // 异常处理(权限拒绝、登录失效等) .and().exceptionHandling() - .authenticationEntryPoint(anonymousAuthenticationEntryPoint)//匿名用户访问无权限资源时的异常处理 + //匿名用户访问无权限资源时的异常处理 + .authenticationEntryPoint(anonymousAuthenticationEntryPoint) // .accessDeniedHandler(accessDeniedHandler)//登录用户没有权限访问资源 - // 登入 - .and().formLogin().permitAll()//允许所有用户 - .successHandler(loginSuccessHandler)//登录成功处理逻辑 - .failureHandler(loginFailureHandler)//登录失败处理逻辑 + // 登入 允许所有用户 + .and().formLogin().permitAll() + //登录成功处理逻辑 + .successHandler(loginSuccessHandler) + //登录失败处理逻辑 + .failureHandler(loginFailureHandler) // 登出 - .and().logout().logoutUrl("/api/user/logout").permitAll()//允许所有用户 - .logoutSuccessHandler(logoutHandler)//登出成功处理逻辑 + .and().logout().logoutUrl("/api/user/logout").permitAll() + //登出成功处理逻辑 + .logoutSuccessHandler(logoutHandler) .deleteCookies("JSESSIONID") // 会话管理 // .and().sessionManagement().invalidSessionStrategy(invalidSessionHandler) // 超时处理 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java index cf07250d..c4294576 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java @@ -64,16 +64,14 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); } device.setKeepaliveTime(DateUtil.getNow()); + // 回复200 OK + responseAck(evt, Response.OK); if (device.getOnline() == 1) { - // 回复200 OK - responseAck(evt, Response.OK); deviceService.updateDevice(device); }else { // 对于已经离线的设备判断他的注册是否已经过期 if (!deviceService.expire(device)){ deviceService.online(device); - // 回复200 OK - responseAck(evt, Response.OK); } } } catch (SipException e) {