简体   繁体   English

Apache CXF发送自定义响应,中止拦截器链

[英]Apache CXF Send custom response, abort interceptor chain

I have three interceptors and their execution order is as follows: 我有三个拦截器,它们的执行顺序如下:
- Security Interceptor -安全拦截器
- Authentication Interceptor -身份验证拦截器
- Authorization Interceptor -授权拦截器

First Security interceptor runs and if it fulfills security requirements then Authentication interceptor invokes and if authentication is done then AuthorizationInterceptor should invoke and authorize the call. 首先运行Security拦截器,如果它满足安全性要求,则调用Authentication拦截器;如果完成身份验证,则AuthorizationInterceptor应该调用并授权该调用。

But problem is that I need to abort the next two ( authentication , authorization ) interceptors if security is not fulfilled and return custom response from SecurityInterceptor. 但是问题是,如果安全性得不到满足,我需要中止接下来的两个(身份验证,授权)拦截器,并从SecurityInterceptor返回自定义响应。

If I call message.getInterceptorChain().abort(); 如果我打电话给message.getInterceptorChain()。abort(); then no response is sent. 那么没有响应被发送。 How do I abort processing of interceptors and send custom response ? 如何中止拦截器的处理并发送自定义响应?

My Security interceptor is at Phase.Receive and other two interceptors are at Phase.PRE_INVOKE phase. 我的安全拦截器处于Phase.Receive,其他两个拦截器处于Phase.PRE_INVOKE阶段。

你应该抛出Fault而不是调用interceptoror.abort()

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM