diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-15 08:07:58 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-15 08:07:58 +0000 |
commit | fa51018b6c24f598ae8174afa183b0b46436e69b (patch) | |
tree | b6c37b85d26f0755ba95200227ea942bd2135c00 /java/sca/modules/binding-jms-runtime | |
parent | 5c5b60f1525a5865a3c2bc35263224c2cd79c713 (diff) |
More work exploring the policy extension model by implementing a token based authentication schema across binding.ws and binding.jm. No authentication is actually performed here. That is left for users to provide their own policy interceptors. However tokens are passed and security Subjects/Principals are created. This exercise has highlighted some awkwardness in the process of building policy implementations. I'll post about this on the mail list.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@695374 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-jms-runtime')
3 files changed, 54 insertions, 0 deletions
diff --git a/java/sca/modules/binding-jms-runtime/pom.xml b/java/sca/modules/binding-jms-runtime/pom.xml index 62eb3de60d..18085ccebf 100644 --- a/java/sca/modules/binding-jms-runtime/pom.xml +++ b/java/sca/modules/binding-jms-runtime/pom.xml @@ -35,6 +35,12 @@ <artifactId>tuscany-binding-jms</artifactId> <version>1.4-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jms-policy</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java index a14e2bd018..5d8053e02d 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.binding.jms.provider; import java.lang.reflect.InvocationTargetException; +import java.util.List; import java.util.Map; import javax.jms.DeliveryMode; @@ -33,10 +34,13 @@ import javax.naming.NamingException; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.invocation.DataExchangeSemantics; import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; import org.apache.tuscany.sca.runtime.ReferenceParameters; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; @@ -59,6 +63,7 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { protected Destination bindingRequestDest; protected Destination bindingReplyDest; protected RuntimeComponentReference reference; + protected JMSTokenAuthenticationPolicy jmsTokenAuthenticationPolicy = null; public JMSBindingInvoker(JMSBinding jmsBinding, Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeComponentReference reference) { @@ -71,6 +76,20 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); + // find out which policies are active + if (jmsBinding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)jmsBinding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (JMSTokenAuthenticationPolicy.class.isInstance(p)) { + jmsTokenAuthenticationPolicy = (JMSTokenAuthenticationPolicy)p; + }else { + // etc. check for other types of policy being present + } + } + } + } + try { bindingRequestDest = lookupDestination(); @@ -353,6 +372,11 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { jmsMsg.setObjectProperty(propName, value); } } + + if (jmsTokenAuthenticationPolicy != null) { + String token = (String)tuscanyMsg.getHeaders().get(jmsTokenAuthenticationPolicy.getTokenName().toString()); + jmsMsg.setStringProperty(jmsTokenAuthenticationPolicy.getTokenName().toString(), token); + } } protected boolean hasCallback() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java index 1990e553e0..f28c85f160 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java @@ -37,9 +37,12 @@ import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; +import org.apache.tuscany.sca.binding.jms.policy.authentication.token.JMSTokenAuthenticationPolicy; import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl; import org.apache.tuscany.sca.core.invocation.MessageImpl; import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; import org.apache.tuscany.sca.runtime.EndpointReference; import org.apache.tuscany.sca.runtime.ReferenceParameters; import org.apache.tuscany.sca.runtime.RuntimeComponentService; @@ -62,6 +65,7 @@ public class JMSBindingListener implements MessageListener { private JMSMessageProcessor responseMessageProcessor; private String correlationScheme; private List<Operation> serviceOperations; + protected JMSTokenAuthenticationPolicy jmsTokenAuthenticationPolicy = null; public JMSBindingListener(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeComponentService service, Binding targetBinding) throws NamingException { this.jmsBinding = jmsBinding; @@ -72,6 +76,20 @@ public class JMSBindingListener implements MessageListener { responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); correlationScheme = jmsBinding.getCorrelationScheme(); serviceOperations = service.getInterfaceContract().getInterface().getOperations(); + + // find out which policies are active + if (jmsBinding instanceof PolicySetAttachPoint) { + List<PolicySet> policySets = ((PolicySetAttachPoint)jmsBinding).getApplicablePolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (JMSTokenAuthenticationPolicy.class.isInstance(p)) { + jmsTokenAuthenticationPolicy = (JMSTokenAuthenticationPolicy)p; + }else { + // etc. check for other types of policy being present + } + } + } + } } @@ -184,6 +202,12 @@ public class JMSBindingListener implements MessageListener { parameters.setCallbackID(callbackID); } } + + if (jmsTokenAuthenticationPolicy != null) { + String token = requestJMSMsg.getStringProperty(jmsTokenAuthenticationPolicy.getTokenName().toString()); + tuscanyMsg.getHeaders().put(jmsTokenAuthenticationPolicy.getTokenName().toString(), + token); + } } protected void sendReply(Message requestJMSMsg, Object responsePayload, boolean isFault) { |