简体   繁体   English

Spring 安全性:如何使用自定义代码停止链?

[英]Spring security: how do I stop the chain with my custom code?

So, I have defined my custom filter and now I want to return in case something goes wrong:所以,我已经定义了我的自定义过滤器,现在我想返回以防出现问题:

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
     if(rulefail()){
        //what now??
      }

     filterChain.doFilter(servletRequest, servletResponse);
 }

I tried throwing a runtime exception but of course it isn't effective: the server returns the tomcat's default internal server error page.我尝试抛出运行时异常,但它当然无效:服务器返回 tomcat 的默认内部服务器错误页面。

From this answer, just return or don't do filterChain.dofiler.从这个答案中,只需返回或不执行 filterChain.dofiler。 See if this answer suffice https://stackoverflow.com/a/8445927/905494看看这个答案是否足够https://stackoverflow.com/a/8445927/905494

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为Spring MVC / Security静态Web服务创建自定义JSON 401页面? - How do I create a custom JSON 401 page for my Spring MVC/Security restful web service? 如何在Spring Security和ActiveDirectoryLdapAuthenticationProvider中使用自定义权限填充程序? - How do I use a custom authorities populator with Spring Security and the ActiveDirectoryLdapAuthenticationProvider? 在Spring Security中,如何捕获自定义AuthenticationManager中的异常? - In Spring Security how do I capture exceptions from a custom AuthenticationManager? 如何在Spring Security中使用自定义角色/权限? - How do I use custom roles/authorities in Spring Security? 自定义Spring Security过滤器链返回404 - Custom Spring Security filter chain returns 404 如何停止spring FilterRegistrationBean在/ *上注册过滤器 - How do I stop spring FilterRegistrationBean from registering my filter on /* 如何让 Spring Vault 信任作为 PEM 提供的自定义 TLS 链 - How do i get Spring Vault to trust a custom TLS chain provided as PEM 如何使用自定义过滤器映射将自定义过滤器添加到spring安全过滤器链中? - how to add custom filter to spring security filter chain with custom filter mapping? 如何在运行时修改Spring Security过滤器链? - How to modify Spring Security filter chain at runtime? 如何按条件中断Spring Security提供商链? - How to interrupt spring security provider chain by condition?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM