Este contenido no está disponible en el idioma seleccionado.
Chapter 6. Policy
6.1. About Policy Copiar enlaceEnlace copiado en el portapapeles!
6.2. Configuring Policy Copiar enlaceEnlace copiado en el portapapeles!
- Policy that the service provider requires
- Policy support that the service consumer provides
<composite name="policy-transaction">
<service name="WorkService" promote="WorkService">
<camel:binding.camel configURI="jms://policyQSTransacted?connectionFactory=%23JmsXA&transactionManager=%23jtaTransactionManager&transacted=true"/>
<camel:binding.camel configURI="jms://policyQSNonTransacted?connectionFactory=#ConnectionFactory"/>
</service>
<component name="WorkService">
<implementation.bean class="org.switchyard.quickstarts.demo.policy.transaction.WorkServiceBean" requires="managedTransaction.Global"/>
<service name="WorkService" requires="propagatesTransaction">
<interface.java interface="org.switchyard.quickstarts.demo.policy.transaction.WorkService"/>
</service>
<reference name="TaskAService" requires="propagatesTransaction">
<interface.java interface="org.switchyard.quickstarts.demo.policy.transaction.TaskAService"/>
</reference>
</component>
</composite>
6.3. Interaction Policy Copiar enlaceEnlace copiado en el portapapeles!
requires attribute. You can use the Interaction policy on component service and component reference and is not allowed to be marked on component implementation. This policy enables you to manage the communication between the service provider and consumer.
6.4. Implementation Policy Copiar enlaceEnlace copiado en el portapapeles!
requires attribute. You can use the Implementation policy on component implementation and is not allowed to be marked on component service nor component reference.
6.5. Transaction Policy Copiar enlaceEnlace copiado en el portapapeles!
6.5.1. Transaction Interaction Policy Copiar enlaceEnlace copiado en el portapapeles!
requires attribute. Here is an example:
<service name="WorkService" requires="propagatesTransaction">
propagatesTransaction: Indicates that a global transaction is required when a service is invoked. If no transaction is present, the SwitchYard generates an error at runtime.suspendsTransaction: Indicates that if a transaction exists, the SwitchYard runtime suspends it before the service implementation is invoked and resumes it after the service invocation. This setting allows you to separate a gateway binding's transactional context from the transactional context of the service implementation.
propagatesTransaction and suspendsTransaction intents either to an interface or explicitly to a service and reference XML element in order to describe how any client transaction context is made available and used by the target service component.
Figure 6.1. Transaction Interaction Policy
6.5.2. Transaction Implementation Policy Copiar enlaceEnlace copiado en el portapapeles!
requires attribute. Here is an example:
<implementation.bean class="org.switchyard.quickstarts.demo.policy.transaction.WorkServiceBean" requires="managedTransaction.Global">
managedTransaction.Global: Indicates that this service implementation runs under a global transaction. If no transaction is present, the SwitchYard runtime creates a new JTA transaction before the execution. The SwitchYard runtime commits this newly created transaction at the end of service execution.managedTransaction.Local: Indicates that this service implementation runs under a local transaction. If a transaction exists, the SwitchYard runtime suspends it. SwitchYard always creates a new JTA transaction before execution. The SwitchYard runtime commits this newly created transaction and resumes the suspended transcation after the service invocation.Note
As the local transaction does not propagate its transaction through the reference, you must mark all of the component reference assuspendsTransaction. If not, the SwitchYard runtime generates an error.noManagedTransaction: Indicates that this service implementation does not run under any managed transaction. If a transaction exists, the SwitchYard runtime suspends it before the service implementation is invoked and resumes it after the service invocation.
managedTransaction and noManagedTransaction intents to describe the transactional environment required by a service component.
Currently, the following gateways are transaction aware:
- Camel JMS Gateway (binding.jms)
- Camel JPA Gateway (binding.jpa)
- Camel SQL Gateway (binding.sql)
- JCA Gateway (binding.jca)
- SCA Gateway (binding.sca)
Note
Note
Figure 6.2. Transaction Implementation Policy
6.6. Security Policy Copiar enlaceEnlace copiado en el portapapeles!
Note
- security.policy- It defines a JVM level permitAll policy.
- kie.policy- It is used by Rule-based services.
- rtgov.policy- It is used for the Runtime Governance REST API.
Note
6.6.1. Security Interaction Policy Copiar enlaceEnlace copiado en el portapapeles!
requires attribute of a component service definition.
<service name="WorkService" requires="authorization clientAuthentication confidentiality">
- clientAuthentication: indicates that the client has been authenticated when a service is invoked. If the associated authenticated user principal is not available, SwitchYard runtime generates an error.
- confidentiality: indicates that the request has been made over a secure channel. When a SOAP request is made over SSL and its confidentiality is not verified, SwitchYard runtime generates an error,
Figure 6.3. Security Interaction Policy
6.6.2. Security Implementation Policy Copiar enlaceEnlace copiado en el portapapeles!
- authorization: indicates that the client is authorized to invoke the service. If the associated authenticated subject does not have an allowed role, SwitchYard runtime generates an error.
Figure 6.4. Security Implementation Policy
6.6.3. Setting Security Policy Copiar enlaceEnlace copiado en el portapapeles!
- Edit the SwitchYard application descriptor (
switchyard.xml) and add therequiresattribute to a service definition.
- Use the
@Requiresattribute in your service implementation to declare security policy for the service. When the application project is built, the SwitchYard application finds@Requiresannotations and automatically generates the required configuration.
6.6.4. Security Processing Copiar enlaceEnlace copiado en el portapapeles!
switchyard.xml.
<switchyard>
<domain>
<security callbackHandler="callback-handler-class-name" moduleName"="jaas-domain-name" rolesAllowed="users, administrators" runAs="leaders">
<properties>
<property name="property-name" value="property-value"/>
</properties>
</security>
</domain>
</switchyard>
Note