diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-30 13:46:51 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-30 13:46:51 +0000 |
commit | c8f58fe2afa3f2f3bdf86846a48cb5a6dd7d503b (patch) | |
tree | b96a10cd0bf623da0612ceff196be9315c7da2e8 /branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationReferencePolicyInterceptor.java | |
parent | b30b676df944c0444a7a6ec8df26f8208a01e896 (diff) |
Tidy jms policy implementations to remove code from the binding and put it into binding wire interceptors. The implication is that the JMS runtime no longer depends on the JMS policy package. Also get rid of split packages in wire format and operation selector packages. Add a binding context to the Tuscany message so that you don't have to keep finding it in the message header.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@721811 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationReferencePolicyInterceptor.java | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationReferencePolicyInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationReferencePolicyInterceptor.java index 17b5da42be..56fffeb817 100644 --- a/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationReferencePolicyInterceptor.java +++ b/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationReferencePolicyInterceptor.java @@ -19,8 +19,12 @@ package org.apache.tuscany.sca.binding.jms.policy.authentication.token; +import javax.jms.JMSException; import javax.security.auth.Subject; +import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext; +import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; +import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; @@ -38,14 +42,12 @@ import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal; public class JMSTokenAuthenticationReferencePolicyInterceptor implements Interceptor { private Invoker next; - private Operation operation; private PolicySet policySet = null; private String context; private JMSTokenAuthenticationPolicy policy; - public JMSTokenAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) { + public JMSTokenAuthenticationReferencePolicyInterceptor(String context, PolicySet policySet) { super(); - this.operation = operation; this.policySet = policySet; this.context = context; init(); @@ -63,20 +65,29 @@ public class JMSTokenAuthenticationReferencePolicyInterceptor implements Interce } public Message invoke(Message msg) { - // could call out here to some 3rd party system to get credentials - - if ( policy.getTokenName() != null){ - - Subject subject = SecurityUtil.getSubject(msg); - TokenPrincipal principal = SecurityUtil.getPrincipal(subject, TokenPrincipal.class); - - if (principal == null){ - principal = new TokenPrincipal("SomeJMSAuthorizationToken"); - subject.getPrincipals().add(principal); - } - } - - return getNext().invoke(msg); + try { + javax.jms.Message jmsMsg = msg.getBody(); + + if ( policy.getTokenName() != null){ + + Subject subject = SecurityUtil.getSubject(msg); + TokenPrincipal principal = SecurityUtil.getPrincipal(subject, TokenPrincipal.class); + + if (principal == null){ + // should call out here to some 3rd party system to get credentials + // and correct token. Here we are just putting in the token name + principal = new TokenPrincipal("DummyTokenID"); + subject.getPrincipals().add(principal); + } + + jmsMsg.setStringProperty(policy.getTokenName().toString(), principal.getName()); + } + + return getNext().invoke(msg); + + } catch (JMSException e) { + throw new JMSBindingException(e); + } } public Invoker getNext() { |