summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/builder
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-09-28 19:11:13 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-09-28 19:11:13 +0000
commit133d3e4ddc679410ecd8d154ec43f5ff40654d58 (patch)
tree988fb0e50d216dd51f5e2bd4985a1f0670e8ce6e /java/sca/modules/builder
parentf4f96f8c8ec04e4c1709d3037e57589145be12fa (diff)
Rename policy-builder to builder as the module to host Tuscany model builders
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@819676 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/builder')
-rw-r--r--java/sca/modules/builder/META-INF/MANIFEST.MF27
-rw-r--r--java/sca/modules/builder/pom.xml70
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentBuilderImpl.java233
-rw-r--r--java/sca/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder17
-rw-r--r--java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/MockPolicy.java39
-rw-r--r--java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentTestCase.java149
-rw-r--r--java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/TestPolicyProcessor.java57
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Calculator.composite49
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite1.composite34
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite2.composite33
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite3.composite29
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite4.composite32
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/definitions.xml38
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.odgbin0 -> 15518 bytes
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.pngbin0 -> 4041817 bytes
-rw-r--r--java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/test_definitions.xml207
16 files changed, 1014 insertions, 0 deletions
diff --git a/java/sca/modules/builder/META-INF/MANIFEST.MF b/java/sca/modules/builder/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..77a8ebf812
--- /dev/null
+++ b/java/sca/modules/builder/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Model Builders
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397097203
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Assembly Model
+Import-Package: javax.xml.namespace,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.dom;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.xpath;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.w3c.dom
+Bundle-SymbolicName: org.apache.tuscany.sca.builder
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/java/sca/modules/builder/pom.xml b/java/sca/modules/builder/pom.xml
new file mode 100644
index 0000000000..520e89f35d
--- /dev/null
+++ b/java/sca/modules/builder/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-builder</artifactId>
+ <name>Apache Tuscany SCA Model Builders</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-definitions-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+
+ </dependencies>
+
+</project>
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentBuilderImpl.java
new file mode 100644
index 0000000000..98d93d8186
--- /dev/null
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentBuilderImpl.java
@@ -0,0 +1,233 @@
+/*
+ * 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.policy.builder.impl;
+
+import static javax.xml.XMLConstants.DEFAULT_NS_PREFIX;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+
+import java.io.StringWriter;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A builder that attaches policy sets to the domain composite using the xpath defined by
+ * the attachTo attribute. It first creates a DOM model for the composite so that the xpath
+ * expression can be evaluated. For the nodes selected by the xpath, add the policySets attribute
+ * to the subject element. Then reload the patched DOM into a Composite model again.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyAttachmentBuilderImpl implements CompositeBuilder {
+ private StAXHelper staxHelper;
+ private DOMHelper domHelper;
+ private StAXArtifactProcessor<Composite> processor;
+
+ public PolicyAttachmentBuilderImpl(ExtensionPointRegistry registry) {
+ domHelper = DOMHelper.getInstance(registry);
+ staxHelper = StAXHelper.getInstance(registry);
+ StAXArtifactProcessorExtensionPoint processors =
+ registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ processor = processors.getProcessor(Composite.class);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.policy.builder.PolicyAttachmentBuilder";
+ }
+
+ public Composite build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+ try {
+ Composite patched = applyXPath(composite, definitions, monitor);
+ return patched;
+ } catch (Exception e) {
+ throw new CompositeBuilderException(e);
+ }
+ }
+
+ /**
+ * Apply the attachTo XPath against the composite model
+ * @param composite The orginal composite
+ * @param definitions SCA definitions that contain the policy sets
+ * @param monitor The monitor
+ * @return A reloaded composite
+ * @throws Exception
+ */
+ private Composite applyXPath(Composite composite, Definitions definitions, Monitor monitor) throws Exception {
+ // Recursively apply the xpath against the composites referenced by <implementation.composite>
+ for (Component component : composite.getComponents()) {
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ Composite patched = applyXPath((Composite)impl, definitions, monitor);
+ if (patched != impl) {
+ component.setImplementation(patched);
+ }
+ }
+ }
+ // First write the composite into a DOM document so that we can apply the xpath
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer = staxHelper.createXMLStreamWriter(sw);
+ // Write the composite into a DOM document
+ processor.write(composite, writer);
+ writer.close();
+
+ Document document = domHelper.load(sw.toString());
+
+ boolean changed = false;
+ for (PolicySet ps : definitions.getPolicySets()) {
+ // First calculate the applicable nodes
+ Set<Node> applicableNodes = null;
+ /*
+ XPathExpression appliesTo = ps.getAppliesToXPathExpression();
+ if (appliesTo != null) {
+ applicableNodes = new HashSet<Node>();
+ NodeList nodes = (NodeList)appliesTo.evaluate(document, XPathConstants.NODESET);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ applicableNodes.add(nodes.item(i));
+ }
+ }
+ */
+ XPathExpression exp = ps.getAttachToXPathExpression();
+ if (exp != null) {
+ NodeList nodes = (NodeList)exp.evaluate(document, XPathConstants.NODESET);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ if (applicableNodes == null || applicableNodes.contains(node)) {
+ // The node can be a component, service, reference or binding
+ if (attach(node, ps) && !changed) {
+ changed = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (changed) {
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(document);
+ reader.nextTag();
+ Composite patchedComposite = (Composite)processor.read(reader);
+ return patchedComposite;
+ } else {
+ return composite;
+ }
+ }
+
+ /**
+ * Attach the policySet to the given DOM node
+ * @param node The DOM node (should be an element)
+ * @param policySet The policy set to be attached
+ * @return true if the element is changed, false if the element already contains the same policy set
+ * and no change is made
+ */
+ private boolean attach(Node node, PolicySet policySet) {
+ Element element = (Element)node;
+ Document document = element.getOwnerDocument();
+
+ QName qname = policySet.getName();
+ String prefix = DOMHelper.getPrefix(element, qname.getNamespaceURI());
+ if (prefix == null) {
+ // Find the a non-conflicting prefix
+ int i = 0;
+ while (true) {
+ prefix = "ns" + i;
+ String ns = DOMHelper.getNamespaceURI(element, prefix);
+ if (ns == null) {
+ break;
+ }
+ }
+ // Declare the namespace
+ Attr nsAttr = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, XMLNS_ATTRIBUTE + ":" + prefix);
+ nsAttr.setValue(qname.getNamespaceURI());
+ element.setAttributeNodeNS(nsAttr);
+ }
+ // Form the value as a qualified name
+ String qvalue = null;
+ if (DEFAULT_NS_PREFIX.equals(prefix)) {
+ qvalue = qname.getLocalPart();
+ } else {
+ qvalue = prefix + ":" + qname.getLocalPart();
+ }
+
+ // Check if the attribute exists
+ Attr attr = element.getAttributeNode("policySets");
+ if (attr == null) {
+ // Create the policySets attr
+ attr = document.createAttributeNS(null, "policySets");
+ attr.setValue(qvalue);
+ element.setAttributeNodeNS(attr);
+ return true;
+ } else {
+ // Append to the existing value
+ boolean duplicate = false;
+ String value = attr.getValue();
+ StringTokenizer tokenizer = new StringTokenizer(value);
+ while (tokenizer.hasMoreTokens()) {
+ String ps = tokenizer.nextToken();
+ int index = ps.indexOf(':');
+ String ns = null;
+ String localName = null;
+ if (index == -1) {
+ ns = DOMHelper.getNamespaceURI(element, DEFAULT_NS_PREFIX);
+ localName = ps;
+ } else {
+ ns = DOMHelper.getNamespaceURI(element, ps.substring(0, index));
+ localName = ps.substring(index + 1);
+ }
+ QName psName = new QName(ns, localName);
+ if (qname.equals(psName)) {
+ duplicate = true;
+ break;
+ }
+ }
+ if (!duplicate) {
+ // REVIEW: [rfeng] How to comply to POL40012?
+ value = value + " " + qvalue;
+ attr.setValue(value.trim());
+ return true;
+ }
+ return false;
+ }
+ }
+
+}
diff --git a/java/sca/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder b/java/sca/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder
new file mode 100644
index 0000000000..5de5512c82
--- /dev/null
+++ b/java/sca/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder
@@ -0,0 +1,17 @@
+# 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.
+org.apache.tuscany.sca.builder.impl.ModelBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeBuilder
diff --git a/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/MockPolicy.java b/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/MockPolicy.java
new file mode 100644
index 0000000000..c3c293cdf8
--- /dev/null
+++ b/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/MockPolicy.java
@@ -0,0 +1,39 @@
+/*
+ * 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.policy.builder.impl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Mocked Policy
+ */
+public class MockPolicy {
+ public QName getName() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+}
diff --git a/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentTestCase.java b/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentTestCase.java
new file mode 100644
index 0000000000..2987dd7b5e
--- /dev/null
+++ b/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/PolicyAttachmentTestCase.java
@@ -0,0 +1,149 @@
+/*
+ * 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.policy.builder.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.builder.impl.CompositeCloneBuilderImpl;
+import org.apache.tuscany.sca.builder.impl.CompositeIncludeBuilderImpl;
+import org.apache.tuscany.sca.builder.impl.StructuralURIBuilderImpl;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test reading SCA XML assembly documents.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyAttachmentTestCase {
+
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+
+ private static ExtensionPointRegistry extensionPoints;
+ private static XMLInputFactory inputFactory;
+ private static AssemblyFactory assemblyFactory;
+ private static BuilderExtensionPoint builders;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ extensionPoints = new DefaultExtensionPointRegistry();
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ inputFactory = factories.getFactory(XMLInputFactory.class);
+ // Create a monitor
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ if (monitorFactory != null) {
+ monitor = monitorFactory.createMonitor();
+ utilities.addUtility(monitorFactory);
+ }
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, monitor);
+ staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
+
+ builders = extensionPoints.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ @Test
+ public void testBuild() throws Exception {
+ Definitions definitions = load("test_definitions.xml");
+ Composite composite = load("Calculator.composite");
+
+ PolicyAttachmentBuilderImpl builder = new PolicyAttachmentBuilderImpl(extensionPoints);
+ builder.build(composite, definitions, monitor);
+ }
+
+ private <T> T load(String file) throws IOException, XMLStreamException, ContributionReadException {
+ URL url = getClass().getResource(file);
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+ reader.nextTag();
+
+ T model = (T)staxProcessor.read(reader);
+ reader.close();
+ return model;
+ }
+
+ @Test
+ public void testComplexBuild() throws Exception {
+ Definitions definitions = load("definitions.xml");
+ Composite composite1 = load("Composite1.composite");
+ Composite composite2 = load("Composite2.composite");
+ Composite composite3 = load("Composite3.composite");
+ Composite composite4 = load("Composite4.composite");
+ composite1.getIncludes().clear();
+ composite1.getIncludes().add(composite3);
+
+ composite1.getComponent("Component1B").setImplementation(composite4);
+ composite2.getComponent("Component2B").setImplementation(composite4);
+
+ Composite domainComposite = assemblyFactory.createComposite();
+ domainComposite.setName(new QName(Base.SCA11_NS, ""));
+ domainComposite.setLocal(false);
+ domainComposite.getIncludes().add(composite1);
+ domainComposite.getIncludes().add(composite2);
+
+ CompositeBuilder includeBuilder = new CompositeIncludeBuilderImpl();
+ CompositeBuilder cloneBuilder = new CompositeCloneBuilderImpl();
+ CompositeBuilder uriBuilder = new StructuralURIBuilderImpl(extensionPoints);
+
+ /*
+ CompositeBuilder includeBuilder =
+ builders.getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeIncludeBuilder");
+ CompositeBuilder cloneBuilder =
+ builders.getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeCloneBuilder");
+ */
+
+ domainComposite = cloneBuilder.build(domainComposite, definitions, monitor);
+ domainComposite = includeBuilder.build(domainComposite, definitions, monitor);
+ domainComposite = uriBuilder.build(domainComposite, definitions, monitor);
+
+ PolicyAttachmentBuilderImpl builder = new PolicyAttachmentBuilderImpl(extensionPoints);
+ domainComposite = builder.build(domainComposite, definitions, monitor);
+
+ }
+
+}
diff --git a/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/TestPolicyProcessor.java b/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/TestPolicyProcessor.java
new file mode 100644
index 0000000000..8a39e70f6b
--- /dev/null
+++ b/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/policy/builder/impl/TestPolicyProcessor.java
@@ -0,0 +1,57 @@
+/*
+ * 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.policy.builder.impl;
+
+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.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;
+
+/**
+ * A PolicyProcessor used for testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<MockPolicy> {
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public MockPolicy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
+ return new MockPolicy();
+ }
+
+ public void write(MockPolicy arg0, XMLStreamWriter arg1) throws ContributionWriteException, XMLStreamException {
+ }
+
+ public Class<MockPolicy> getModelType() {
+ return MockPolicy.class;
+ }
+
+ public void resolve(MockPolicy arg0, ModelResolver arg1) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Calculator.composite b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Calculator.composite
new file mode 100644
index 0000000000..d6082a936d
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Calculator.composite
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent" requires="confidentiality">
+ <implementation.java class="calculator.CalculatorServiceImpl" xmlns:test="http://test" requiers="test:TestIntentOne"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite1.composite b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite1.composite
new file mode 100644
index 0000000000..105a478842
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite1.composite
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite1">
+ <include composite="sample:Composite3"/>
+
+ <component name="Component1A">
+ <implementation.java class="sample.Component1AImpl"/>
+ </component>
+
+ <component name="Component1B">
+ <implementation.composite name="sample:Composite4"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite2.composite b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite2.composite
new file mode 100644
index 0000000000..d3d5bafdfc
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite2.composite
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite2">
+
+ <component name="Component2A">
+ <implementation.java class="sample.Component2AImpl"/>
+ </component>
+
+ <component name="Component2B">
+ <implementation.composite name="sample:Composite4"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite3.composite b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite3.composite
new file mode 100644
index 0000000000..12aa35b694
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite3.composite
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite3">
+
+ <component name="Component3A">
+ <implementation.java class="sample.Component3AImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite4.composite b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite4.composite
new file mode 100644
index 0000000000..141ff2a4ea
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/Composite4.composite
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite4">
+
+ <service name="Service1" promote="Component4A/Service1"/>
+ <reference name="reference1" promote="Component4A/reference1"/>
+
+ <component name="Component4A">
+ <implementation.java class="sample.Component4AImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/definitions.xml b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/definitions.xml
new file mode 100644
index 0000000000..fe76d0038a
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/definitions.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<definitions
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <policySet name="PolicySet1" appliesTo="sca:implementation.java"
+ attachTo = "//composite[@name='']">
+ </policySet>
+
+ <policySet name="PolicySet2" appliesTo="sca:implementation.java"
+ attachTo = "//component[@name='Component3A']">
+ </policySet>
+
+ <policySet name="PolicySet3" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[sca:URIRef('Component2B/Component4A')]">
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.odg b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.odg
new file mode 100644
index 0000000000..a010bb1bf1
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.odg
Binary files differ
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.png b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.png
new file mode 100644
index 0000000000..e1f78f6423
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/scenario.png
Binary files differ
diff --git a/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/test_definitions.xml b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/test_definitions.xml
new file mode 100644
index 0000000000..dac8e384e3
--- /dev/null
+++ b/java/sca/modules/builder/src/test/resources/org/apache/tuscany/sca/policy/builder/impl/test_definitions.xml
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
+ authentication" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
+ alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file