The PolicyAnnotationListener
(rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java)
is where you would probably be looking at to add actual dynamic support as
discussed above.




On Tue, May 21, 2013 at 9:08 PM, Jason Pell <[email protected]> wrote:

> Hi,
>
> Not sure if this will suffice, but you can reference spring bean id's in
> java first @Policy annotations, for example:
>
>
> https://github.com/pellcorp/cxf/blob/master/JavaFirst/src/main/java/com/pellcorp/server/security/SecuritySimpleServiceImpl.java
>
> See that I have used:
>
> @Policy(uri="#UsernamePasswordPolicy",
>
> Which has been defined here:
>
>
> https://github.com/pellcorp/cxf/blob/master/JavaFirst/src/main/resources/UsernamePasswordPolicy.xml
>
> You can then import your policies into your spring context, see for
> example:
>
>
> https://github.com/pellcorp/cxf/blob/master/JavaFirst/src/main/resources/META-INF/applicationContext.xml
>
> What I then do if I want to vary the policy definition is have different
> spring xml files all with the same # bean id, and based on spring
> properties import the correct one.
>
> <import resource="${security.policy.file}" />
>
> It does not give you actual dynamic based on spring properties, but if you
> can define 3 bean names and then have various different spring files that
> each define those three, you can configure which to import.
>
>
>
> On Mon, May 20, 2013 at 4:42 PM, Josh Hill <[email protected]> wrote:
>
>>  I annotate my web services with one class level policy and two per
>> method to take advantage of the placement attribute (see Fig 1). I would
>> like to set the policy’s uri as a spring property (see Fig 2). ****
>>
>> ** **
>>
>> My first solution was to use an custom policy in/out interceptor to read
>> the @Policy annotation’s uri and if surround with “${}” then build a
>> dynamic policy using Neethi and set it to PolicyConstants.POLICY_OVERRIDE.
>> A problem I encountered with this approach is that I need to attach three
>> different policies using different placements. Merging them may be a last
>> resort option.****
>>
>> ** **
>>
>> A temporary hack would be to alter
>> org.apache.cxf.resource.ExtendedURIResolver.resolve() to resolve a uri
>> surrounded with “${}” to a spring property. I’m hoping someone here can
>> suggest a better solution.****
>>
>> ** **
>>
>> Any thoughts****
>>
>> ** **
>>
>> Fig 1.****
>>
>> @WebService****
>>
>> @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
>> SOAPBinding.Use.LITERAL)****
>>
>> @Policy(uri = "classpath:/policy/service.policy", placement =
>> Policy.Placement.SERVICE)****
>>
>> public interface ProductWS {****
>>
>> ** **
>>
>>     @WebMethod****
>>
>>     @WebResult(name = "product-wsresponse")****
>>
>>     @Policies({****
>>
>>             @Policy(uri = "classpath:/policy/service-input.policy",
>> placement = Policy.Placement.BINDING_OPERATION_INPUT),****
>>
>>             @Policy(uri = "classpath:/policy/service-output.policy",
>> placement = Policy.Placement.BINDING_OPERATION_OUTPUT)****
>>
>>     })****
>>
>>     ProductResponseMessage products(@WebParam(name = "product-wsrequest")
>> ProductRequestMessage productRequestMessage);****
>>
>> }****
>>
>> ** **
>>
>> Fig 2.****
>>
>> @WebService****
>>
>> @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
>> SOAPBinding.Use.LITERAL)****
>>
>> @Policy(uri = "${product.service.policy}", placement =
>> Policy.Placement.SERVICE)****
>>
>> public interface ProductWS {****
>>
>> ** **
>>
>>     @WebMethod****
>>
>>     @WebResult(name = "product-wsresponse")****
>>
>>     @Policies({****
>>
>>             @Policy(uri = "${product.service.input.policy}", placement =
>> Policy.Placement.BINDING_OPERATION_INPUT),****
>>
>>             @Policy(uri = "${product.service.output.policy}", placement =
>> Policy.Placement.BINDING_OPERATION_OUTPUT)****
>>
>>     })****
>>
>>     ProductResponseMessage products(@WebParam(name = "product-wsrequest")
>> ProductRequestMessage productRequestMessage);****
>>
>> } ****
>>
>>
>>
>> *Josh Hill*
>> Senior Java Developer
>>
>>
>>
>> [image: Finzsoft - Your Vision + Our Innovations]
>>
>>
>>
>> sovereign finance and banking software
>>
>>
>>
>> *A* Level 1, Building C, Millennium Centre, 602 Great South Road,
>> Greenlane, Auckland, New Zealand
>> *D* 64 9 571 6812       *P* 64 9 571 6800    *F* 64 9 571 6899
>> *E* [email protected]    *W* www.finzsoft.com
>>
>>
>>       *Please note*: This email contains information that is
>> confidential and may be privileged. If you are not the intended recipient, 
>> you
>> must not peruse, use, disseminate, distribute or copy this email or
>> attachments. If you have received this in error, please notify Finzsoft
>> Solutions (New Zealand) Ltd immediately by return email and delete this
>> email. Thank you.
>>
>>
>> ______________________________________________________________________
>> This email has been scanned by the Symantec Email Security.cloud service.
>> ______________________________________________________________________
>>
>
>

Reply via email to