Commit cb845726f63f275e2def6101459833da6cc23681
1 parent
72852799
优化代码
Showing
3 changed files
with
17 additions
and
11 deletions
src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java
| ... | ... | @@ -11,6 +11,9 @@ import javax.servlet.http.HttpServletRequest; |
| 11 | 11 | import javax.servlet.http.HttpServletResponse; |
| 12 | 12 | import java.io.IOException; |
| 13 | 13 | |
| 14 | +/** | |
| 15 | + * @author lin | |
| 16 | + */ | |
| 14 | 17 | @Component |
| 15 | 18 | public class LoginSuccessHandler implements AuthenticationSuccessHandler { |
| 16 | 19 | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
| ... | ... | @@ -20,6 +20,7 @@ import java.util.List; |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * 配置Spring Security |
| 23 | + * @author lin | |
| 23 | 24 | */ |
| 24 | 25 | @Configuration |
| 25 | 26 | @EnableWebSecurity |
| ... | ... | @@ -132,15 +133,19 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| 132 | 133 | .anyRequest().authenticated() |
| 133 | 134 | // 异常处理(权限拒绝、登录失效等) |
| 134 | 135 | .and().exceptionHandling() |
| 135 | - .authenticationEntryPoint(anonymousAuthenticationEntryPoint)//匿名用户访问无权限资源时的异常处理 | |
| 136 | + //匿名用户访问无权限资源时的异常处理 | |
| 137 | + .authenticationEntryPoint(anonymousAuthenticationEntryPoint) | |
| 136 | 138 | // .accessDeniedHandler(accessDeniedHandler)//登录用户没有权限访问资源 |
| 137 | - // 登入 | |
| 138 | - .and().formLogin().permitAll()//允许所有用户 | |
| 139 | - .successHandler(loginSuccessHandler)//登录成功处理逻辑 | |
| 140 | - .failureHandler(loginFailureHandler)//登录失败处理逻辑 | |
| 139 | + // 登入 允许所有用户 | |
| 140 | + .and().formLogin().permitAll() | |
| 141 | + //登录成功处理逻辑 | |
| 142 | + .successHandler(loginSuccessHandler) | |
| 143 | + //登录失败处理逻辑 | |
| 144 | + .failureHandler(loginFailureHandler) | |
| 141 | 145 | // 登出 |
| 142 | - .and().logout().logoutUrl("/api/user/logout").permitAll()//允许所有用户 | |
| 143 | - .logoutSuccessHandler(logoutHandler)//登出成功处理逻辑 | |
| 146 | + .and().logout().logoutUrl("/api/user/logout").permitAll() | |
| 147 | + //登出成功处理逻辑 | |
| 148 | + .logoutSuccessHandler(logoutHandler) | |
| 144 | 149 | .deleteCookies("JSESSIONID") |
| 145 | 150 | // 会话管理 |
| 146 | 151 | // .and().sessionManagement().invalidSessionStrategy(invalidSessionHandler) // 超时处理 | ... | ... |
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 |
| 64 | 64 | device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); |
| 65 | 65 | } |
| 66 | 66 | device.setKeepaliveTime(DateUtil.getNow()); |
| 67 | + // 回复200 OK | |
| 68 | + responseAck(evt, Response.OK); | |
| 67 | 69 | if (device.getOnline() == 1) { |
| 68 | - // 回复200 OK | |
| 69 | - responseAck(evt, Response.OK); | |
| 70 | 70 | deviceService.updateDevice(device); |
| 71 | 71 | }else { |
| 72 | 72 | // 对于已经离线的设备判断他的注册是否已经过期 |
| 73 | 73 | if (!deviceService.expire(device)){ |
| 74 | 74 | deviceService.online(device); |
| 75 | - // 回复200 OK | |
| 76 | - responseAck(evt, Response.OK); | |
| 77 | 75 | } |
| 78 | 76 | } |
| 79 | 77 | } catch (SipException e) { | ... | ... |