From cb845726f63f275e2def6101459833da6cc23681 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期一, 23 五月 2022 10:16:46 +0800 Subject: [PATCH] 优化代码 --- src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java | 3 +++ src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java | 19 ++++++++++++------- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/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 9690c6d..2d7e8a1 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.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 47cfdab..a4bbdba 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 @@ /** * 閰嶇疆Spring Security + * @author lin */ @Configuration @EnableWebSecurity @@ -132,15 +133,19 @@ .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 cf07250..c429457 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 @@ 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) { -- Gitblit v1.8.0