You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Retrieval of Policies

Policies are associated with policy subjects. In the web services context, there are four different subjects:

  • Service
  • Endpoint
  • Operation
  • Message

Note that subjects do not correspond to wsdl elements directly. Rather, they map to a set of wsdl elements that are used to compute the effective policy for a subject (see below). For example wsdl:port, wsdl:portType and wsdl:binding elements together describe the endpoint as a subject.

Using WSDL 1.1, the policy-subject association usually takes the form of xml element attachment, i.e. a wsp:Policy (or wsp:PolicyReference) element, with wsp as prefix for http://www.w3.org/2006/07/ws-policy namespace, is attached to a WSDL element such as wsdl:port (in case of a PolicyReference the actual policy may reside outside of the wsdl).
Alternatively, policies can be attached to their subjects by external attachment, i.e. by means of wsdp:PolicyAttachment elements, which can reside in arbitrary locations.

In CXF, elements attached to a wsdl element are available as extensors in the service model representation of that wsdl element: wsp:Policy and wsdp:PolicyReference elements can be obtained through the service model as extensors of type UnknownExtensibilityElement with matching element names (note that these attached elements are not parsed when the service model is built).
Policies attached to their subject through xml element attachment in WSDL 1.1 can therefore be obtained through the service model associated with an endpoint/an operation.

The location of documents containing PolicyAttachment documents however needs to be made known to the framework. You can do this through configuration:

<bean class="org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider">
    <constructor-arg ref="cxf"/>
    <property name="location" value="org/apache/cxf/systest/ws/policy/addr-external.xml"/>
</bean>

The location of the document containing PolicyAttachments is specified in the form of a classpath resource or URL. You can specifify any number of external attachment providers.

Note that PolicyAttachments are extensible w.r.t. the type of domain expressions. Domain expressions are used to identify entities such as endpoints, operations or messages with which a policy can be associated:

<wsp:PolicyAttachment>
    <wsp:AppliesTo> 
        <x:DomainExpression/> +
    </wsp:AppliesTo>
    (<wsp:Policy>...</wsp:Policy> | <wsp:PolicyReference>...</wsp:PolicyReference>)
</wsp:PolicyAttachment>

Currently, CXF supports domain only domain expressions of type wsa:EndpointReferenceType: This allows to associate the policies or policy references in an attachment with an endpoint (by means of matching the endpoint's address with that in the EndpointReferenceType element).
Support for other types of domain expressions can be plugged in by implementing the DomainExpressionBuilder interface and adding a corresponding bean to your configuration file (all DomainExpressionBuilder instances loaded that way will automatically register with the DomainExpressionBuilder and thus be considered in the process of parsing PolicyAttachment elements).

Now that the framework knows where to look for wsp:Policy and wsp:PolicyReference elements, it parses the elements and creates runtime presentations for them. This is where AssertionBuilders come into play: Child elements of a wsp:Policy element that are not in the wsp namespace identifies the element as an assertion. The framework will use its AssertionBuilderRegistry to find an AssertionBuilder registered for the element type in question and in that case proceed to build an Assertion object (or else throw a PolicyException).

Computation of Effective Policies

On-the-fly Provision of Interceptors

Verification

  • No labels