...
It is also possible to implement policy interceptor provider programmatically from scratch. It's constructor gives assertions QNames as argument of super constructor and adds corresponded interceptors using getters:
Code Block |
---|
public class AuthorizationInterceptorProviderMyInterceptorProvider extends AbstractPolicyInterceptorProvider { private static final long serialVersionUID = -5248428637449096540L; private static final AuthorizationInInterceptorMyInInterceptor IN_AUTHZINTERCEPTOR = new MyInInterceptor(); private static final MyOutInterceptor OUT_INTERCEPTOR = new AuthorizationInInterceptorMyOutInterceptor(); private static final AuthorizationInInterceptorMyOutFaultInterceptor OUT_AUTHZFAULT_INTERCEPTOR = new AuthorizationOutInterceptorMyOutFaultInterceptor(); private static final Collection<QName> ASSERTION_TYPES; static { ASSERTION_TYPES = new ArrayList<QName>(); ASSERTION_TYPES.add(AuthorizationConstants.AUTHORIZATION_ASSERTION(new QName("www.mycompany.org", "myassertion")); } public AuthorizationInterceptorProviderMyInterceptorProvider() { super(ASSERTION_TYPES); getInInterceptors().add(IN_AUTHZINTERCEPTOR); getOutInterceptors().add(OUT_INTERCEPTOR); getOutInterceptorsgetOutFaultInterceptors().add(OUT_AUTHZFAULT_INTERCEPTOR); } } |
Since version 2.5.2, Assertion builder and policy interceptor provider can be registered using CXF bus extension mechanism: just create a file META-INF/cxf/bus-extensions.txt containing the following:
Code Block |
---|
org.company.MyInterceptorProvider::true
org.company.MyAssertionBuilder::true
|
Boolean value at the end specifies lazy loading strategy.
CXF automatically recognizes the assertion builder and policy interceptor provider and store them into registries: AssertionBuilderRegistry and PolicyInterceptorProviderRegistry. Since CXF 2.6.0 it is possible to register multiple interceptor providers for single assertion.
Implementing a Policy-Aware Conduit/Destination
...