From ab6904bc2f622129bc548391745b08eb0c219e57 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 21 Jul 2009 07:03:47 +0000 Subject: Fix svn:eol-style and svn:keywords properties for java/xml files git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@796166 13f79535-47bb-0310-9956-ffa450edef68 --- .../token/Axis2TokenAuthenticationPolicy.java | 108 +++++----- .../Axis2TokenAuthenticationPolicyProcessor.java | 226 ++++++++++----------- ...s2TokenAuthenticationPolicyProviderFactory.java | 118 +++++------ ...enAuthenticationReferencePolicyInterceptor.java | 180 ++++++++-------- ...TokenAuthenticationReferencePolicyProvider.java | 142 ++++++------- ...okenAuthenticationServicePolicyInterceptor.java | 196 +++++++++--------- ...s2TokenAuthenticationServicePolicyProvider.java | 140 ++++++------- 7 files changed, 555 insertions(+), 555 deletions(-) (limited to 'java/sca/modules/binding-ws-axis2-policy') diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java index 0d6743bfe2..985f387178 100644 --- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java +++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java @@ -1,54 +1,54 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; - -import javax.xml.namespace.QName; - -/** - * Implementation for policies that could be injected as parameter - * into the axis2config. - * - * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $ - */ -public class Axis2TokenAuthenticationPolicy { - private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - public static final QName AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "axis2TokenAuthentication"); - public static final String AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME = "tokenName"; - - private QName tokenName; - - public QName getTokenName() { - return tokenName; - } - - public void setTokenName(QName tokenName) { - this.tokenName = tokenName; - } - - public QName getSchemaName() { - return AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; + +import javax.xml.namespace.QName; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationPolicy { + private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; + public static final QName AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "axis2TokenAuthentication"); + public static final String AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME = "tokenName"; + + private QName tokenName; + + public QName getTokenName() { + return tokenName; + } + + public void setTokenName(QName tokenName) { + this.tokenName = tokenName; + } + + public QName getSchemaName() { + return AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java index 61624bb346..9b1f870cee 100644 --- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java +++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java @@ -1,113 +1,113 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * - * Adjusted for 2.0 environment, Mike Edwards, 4th Dec 2008 - * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $ - */ -public class Axis2TokenAuthenticationPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { - private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - - public QName getArtifactType() { - return Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME; - } - - public Axis2TokenAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - } - - - public Axis2TokenAuthenticationPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - Axis2TokenAuthenticationPolicy policy = new Axis2TokenAuthenticationPolicy(); - int event = reader.getEventType(); - QName name = null; - - while (reader.hasNext()) { - event = reader.getEventType(); - switch (event) { - case START_ELEMENT : { - name = reader.getName(); - if ( name.equals(getArtifactType()) ) { - policy.setTokenName(getQName(reader, Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME)); - } - break; - } - } - - if ( event == END_ELEMENT ) { - if ( getArtifactType().equals(reader.getName()) ) { - break; - } - } - - //Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return policy; - } - - public void write(Axis2TokenAuthenticationPolicy policy, XMLStreamWriter writer) - throws ContributionWriteException, XMLStreamException { - String prefix = "tuscany"; - writer.writeStartElement(prefix, - getArtifactType().getLocalPart(), - getArtifactType().getNamespaceURI()); - writer.writeNamespace("tuscany", SCA11_TUSCANY_NS); - - if ( policy.getTokenName() != null ) { - writer.writeStartElement(prefix, - Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME, - getArtifactType().getNamespaceURI()); - writer.writeCharacters(policy.getTokenName().toString()); - writer.writeEndElement(); - } - - writer.writeEndElement(); - } - - public Class getModelType() { - return Axis2TokenAuthenticationPolicy.class; - } - - public void resolve(Axis2TokenAuthenticationPolicy arg0, ModelResolver arg1) throws ContributionResolveException { - - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * + * Adjusted for 2.0 environment, Mike Edwards, 4th Dec 2008 + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; + + public QName getArtifactType() { + return Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME; + } + + public Axis2TokenAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public Axis2TokenAuthenticationPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + Axis2TokenAuthenticationPolicy policy = new Axis2TokenAuthenticationPolicy(); + int event = reader.getEventType(); + QName name = null; + + while (reader.hasNext()) { + event = reader.getEventType(); + switch (event) { + case START_ELEMENT : { + name = reader.getName(); + if ( name.equals(getArtifactType()) ) { + policy.setTokenName(getQName(reader, Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME)); + } + break; + } + } + + if ( event == END_ELEMENT ) { + if ( getArtifactType().equals(reader.getName()) ) { + break; + } + } + + //Read the next element + if (reader.hasNext()) { + reader.next(); + } + } + + return policy; + } + + public void write(Axis2TokenAuthenticationPolicy policy, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", SCA11_TUSCANY_NS); + + if ( policy.getTokenName() != null ) { + writer.writeStartElement(prefix, + Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME, + getArtifactType().getNamespaceURI()); + writer.writeCharacters(policy.getTokenName().toString()); + writer.writeEndElement(); + } + + writer.writeEndElement(); + } + + public Class getModelType() { + return Axis2TokenAuthenticationPolicy.class; + } + + public void resolve(Axis2TokenAuthenticationPolicy arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java index af9689bc2a..5cf095a67f 100644 --- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java +++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java @@ -1,59 +1,59 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.PolicyProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $ - */ -public class Axis2TokenAuthenticationPolicyProviderFactory implements PolicyProviderFactory { - private ExtensionPointRegistry registry; - - public Axis2TokenAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { - return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation); - } - - public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { - return new Axis2TokenAuthenticationReferencePolicyProvider(endpointReference); - } - - public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { - return new Axis2TokenAuthenticationServicePolicyProvider(endpoint); - } - - /** - * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() - */ - public Class getModelType() { - return Axis2TokenAuthenticationPolicy.class; - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationPolicyProviderFactory implements PolicyProviderFactory { + private ExtensionPointRegistry registry; + + public Axis2TokenAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { + return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation); + } + + public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { + return new Axis2TokenAuthenticationReferencePolicyProvider(endpointReference); + } + + public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { + return new Axis2TokenAuthenticationServicePolicyProvider(endpoint); + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class getModelType() { + return Axis2TokenAuthenticationPolicy.class; + } + +} diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java index d9e4373c2f..00f93fed26 100644 --- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java +++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java @@ -1,90 +1,90 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; - -import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Policy handler to handle PolicySet related to Logging with the QName - * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy - * - * @version $Rev: 698457 $ $Date: 2008-09-24 09:13:02 +0100 (Wed, 24 Sep 2008) $ - */ -public class Axis2TokenAuthenticationReferencePolicyInterceptor implements PhasedInterceptor { - - private Invoker next; - private Operation operation; - private PolicySet policySet = null; - private String context; - private Axis2TokenAuthenticationPolicy policy; - - public Axis2TokenAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) { - super(); - this.operation = operation; - this.policySet = policySet; - this.context = context; - init(); - } - - private void init() { - if (policySet != null) { - for (Object policyObject : policySet.getPolicies()){ - if (policyObject instanceof Axis2TokenAuthenticationPolicy){ - policy = (Axis2TokenAuthenticationPolicy)policyObject; - break; - } - } - } - } - - public Message invoke(Message msg) { - // could call out here to some 3rd party system to get credentials - - if ( policy.getTokenName() != null){ - // create Axis representation of header - Axis2SOAPHeaderString header = new Axis2SOAPHeaderString(); - header.setHeaderName(policy.getTokenName()); - header.setHeaderString("SomeWSAuthorizationToken"); - - // add header to Tuscany message - msg.getHeaders().add(header); - } - - return getNext().invoke(msg); - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public String getPhase() { - return Phase.REFERENCE_POLICY; - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; + +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationReferencePolicyInterceptor implements PhasedInterceptor { + + private Invoker next; + private Operation operation; + private PolicySet policySet = null; + private String context; + private Axis2TokenAuthenticationPolicy policy; + + public Axis2TokenAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) { + super(); + this.operation = operation; + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + if (policySet != null) { + for (Object policyObject : policySet.getPolicies()){ + if (policyObject instanceof Axis2TokenAuthenticationPolicy){ + policy = (Axis2TokenAuthenticationPolicy)policyObject; + break; + } + } + } + } + + public Message invoke(Message msg) { + // could call out here to some 3rd party system to get credentials + + if ( policy.getTokenName() != null){ + // create Axis representation of header + Axis2SOAPHeaderString header = new Axis2SOAPHeaderString(); + header.setHeaderName(policy.getTokenName()); + header.setHeaderString("SomeWSAuthorizationToken"); + + // add header to Tuscany message + msg.getHeaders().add(header); + } + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } + + public String getPhase() { + return Phase.REFERENCE_POLICY; + } + +} diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java index 94fcb236f8..cb2f004070 100644 --- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java +++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java @@ -1,71 +1,71 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.provider.PolicyProvider; - -/** - * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $ - */ -public class Axis2TokenAuthenticationReferencePolicyProvider implements PolicyProvider { - private EndpointReference endpointReference; - - public Axis2TokenAuthenticationReferencePolicyProvider(EndpointReference endpointReference) { - super(); - this.endpointReference = endpointReference; - } - - private PolicySet findPolicySet() { - List policySets = endpointReference.getPolicySets(); - for (PolicySet ps : policySets) { - for (Object p : ps.getPolicies()) { - if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { - return ps; - } - } - } - return null; - } - - private String getContext() { - return endpointReference.getURI(); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public PhasedInterceptor createInterceptor(Operation operation) { - PolicySet ps = findPolicySet(); - return ps == null ? null : new Axis2TokenAuthenticationReferencePolicyInterceptor(getContext(), operation, ps); - } - - public void start() { - } - - public void stop() { - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.provider.PolicyProvider; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationReferencePolicyProvider implements PolicyProvider { + private EndpointReference endpointReference; + + public Axis2TokenAuthenticationReferencePolicyProvider(EndpointReference endpointReference) { + super(); + this.endpointReference = endpointReference; + } + + private PolicySet findPolicySet() { + List policySets = endpointReference.getPolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + return ps; + } + } + } + return null; + } + + private String getContext() { + return endpointReference.getURI(); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) + */ + public PhasedInterceptor createInterceptor(Operation operation) { + PolicySet ps = findPolicySet(); + return ps == null ? null : new Axis2TokenAuthenticationReferencePolicyInterceptor(getContext(), operation, ps); + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java index 33f7d97869..a863ef9f73 100644 --- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java +++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java @@ -1,98 +1,98 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; - - -import java.security.Principal; - -import javax.security.auth.Subject; - -import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil; -import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal; -import org.apache.tuscany.sca.policy.security.SecurityUtil; - -/** - * Policy handler to handle PolicySet related to Logging with the QName - * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy - * - * @version $Rev: 721811 $ $Date: 2008-11-30 13:46:51 +0000 (Sun, 30 Nov 2008) $ - */ -public class Axis2TokenAuthenticationServicePolicyInterceptor implements PhasedInterceptor { - private Invoker next; - private Operation operation; - private PolicySet policySet = null; - private String context; - private Axis2TokenAuthenticationPolicy policy; - - public Axis2TokenAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) { - super(); - this.operation = operation; - this.policySet = policySet; - this.context = context; - init(); - } - - private void init() { - if (policySet != null) { - for (Object policyObject : policySet.getPolicies()){ - if (policyObject instanceof Axis2TokenAuthenticationPolicy){ - policy = (Axis2TokenAuthenticationPolicy)policyObject; - break; - } - } - } - } - - public Message invoke(Message msg) { - - Axis2SOAPHeaderString header = (Axis2SOAPHeaderString)Axis2HeaderPolicyUtil.getHeader(msg, policy.getTokenName()); - - if (header != null) { - System.out.println("Web service received token: " + header.getHeaderString()); - - // call out here to some 3rd party system to do whatever you - // need to turn header credentials into an authenticated principal - - Subject subject = SecurityUtil.getSubject(msg); - Principal principal = new TokenPrincipal(header.getHeaderString()); - subject.getPrincipals().add(principal); - } - - return getNext().invoke(msg); - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public String getPhase() { - return Phase.SERVICE_POLICY; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; + + +import java.security.Principal; + +import javax.security.auth.Subject; + +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil; +import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal; +import org.apache.tuscany.sca.policy.security.SecurityUtil; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationServicePolicyInterceptor implements PhasedInterceptor { + private Invoker next; + private Operation operation; + private PolicySet policySet = null; + private String context; + private Axis2TokenAuthenticationPolicy policy; + + public Axis2TokenAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) { + super(); + this.operation = operation; + this.policySet = policySet; + this.context = context; + init(); + } + + private void init() { + if (policySet != null) { + for (Object policyObject : policySet.getPolicies()){ + if (policyObject instanceof Axis2TokenAuthenticationPolicy){ + policy = (Axis2TokenAuthenticationPolicy)policyObject; + break; + } + } + } + } + + public Message invoke(Message msg) { + + Axis2SOAPHeaderString header = (Axis2SOAPHeaderString)Axis2HeaderPolicyUtil.getHeader(msg, policy.getTokenName()); + + if (header != null) { + System.out.println("Web service received token: " + header.getHeaderString()); + + // call out here to some 3rd party system to do whatever you + // need to turn header credentials into an authenticated principal + + Subject subject = SecurityUtil.getSubject(msg); + Principal principal = new TokenPrincipal(header.getHeaderString()); + subject.getPrincipals().add(principal); + } + + return getNext().invoke(msg); + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } + + public String getPhase() { + return Phase.SERVICE_POLICY; + } +} diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java index e229a7d328..9bfa1b8804 100644 --- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java +++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java @@ -1,70 +1,70 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.provider.PolicyProvider; - -/** - * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $ - */ -public class Axis2TokenAuthenticationServicePolicyProvider implements PolicyProvider { - private Endpoint endpoint; - - public Axis2TokenAuthenticationServicePolicyProvider(Endpoint endpoint) { - super(); - this.endpoint = endpoint; - } - - private PolicySet findPolicySet() { - List policySets = endpoint.getPolicySets(); - for (PolicySet ps : policySets) { - for (Object p : ps.getPolicies()) { - if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { - return ps; - } - } - } - return null; - } - - private String getContext() { - return endpoint.getURI(); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public PhasedInterceptor createInterceptor(Operation operation) { - PolicySet ps = findPolicySet(); - return ps == null ? null : new Axis2TokenAuthenticationServicePolicyInterceptor(getContext(), operation, ps); - } - - public void start() { - } - - public void stop() { - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.PhasedInterceptor; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.provider.PolicyProvider; + +/** + * @version $Rev$ $Date$ + */ +public class Axis2TokenAuthenticationServicePolicyProvider implements PolicyProvider { + private Endpoint endpoint; + + public Axis2TokenAuthenticationServicePolicyProvider(Endpoint endpoint) { + super(); + this.endpoint = endpoint; + } + + private PolicySet findPolicySet() { + List policySets = endpoint.getPolicySets(); + for (PolicySet ps : policySets) { + for (Object p : ps.getPolicies()) { + if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) { + return ps; + } + } + } + return null; + } + + private String getContext() { + return endpoint.getURI(); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) + */ + public PhasedInterceptor createInterceptor(Operation operation) { + PolicySet ps = findPolicySet(); + return ps == null ? null : new Axis2TokenAuthenticationServicePolicyInterceptor(getContext(), operation, ps); + } + + public void start() { + } + + public void stop() { + } +} -- cgit v1.2.3