diff options
Diffstat (limited to 'sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy')
12 files changed, 0 insertions, 896 deletions
diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java deleted file mode 100644 index 699846ead2..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.basic; - -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.policy.authentication.basic.BasicAuthenticationPolicy; -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 BasicAuthenticationPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> { - private ExtensionPointRegistry registry; - - public BasicAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { - return null; - } - - public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { - return new BasicAuthenticationReferencePolicyProvider(endpointReference); - } - - public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { - return new BasicAuthenticationServicePolicyProvider(endpoint); - } - - public Class<BasicAuthenticationPolicy> getModelType() { - return BasicAuthenticationPolicy.class; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java deleted file mode 100644 index 04b46485d8..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.basic; - -import java.util.ArrayList; -import java.util.List; - -import javax.security.auth.Subject; -import javax.xml.namespace.QName; - -import org.apache.axis2.client.OperationClient; -import org.apache.axis2.transport.http.HTTPConstants; -import org.apache.axis2.transport.http.HttpTransportProperties; -import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator; -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.PolicyExpression; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; -import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal; -import org.apache.tuscany.sca.policy.security.SecurityUtil; -import org.oasisopen.sca.ServiceRuntimeException; - -/** - * - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationReferencePolicyInterceptor implements PhasedInterceptor { - private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication"); - - private Invoker next; - private PolicySet policySet = null; - private String context; - private BasicAuthenticationPolicy policy; - - public BasicAuthenticationReferencePolicyInterceptor(String context, PolicySet policySet) { - super(); - this.policySet = policySet; - this.context = context; - init(); - } - - private void init() { - // TODO - how to get the appropriate expression out of the - // policy set. Need WS Policy help here - if (policySet != null) { - for (PolicyExpression policyExpression : policySet.getPolicies()){ - if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){ - policy = (BasicAuthenticationPolicy)policyExpression.getPolicy(); - break; - } - } - } - } - - public Message invoke(Message msg) { - - OperationClient operationClient = msg.getBindingContext(); - - String username = null; - String password = null; - - // get the security context - Subject subject = SecurityUtil.getSubject(msg); - BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject, - BasicAuthenticationPrincipal.class); - - // could use the security principal to look up basic auth credentials - if ( principal != null ) { - username = ((BasicAuthenticationPrincipal)principal).getName(); - password = ((BasicAuthenticationPrincipal)principal).getPassword(); - } else if (policy != null ){ - username = policy.getUserName(); - password = policy.getPassword(); - - principal = new BasicAuthenticationPrincipal(username, - password); - subject.getPrincipals().add(principal); - } - - if (username == null || password == null ){ - throw new ServiceRuntimeException("Basic authentication username and/or password is null"); - } - - HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator(); - List<String> auth = new ArrayList<String>(); - auth.add(Authenticator.BASIC); - authenticator.setAuthSchemes(auth); - authenticator.setPreemptiveAuthentication(true); - authenticator.setUsername(username); - authenticator.setPassword(password); - - operationClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE, - authenticator); - - return getNext().invoke(msg); - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public String getPhase() { - return Phase.REFERENCE_BINDING_POLICY; - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java deleted file mode 100644 index d4b3851d97..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.basic; - -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; -import org.apache.tuscany.sca.provider.BasePolicyProvider; - -/** - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationReferencePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> { - - public BasicAuthenticationReferencePolicyProvider(EndpointReference endpointReference) { - super(BasicAuthenticationPolicy.class, endpointReference); - } - - public PhasedInterceptor createBindingInterceptor() { - PolicySet ps = findPolicySet(); - return ps == null ? null : new BasicAuthenticationReferencePolicyInterceptor(getContext(), ps); - } - - public void start() { - } - - public void stop() { - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java deleted file mode 100644 index 5365754fb3..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.basic; - - -import java.util.Map; - -import javax.security.auth.Subject; -import javax.xml.namespace.QName; - -import org.apache.axiom.util.base64.Base64Utils; -import org.apache.axis2.context.MessageContext; -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.PolicyExpression; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; -import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal; -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 BasicAuthenticationServicePolicyInterceptor implements PhasedInterceptor { - private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication"); - - private Invoker next; - private PolicySet policySet = null; - private String context; - private BasicAuthenticationPolicy policy; - - public BasicAuthenticationServicePolicyInterceptor(String context, PolicySet policySet) { - super(); - this.policySet = policySet; - this.context = context; - init(); - } - - private void init() { - // TODO - how to get the appropriate expression out of the - // policy set. Need WS Policy help here - if (policySet != null) { - for (PolicyExpression policyExpression : policySet.getPolicies()){ - if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){ - policy = (BasicAuthenticationPolicy)policyExpression.getPolicy(); - break; - } - } - } - } - - public Message invoke(Message msg) { - - MessageContext messageContext = msg.getBindingContext(); - Map httpHeaderProperties = (Map)messageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); - - String basicAuthString = (String)httpHeaderProperties.get("Authorization"); - String decodedBasicAuthString = null; - String username = null; - String password = null; - - if (basicAuthString != null) { - basicAuthString = basicAuthString.trim(); - - if (basicAuthString.startsWith("Basic ")) { - decodedBasicAuthString = new String(Base64Utils.decode(basicAuthString.substring(6))); - } - - int collonIndex = decodedBasicAuthString.indexOf(':'); - - if (collonIndex == -1){ - username = decodedBasicAuthString; - } else { - username = decodedBasicAuthString.substring(0, collonIndex); - password = decodedBasicAuthString.substring(collonIndex + 1); - } - } - - // get the security context - Subject subject = SecurityUtil.getSubject(msg); - BasicAuthenticationPrincipal principal = new BasicAuthenticationPrincipal(username, - password); - 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_BINDING_POLICY; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java deleted file mode 100644 index ec4536c309..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.basic; - - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy; -import org.apache.tuscany.sca.provider.BasePolicyProvider; - -/** - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationServicePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> { - - public BasicAuthenticationServicePolicyProvider(Endpoint endpoint) { - super(BasicAuthenticationPolicy.class, endpoint); - } - - public PhasedInterceptor createBindingInterceptor() { - PolicySet ps = findPolicySet(); - return ps == null ? null : new BasicAuthenticationServicePolicyInterceptor(getContext(), ps); - } - - public void start() { - } - - public void stop() { - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java deleted file mode 100644 index ded09392ec..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.configuration; - -import java.util.Hashtable; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMElement; - -/** - * Implementation for policies that could be injected as parameter - * into the axis2config. - * - * @version $Rev$ $Date$ - */ -public class Axis2ConfigParamPolicy { - private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - public static final QName NAME = new QName(SCA11_TUSCANY_NS, "wsConfigParam"); - private Map<String, OMElement> paramElements = new Hashtable<String, OMElement>(); - - public Map<String, OMElement> getParamElements() { - return paramElements; - } - - public QName getSchemaName() { - return NAME; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java deleted file mode 100644 index c13c009edf..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.configuration; - -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.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -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.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; - -/** - * - * @version $Rev$ $Date$ - */ -public class Axis2ConfigParamPolicyProcessor implements StAXArtifactProcessor<Axis2ConfigParamPolicy> { - public static final QName AXIS2_CONFIG_PARAM_POLICY_QNAME = Axis2ConfigParamPolicy.NAME; - public static final String PARAMETER = "parameter"; - public QName getArtifactType() { - return AXIS2_CONFIG_PARAM_POLICY_QNAME; - } - - public Axis2ConfigParamPolicyProcessor(FactoryExtensionPoint modelFactories) { - } - - public Axis2ConfigParamPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { - Axis2ConfigParamPolicy policy = new Axis2ConfigParamPolicy(); - int event = reader.getEventType(); - QName name = null; - OMElement parameterElement = null; - String paramName = null; - while (reader.hasNext()) { - event = reader.getEventType(); - switch (event) { - case START_ELEMENT : { - name = reader.getName(); - if ( PARAMETER.equals(name.getLocalPart()) ) { - paramName = reader.getAttributeValue(null, "name"); - parameterElement = loadElement(reader); - policy.getParamElements().put(paramName, parameterElement); - } - break; - } - } - - if ( event == END_ELEMENT ) { - if ( AXIS2_CONFIG_PARAM_POLICY_QNAME.equals(reader.getName()) ) { - break; - } - } - - //Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return policy; - } - - public void write(Axis2ConfigParamPolicy arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - } - - public Class<Axis2ConfigParamPolicy> getModelType() { - return Axis2ConfigParamPolicy.class; - } - - public void resolve(Axis2ConfigParamPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { - - } - - private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException { - OMFactory fac = OMAbstractFactory.getOMFactory(); - OMElement head = fac.createOMElement(reader.getName()); - OMElement current = head; - while (true) { - switch (reader.next()) { - case XMLStreamConstants.START_ELEMENT: - //since the axis2 code checks against a no namespace we need to generate accordingly - QName name = new QName(reader.getName().getLocalPart()); - OMElement child = fac.createOMElement(name, current); - - int count = reader.getNamespaceCount(); - for (int i = 0; i < count; i++) { - String prefix = reader.getNamespacePrefix(i); - String ns = reader.getNamespaceURI(i); - child.declareNamespace(ns, prefix); - } - - if(!"".equals(name.getNamespaceURI())) { - child.declareNamespace(name.getNamespaceURI(), name.getPrefix()); - } - - // add the attributes for this element - count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - String ns = reader.getAttributeNamespace(i); - String prefix = reader.getAttributePrefix(i); - String qname = reader.getAttributeLocalName(i); - String value = reader.getAttributeValue(i); - - if (ns != null) { - child.addAttribute(qname, value, fac.createOMNamespace(ns, prefix)); - child.declareNamespace(ns, prefix); - } else { - child.addAttribute(qname, value, null); - } - } - current = child; - break; - case XMLStreamConstants.CDATA: - fac.createOMText(current, reader.getText()); - break; - case XMLStreamConstants.CHARACTERS: - fac.createOMText(current, reader.getText()); - break; - case XMLStreamConstants.END_ELEMENT: - if ( current == head ) { - return head; - } else { - current = (OMElement)current.getParent(); - } - } - } - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java deleted file mode 100644 index a77f71b734..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.configuration; - -import org.apache.axis2.AxisFault; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.description.Parameter; -import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.apache.tuscany.sca.provider.BasePolicyProvider; -import org.oasisopen.sca.ServiceRuntimeException; - -/** - * @version $Rev$ $Date$ - */ -public class Axis2ConfigParamPolicyProvider extends BasePolicyProvider<Axis2ConfigParamPolicy> { - - public Axis2ConfigParamPolicyProvider(PolicySubject subject) { - super(Axis2ConfigParamPolicy.class, subject); - } - - public void configureBinding(Object context) { - ConfigurationContext configurationContext = ((Axis2BaseBindingProvider)context).getAxisConfigurationContext(); - Axis2ConfigParamPolicy axis2ConfigParamPolicy = null; - Parameter configParam = null; - for (Object policy : findPolicies()) { - if (policy instanceof Axis2ConfigParamPolicy) { - axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy; - for (String paramName : axis2ConfigParamPolicy.getParamElements().keySet()) { - configParam = - new Parameter(paramName, axis2ConfigParamPolicy.getParamElements().get(paramName) - .getFirstElement()); - configParam.setParameterElement(axis2ConfigParamPolicy.getParamElements().get(paramName)); - try { - configurationContext.getAxisConfiguration().addParameter(configParam); - } catch (AxisFault e) { - throw new ServiceRuntimeException(e); - } - } - } - } - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java deleted file mode 100644 index c4c93cd33d..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.configuration; - - -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 Axis2ConfigParamPolicyProviderFactory implements PolicyProviderFactory<Axis2ConfigParamPolicy> { - - public Axis2ConfigParamPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - } - - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { - return null; - } - - public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { - return new Axis2ConfigParamPolicyProvider(endpointReference); - } - - public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { - return new Axis2ConfigParamPolicyProvider(endpoint); - } - - public Class<Axis2ConfigParamPolicy> getModelType() { - return Axis2ConfigParamPolicy.class; - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java deleted file mode 100644 index e27da2bbd1..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.mtom; - -import org.apache.axis2.Constants.Configuration; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.apache.tuscany.sca.provider.BasePolicyProvider; - -/** - * @version $Rev$ $Date$ - */ -public class Axis2MTOMPolicyProvider extends BasePolicyProvider<Object> { - - public Axis2MTOMPolicyProvider(PolicySubject subject) { - super(Object.class, subject); - } - - public void configureBinding(Object configuration) { - - if (configuration instanceof ConfigurationContext){ - ConfigurationContext configurationContext = (ConfigurationContext)configuration; - configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setLocked(false); - configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setValue("true"); - } - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java deleted file mode 100644 index 8355c0fa4e..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.security.http.ssl; - -import java.util.logging.Logger; - -import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider; -import org.apache.tuscany.sca.host.http.SecurityContext; -import org.apache.tuscany.sca.policy.PolicySubject; -import org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy; -import org.apache.tuscany.sca.provider.BasePolicyProvider; - -/** - * @version $Rev$ $Date$ - */ -public class HTTPSPolicyProvider extends BasePolicyProvider<HTTPSPolicy> { - private final Logger logger = Logger.getLogger(HTTPSPolicyProvider.class.getName()); - - public HTTPSPolicyProvider(PolicySubject subject) { - super(HTTPSPolicy.class, subject); - } - - public void configureBinding(Object context) { - SecurityContext securityContext = ((Axis2BaseBindingProvider)context).getHttpSecurityContext(); - - for (Object policy : findPolicies()) { - if (policy instanceof HTTPSPolicy) { - HTTPSPolicy httpsPolicy = (HTTPSPolicy)policy; - - securityContext.setSSLEnabled(true); - securityContext.setSSLProperties(httpsPolicy.toProperties()); - - // TODO - what is the right way to set trust/key store on client side? - - logger.info("HTTPSPolicyProvider: Setting JVM trust store to " + httpsPolicy.getTrustStore()); - System.setProperty("javax.net.ssl.trustStore", httpsPolicy.getTrustStore()); - System.setProperty("javax.net.ssl.trustStorePassword", httpsPolicy.getTrustStorePassword()); - System.setProperty("javax.net.ssl.trustStoreType", httpsPolicy.getTrustStoreType()); - - logger.info("HTTPSPolicyProvider: Setting JVM key store to " + httpsPolicy.getKeyStore()); - System.setProperty("javax.net.ssl.keyStore", httpsPolicy.getKeyStore()); - System.setProperty("javax.net.ssl.keyStorePassword", httpsPolicy.getKeyStorePassword()); - System.setProperty("javax.net.ssl.keyStoreType", httpsPolicy.getKeyStoreType()); - - return; - } - } - } -} diff --git a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java b/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java deleted file mode 100644 index 592300aaa3..0000000000 --- a/sca-java-2.x/tags/2.0-Beta2-RC3/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.security.http.ssl; - -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.policy.authentication.basic.BasicAuthenticationPolicy; -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 HTTPSPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> { - private ExtensionPointRegistry registry; - - public HTTPSPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { - return null; - } - - public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { - return new HTTPSPolicyProvider(endpointReference); - } - - public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { - return new HTTPSPolicyProvider(endpoint); - } - - public Class<BasicAuthenticationPolicy> getModelType() { - return BasicAuthenticationPolicy.class; - } - -} |