diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-09 19:46:49 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-09 19:46:49 +0000 |
commit | ef661e65d95860ffb3ba09579743f05402ba3014 (patch) | |
tree | 0e72f6b7f2d38ebdd8763c43c018ebe844ab3038 | |
parent | 65622dd13e196361e2ba8774e5dbbcda8ab51f7c (diff) |
TUSCANY-2434 and updates from TUSCANY-2354
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@675323 13f79535-47bb-0310-9956-ffa450edef68
7 files changed, 73 insertions, 32 deletions
diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite index 75b073c03a..2a22a0905d 100644 --- a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite +++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite @@ -27,7 +27,7 @@ so for this composite the service is: http://localhost:8085/myExplicitURI
-->
- <service name="helloWorld" promote="HelloWorldService" policySets="tuscany:wsAuthenticationPolicy">
+ <service name="helloWorld" promote="HelloWorldService" policySets="tuscany:wsSecurityPolicyForAuthentication">
<interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
<binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
</service>
@@ -41,7 +41,7 @@ <reference name="helloWorldWS" />
</component>
- <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsAuthenticationPolicy">
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsSecurityPolicyForAuthentication">
<interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
<binding.ws wsdlElement="http://helloworld-om-uri#wsdl.binding(HelloWorldSoapBinding)"
uri="http://localhost:8085/myExplicitURI"/>
diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml index 8f7135e767..d7f40ccf0e 100644 --- a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml +++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml @@ -24,7 +24,7 @@ <!-- WS Security POLICY SETS -->
<!-- A policyset that uses WS Policy -->
- <sca:policySet name="wsAuthenticationPolicy"
+ <sca:policySet name="wsSecurityPolicyForAuthentication"
provides="sca:authentication"
appliesTo="sca:binding.ws">
<wsp:Policy wsu:Id="UTOverTransport"
diff --git a/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml b/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml index 6750944697..f60047e769 100644 --- a/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml +++ b/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml @@ -102,7 +102,9 @@ </intentMap>
</policySet>
-<policySet name="SecurityPolicy" provides="test:confidentiality"
+<policySet name="SecurityPolicy" + provides="test:confidentiality" + appliesTo="binding.ws"
xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" >
<intentMap provides="test:confidentiality" default="message">
@@ -149,7 +151,7 @@ <policySet name="ConfidentialityPolicies"
provides="test:confidentiality"
- bindings="binding.ws"
+ appliesTo="binding.ws"
xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<intentMap provides="test:confidentiality" default="transport">
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java index 33e88663ee..76ef8df298 100644 --- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java +++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java @@ -84,6 +84,11 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP public T read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { Intent policyIntent = null; String policyIntentName = reader.getAttributeValue(null, NAME); + if (policyIntentName == null) { + error("IntentNameMissing", reader); + return (T)policyIntent; + } + // Read an <sca:intent> if (reader.getAttributeValue(null, REQUIRES) != null) { policyIntent = policyFactory.createProfileIntent(); diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java index e19099a2f3..81ca27a085 100644 --- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java +++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java @@ -109,11 +109,20 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA } public PolicySet read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + PolicySet policySet = null; + String policySetName = reader.getAttributeValue(null, NAME); + String appliesTo = reader.getAttributeValue(null, APPLIES_TO); + if (policySetName == null || appliesTo == null) { + if (policySetName == null) + error("PolicySetNameMissing", reader); + if (appliesTo == null) + error("PolicySetAppliesToMissing", reader); + return policySet; + } - PolicySet policySet = policyFactory.createPolicySet(); + policySet = policyFactory.createPolicySet(); policySet.setName(new QName(policySetName)); - String appliesTo = reader.getAttributeValue(null, APPLIES_TO); String alwaysAppliesTo = reader.getAttributeValue(TUSCANY_NS, ALWAYS_APPLIES_TO); //TODO: with 1.0 version of specs the applies to xpath is given related to the immediate @@ -158,17 +167,27 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA name = reader.getName(); if ( POLICY_INTENT_MAP_QNAME.equals(name) ) { Intent mappedIntent = policyFactory.createIntent(); - mappedIntent.setName(getQName(reader, PROVIDES)); - if ( policySet.getProvidedIntents().contains(mappedIntent) ) { - readIntentMap(reader, policySet, mappedIntent); + String provides = reader.getAttributeValue(null, PROVIDES); + if (provides != null) { + mappedIntent.setName(getQName(reader, PROVIDES)); + if ( policySet.getProvidedIntents().contains(mappedIntent) ) { + readIntentMap(reader, policySet, mappedIntent); + } else { + error("IntentNotSpecified", policySet, policySetName); + //throw new ContributionReadException("Intent Map provides for Intent not specified as provided by parent PolicySet - " + policySetName); + } } else { - error("IntentNotSpecified", policySet, policySetName); - //throw new ContributionReadException("Intent Map provides for Intent not specified as provided by parent PolicySet - " + policySetName); + error("IntentMapProvidesMissing", reader, policySetName); } } else if ( POLICY_SET_REFERENCE_QNAME.equals(name) ) { PolicySet referredPolicySet = policyFactory.createPolicySet(); - referredPolicySet.setName(getQName(reader, NAME)); - policySet.getReferencedPolicySets().add(referredPolicySet); + String referencename = reader.getAttributeValue(null, NAME); + if (referencename != null) { + referredPolicySet.setName(getQName(reader, NAME)); + policySet.getReferencedPolicySets().add(referredPolicySet); + } else { + error("PolicySetReferenceNameMissing", reader, policySetName); + } } /*else if ( WS_POLICY_QNAME.equals(name) ) { OMElement policyElement = loadElement(reader); org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement); @@ -218,12 +237,16 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA case START_ELEMENT : { name = reader.getName(); if ( POLICY_INTENT_MAP_QUALIFIER_QNAME.equals(name)) { - qualifierName = getString(reader, NAME); - qualfiedIntentName = mappedIntent.getName().getLocalPart() + - QUALIFIER + qualifierName; - qualifiedIntent = policyFactory.createIntent(); - qualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(), - qualfiedIntentName)); + qualifierName = getString(reader, NAME); + if (qualifierName != null) { + qualfiedIntentName = mappedIntent.getName().getLocalPart() + + QUALIFIER + qualifierName; + qualifiedIntent = policyFactory.createIntent(); + qualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(), + qualfiedIntentName)); + } else { + error("QualifierNameMissing", reader, policySet.getName()); + } } else if ( POLICY_INTENT_MAP_QNAME.equals(name) ) { QName providedIntent = getQName(reader, PROVIDES); if ( qualifierName.equals(providedIntent.getLocalPart()) ) { @@ -251,7 +274,7 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA policyList.add((Policy)wsPolicy); }*/ else { Object extension = extensionProcessor.read(reader); - if ( extension != null ) { + if ( extension != null && qualifiedIntent != null) { List<Object> policyList = mappedPolicies.get(qualifiedIntent); if ( policyList == null ) { policyList = new ArrayList<Object>(); @@ -345,13 +368,15 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA private void resolvePolicies(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException { boolean unresolved = false; - for ( Object o : policySet.getPolicies() ) { - extensionProcessor.resolve(o, resolver); - /*if ( o instanceof Policy && ((Policy)o).isUnresolved() ) { - unresolved = true; - }*/ + if (policySet != null) { + for ( Object o : policySet.getPolicies() ) { + extensionProcessor.resolve(o, resolver); + /*if ( o instanceof Policy && ((Policy)o).isUnresolved() ) { + unresolved = true; + }*/ + } + policySet.setUnresolved(unresolved); } - policySet.setUnresolved(unresolved); } diff --git a/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties b/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties index 60c73d5354..40107bb11e 100644 --- a/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties +++ b/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties @@ -24,7 +24,7 @@ ProvidedIntentNotFound = Provided Intent - {0} not found for PolicySet {1} UnableToMapPolicies = Unable to map policies for default qualifier in IntentMap for - {0} in policy set - {1} IntentMapDoesNotMatch = Intent provided by IntentMap {0} does not match parent qualifier {1} in policyset - {2} IntentNotSpecified = Intent Map provides for Intent not specified as provided by parent PolicySet - {0} -ContrainsAttributeMissing = Contrains attribute missing from Policy Intent Definition {0} +ContrainsAttributeMissing = Constrains attribute missing from Policy Intent Definition {0} RequiredIntentNotFound = Required Intent - {0} not found for ProfileIntent {1} QualifiableIntentNotFound = Qualifiable Intent - {0} not found for QualifiedIntent {1} ErrorInPolicyIntentDefinition = Error in PolicyIntent Definition - {0} {1} @@ -33,5 +33,12 @@ UnrecognizedIntentAttachPointType = Unrecognized IntentAttachPointType - {0} RequiredAttributeMissing = Required attribute {0} missing from BindingType Definition AlwaysProvidedIntentNotFound = Always Provided Intent - {0} not found for ExtensionType {1} MayProvideIntentNotFound = May Provide Intent - {0} not found for ExtensionType {1} -ContributionReadException = ContributionReadException occured due to: {0} -CyclicReferenceFound = Cyclic reference detected in required attributes of ProfileIntents {0} and {1}
\ No newline at end of file +ContributionReadException = ContributionReadException occurred due to: {0} +CyclicReferenceFound = Cyclic reference detected in required attributes of ProfileIntents {0} and {1} +IntentNameMissing = Required attribute "name" missing for Intent Definition +PolicySetReferenceNameMissing = Required attribute "name" missing for PolicySetReference in PolicySet : {0} +PolicySetNameMissing = Required attribute "name" missing for PolicySet Definition +PolicySetAppliesToMissing = Required attribute "appliesTo" missing for PolicySet Definition +IntentMapProvidesMissing = Required attribute "provides" missing for IntentMap in PolicySet : {0} +QualifierNameMissing = Required attribute "name" missing for qualifier definition in PolicySet : {0} + diff --git a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml index 6750944697..b51a6fba98 100644 --- a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml +++ b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml @@ -102,7 +102,9 @@ </intentMap>
</policySet>
-<policySet name="SecurityPolicy" provides="test:confidentiality"
+<policySet name="SecurityPolicy" + provides="test:confidentiality" + appliesTo="binding.ws"
xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" >
<intentMap provides="test:confidentiality" default="message">
@@ -149,7 +151,7 @@ <policySet name="ConfidentialityPolicies"
provides="test:confidentiality"
- bindings="binding.ws"
+ appliesTo="binding.ws"
xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<intentMap provides="test:confidentiality" default="transport">
|