1) Depends. If you actually need to act on the policy (and fail/fault if the policy is not met) in one way or another, then yes. If the policy is more informational and not something you need to really assert, then no. You can use the IgnorablePolicyInterceptorProvider to have the policy “asserted” without really doing anything.
2) Looks correct. All interceptors you add should be AFTER the Policy*Interceptors as the effective policy is computed there, then subsequence interceptors would have to assert true/false the assertions that have been met. 3) No 4) None that I’m aware of. Dan > On Jun 18, 2015, at 10:46 AM, ellen <[email protected]> wrote: > > Hi all, > > I would like to use a new custom ws-policy, and would like to let cxf know > and check it, I see there is a link about that, but there is no E2E code so > that my development is not work for me, could you please help me double > check which step is wrong? Appreciate it! :) > http://cxf.apache.org/docs/developing-assertions.html > > My custom policy like this: > <wsat:ATAssertion wsp:optional="true" /> > > </wsp:Policy> > > Question 1: > Need I develop AssertionBuilder and Policy-Aware Interceptor to know this > custom policy? > > Or I just need write an interceptor before PolicyInInterceptor, and then > run: > public void handleMessage(Message message) { > > // get AssertionInfoMap > org.apache.cxf.ws.policy.AssertionInfoMap aim = > message.get(org.apache.cxf.ws.policy.AssertionInfoMap.class); > Collection<AssertionInfo ais> = aim.get(assertionType ); > > // extract Assertion information > for (AssertionInfo ai : ais) { > org.apache.neethi.Assertion a = ai.getAssertion(); > MyAssertionType ma = (MyAssertionType)a; > // digest .... > } > > // process message ... > // express support > > for (AssertionInfo ai : ais) { > ai.setAsserted(...); > } } > } > To set assertion? > > > Question 2: > If question 1 is not, I need complete full flow of policy development, > what's the correct step? > > 1, Implementing the AssertionBuilder, complete build and getKnownElements > method, and return my Assertion object in build method. > > 2, Implement Policy-Aware Interceptor and MyInterceptorProvider, > in the interceptor, what I should do is: > // get AssertionInfoMap > org.apache.cxf.ws.policy.AssertionInfoMap aim = > message.get(org.apache.cxf.ws.policy.AssertionInfoMap.class); > Collection<AssertionInfo ais> = aim.get(assertionType ); > > // extract Assertion information > for (AssertionInfo ai : ais) { > org.apache.neethi.Assertion a = ai.getAssertion(); > MyAssertionType ma = (MyAssertionType)a; > // digest .... > } > > // process message ... > // express support > > for (AssertionInfo ai : ais) { > ai.setAsserted(...); > } } > to set Assertion? > > > And in MyInterceptorProvider is add these interceptor? > public MyInterceptorProvider() { > super(ASSERTION_TYPES); > getInInterceptors().add(IN_INTERCEPTOR); > getOutInterceptors().add(OUT_INTERCEPTOR); > getOutFaultInterceptors().add(OUT_FAULT_INTERCEPTOR); > } > But where to add them? before PolicyInInterceptor and PolicyOutInterceptor? > > Then add these in META-INF/cxf/bus-extensions.txt > org.company.MyInterceptorProvider::true > org.company.MyAssertionBuilder::true > > > Question 3: > If I implement AssertionBuilder and Policy-Aware Interceptor, Need I > implement a Policy-Aware Conduit/Destination? > > > Question 4: > > Do you have a full E2E document or link, so that I can deeply study? > I cannot search detail article in Google.... > > Great thanks a lot! > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/How-can-cxf-know-and-get-custom-ws-policy-tp5758385.html > Sent from the cxf-user mailing list archive at Nabble.com. -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
