cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r692229 [1/2] - in /cxf/trunk: api/src/main/java/org/apache/cxf/ws/policy/ api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/ api/src/main/java/org/apache/cxf/ws/policy/builder/xml/ api/src/test/java/org/apache/cxf/ws/policy/buil...
Date Thu, 04 Sep 2008 20:36:48 GMT
Author: dkulp
Date: Thu Sep  4 13:36:47 2008
New Revision: 692229

URL: http://svn.apache.org/viewvc?rev=692229&view=rev
Log:
Update policy engine to parse policies in any namespace.   No need to configure a namespace now.

Removed:
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyConstantsBeanDefinitionParser.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyTestUtils.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java
    cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalDocumentReferenceResolver.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalServiceModelReferenceResolver.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMAssertionBuilder.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/NamespaceHandler.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyBeanDefinitionParser.java
    cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml
    cxf/trunk/rt/ws/policy/src/main/resources/schemas/policy.xsd
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/NormalizeTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyBeansTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/beans.xml
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java
    cxf/trunk/systests/src/test/resources/wsdl_systest/DoubleIt.wsdl

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java Thu Sep  4 13:36:47 2008
@@ -19,14 +19,24 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.extension.BusExtension;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+import org.apache.cxf.helpers.DOMUtils;
 
 /**
  * Encapsulation of version-specific WS-Policy constants.
  */
-public final class PolicyConstants implements BusExtension {
+public final class PolicyConstants {
     
     public static final String NAMESPACE_WS_POLICY
         = "http://www.w3.org/ns/ws-policy";
@@ -38,6 +48,16 @@
         = "http://schemas.xmlsoap.org/ws/2004/09/policy";
     
     
+    public static final String POLICY_ELEM_NAME = "Policy";
+    public static final String POLICYREFERENCE_ELEM_NAME = "PolicyReference";
+    public static final String POLICYATTACHMENT_ELEM_NAME = "PolicyAttachment";
+    public static final String APPLIESTO_ELEM_NAME = "AppliesTo";
+
+    public static final String WSU_NAMESPACE_URI = 
+        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+    public static final String WSU_ID_ATTR_NAME = "Id";
+
+    
     public static final String CLIENT_POLICY_OUT_INTERCEPTOR_ID
         = "org.apache.cxf.ws.policy.ClientPolicyOutInterceptor";
     public static final String CLIENT_POLICY_IN_INTERCEPTOR_ID
@@ -66,153 +86,83 @@
     public static final String SERVER_OUTFAULT_ASSERTIONS
         = "org.apache.cxf.ws.policy.server.outfault.assertions";
     
-    private static String namespaceURI; 
-    
-    private static final String POLICY_ELEM_NAME = "Policy";
     
     private static final String ALL_ELEM_NAME = "All";
-    
     private static final String EXACTLYONE_ELEM_NAME = "ExactlyOne";
-    
-    private static final String POLICYREFERENCE_ELEM_NAME = "PolicyReference";
-    
-    private static final String POLICYATTACHMENT_ELEM_NAME = "PolicyAttachment";
-    
-    private static final String APPLIESTO_ELEM_NAME = "AppliesTo";
-    
     private static final String OPTIONAL_ATTR_NAME = "Optional"; 
-    
     private static final String POLICYURIS_ATTR_NAME = "PolicyURIs";
     
-    private static QName policyElemQName;
-    
-    private static QName allElemQName;
-    
-    private static QName exactlyOneElemQName;
-    
-    private static QName policyReferenceElemQName;
-    
-    private static QName policyAttachmentElemQName;
     
-    private static QName appliesToElemQName;
-    
-    private static QName optionalAttrQName;
-    
-    private static QName policyURIsAttrQName;
-    
-    private static final String WSU_NAMESPACE_URI = 
-        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
-    
-    private static final String WSU_ID_ATTR_NAME = "Id";
-    
-    private static final QName WSU_ID_ATTR_QNAME =
-        new QName(WSU_NAMESPACE_URI, WSU_ID_ATTR_NAME);
-    
-    
-    public PolicyConstants() {
-        setNamespace(NAMESPACE_WS_POLICY);
-    }
-    
-    public Class<?> getRegistrationType() {
-        return PolicyConstants.class;
-    }
-
-    public void setNamespace(String uri) {
-        namespaceURI = uri;
-        
-        // update qnames
-        
-        policyElemQName = new QName(namespaceURI, POLICY_ELEM_NAME);
-        allElemQName = new QName(namespaceURI, ALL_ELEM_NAME);
-        exactlyOneElemQName = new QName(namespaceURI, EXACTLYONE_ELEM_NAME);
-        policyReferenceElemQName = new QName(namespaceURI, POLICYREFERENCE_ELEM_NAME);
-        policyAttachmentElemQName = new QName(namespaceURI, POLICYATTACHMENT_ELEM_NAME);
-        appliesToElemQName = new QName(namespaceURI, APPLIESTO_ELEM_NAME);
-        optionalAttrQName = new QName(namespaceURI, OPTIONAL_ATTR_NAME);
-        policyURIsAttrQName = new QName(namespaceURI, POLICYURIS_ATTR_NAME);
-        
-    }
-  
-    public String getNamespace() {
-        return namespaceURI;
-    } 
-    
-    public String getWSUNamespace() {
-        return WSU_NAMESPACE_URI;
-    }
-    
-    public String getPolicyElemName() {
-        return POLICY_ELEM_NAME;
-    }
     
-    public String getAllElemName() {
-        return ALL_ELEM_NAME;
+    private static final Set<String> SUPPORTED_NAMESPACES = new HashSet<String>();
+    static {
+        SUPPORTED_NAMESPACES.add(NAMESPACE_WS_POLICY);
+        SUPPORTED_NAMESPACES.add(NAMESPACE_W3_200607);
+        SUPPORTED_NAMESPACES.add(NAMESPACE_XMLSOAP_200409);
+    }
+    
+    private PolicyConstants() {
+        //utility class
+    }
+    
+    public static List<Element> findAllPolicyElementsOfLocalName(Document doc, String localName) {
+        return findAllPolicyElementsOfLocalName(doc.getDocumentElement(), localName);
+    }
+    public static List<Element> findAllPolicyElementsOfLocalName(Element el, String localName) {
+        List<Element> ret = new LinkedList<Element>();
+        findAllPolicyElementsOfLocalName(el, localName, ret);
+        return ret;
+    }
+    public static void findAllPolicyElementsOfLocalName(Element el, String localName, List<Element> val) {
+        if (localName.equals(el.getLocalName()) && SUPPORTED_NAMESPACES.contains(el.getNamespaceURI())) {
+            val.add(el);
+        }
+        el = DOMUtils.getFirstElement(el);
+        while (el != null) {
+            findAllPolicyElementsOfLocalName(el, localName, val);
+            el = DOMUtils.getNextElement(el);
+        }
+    }
+
+    
+    public static Attr findOptionalAttribute(Element e) {
+        NamedNodeMap atts = e.getAttributes();
+        for (int x = 0; x < atts.getLength(); x++) {
+            Attr att = (Attr)atts.item(x);
+            QName qn = new QName(att.getNamespaceURI(), att.getLocalName());
+            if (isOptionalAttribute(qn)) {
+                return att;
+            }
+        }
+        return null;
+    }
+
+    public static boolean isOptionalAttribute(QName qn) {
+        return OPTIONAL_ATTR_NAME.equals(qn.getLocalPart())
+            && SUPPORTED_NAMESPACES.contains(qn.getNamespaceURI());
+    }
+    public static boolean isPolicyElem(QName qn) {
+        return POLICY_ELEM_NAME.equals(qn.getLocalPart())
+            && SUPPORTED_NAMESPACES.contains(qn.getNamespaceURI());
+    }
+    public static boolean isPolicyRefElem(QName qn) {
+        return POLICYREFERENCE_ELEM_NAME.equals(qn.getLocalPart())
+            && SUPPORTED_NAMESPACES.contains(qn.getNamespaceURI());
+    }
+    public static boolean isAppliesToElem(QName qn) {
+        return APPLIESTO_ELEM_NAME.equals(qn.getLocalPart())
+            && SUPPORTED_NAMESPACES.contains(qn.getNamespaceURI());
+    }
+    public static boolean isPolicyURIsAttr(QName qn) {
+        return POLICYURIS_ATTR_NAME.equals(qn.getLocalPart())
+            && SUPPORTED_NAMESPACES.contains(qn.getNamespaceURI());
+    }
+    public static boolean isExactlyOne(QName qn) {
+        return EXACTLYONE_ELEM_NAME.equals(qn.getLocalPart())
+            && SUPPORTED_NAMESPACES.contains(qn.getNamespaceURI());
+    }
+    public static boolean isAll(QName qn) {
+        return ALL_ELEM_NAME.equals(qn.getLocalPart())
+            && SUPPORTED_NAMESPACES.contains(qn.getNamespaceURI());
     }
-    
-    public String getExactlyOneElemName() {
-        return EXACTLYONE_ELEM_NAME;
-    }
-    
-    public String getPolicyReferenceElemName() {
-        return POLICYREFERENCE_ELEM_NAME;
-    }
-    
-    public String getPolicyAttachmentElemName() {
-        return POLICYATTACHMENT_ELEM_NAME;
-    }
-    
-    public String getAppliesToElemName() {
-        return APPLIESTO_ELEM_NAME;
-    }
-    
-    public String getOptionalAttrName() {
-        return OPTIONAL_ATTR_NAME;
-    }
-    
-    public String getPolicyURIsAttrName() {
-        return POLICYURIS_ATTR_NAME;
-    }
-    
-    public String getIdAttrName() {
-        return WSU_ID_ATTR_NAME;
-    }
-    
-    public QName getPolicyElemQName() {
-        return policyElemQName;
-    }
-    
-    public QName getAllElemQName() {
-        return allElemQName;
-    }
-    
-    public QName getExactlyOneElemQName() {
-        return exactlyOneElemQName;
-    }
-    
-    public QName getPolicyReferenceElemQName() {
-        return policyReferenceElemQName;
-    }
-    
-    public QName getPolicyAttachmentElemQName() {
-        return policyAttachmentElemQName;
-    }
-    
-    public QName getAppliesToElemQName() {
-        return appliesToElemQName;
-    }
-    
-    public QName getOptionalAttrQName() {
-        return optionalAttrQName;
-    }
-    
-    public QName getPolicyURIsAttrQName() {
-        return policyURIsAttrQName;
-    }
-    
-    public QName getIdAttrQName() {
-        return WSU_ID_ATTR_QNAME;
-    } 
-    
-    
-   
 }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java Thu Sep  4 13:36:47 2008
@@ -66,14 +66,12 @@
         this.nested = p;
     }
 
-    public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, 
-                                    PolicyConstants constants) {
-        this(elem, builder, constants, true);
+    public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder) {
+        this(elem, builder, true);
     }
     
-    public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, 
-                                    PolicyConstants constants, boolean assertionRequired) {
-        super(elem, constants);
+    public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, boolean assertionRequired) {
+        super(elem);
         this.assertionRequired = assertionRequired;
         
         // expect exactly one child element of type Policy
@@ -82,18 +80,18 @@
         for (Node nd = elem.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
             if (Node.ELEMENT_NODE == nd.getNodeType()) {
                 QName qn = new QName(nd.getNamespaceURI(), nd.getLocalName());
-                if (constants.getPolicyElemQName().equals(qn)
+                if (PolicyConstants.isPolicyElem(qn)
                     && null == policyElem) {
                     policyElem = (Element)nd;
                 } else {
                     throw new PolicyException(new Message("UNEXPECTED_CHILD_ELEMENT_EXC", BUNDLE, 
-                                                          constants.getPolicyElemQName()));
+                                                          PolicyConstants.POLICY_ELEM_NAME));
                 }                
             }
         }
         if (null == policyElem) {
             throw new PolicyException(new Message("UNEXPECTED_CHILD_ELEMENT_EXC", BUNDLE, 
-                                                  constants.getPolicyElemQName()));
+                                                  PolicyConstants.POLICY_ELEM_NAME));
         }
         
         nested = builder.getPolicy(policyElem);  

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java Thu Sep  4 13:36:47 2008
@@ -42,7 +42,7 @@
     
     @Override
     public PolicyAssertion build(Element elem) {
-        return new NestedPrimitiveAssertion(elem, builder, getPolicyConstants()); 
+        return new NestedPrimitiveAssertion(elem, builder); 
     }
 
     @Override

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java Thu Sep  4 13:36:47 2008
@@ -27,6 +27,7 @@
 
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
 
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
@@ -59,12 +60,15 @@
         optional = o;
     }
     
-    public PrimitiveAssertion(Element element, PolicyConstants constants) {
+    public PrimitiveAssertion(Element element) {
         name = new QName(element.getNamespaceURI(), element.getLocalName());
-        Attr attribute = element.getAttributeNodeNS(constants.getNamespace(), 
-                                                    constants.getOptionalAttrName());
-        if (attribute != null) {
-            optional = Boolean.valueOf(attribute.getValue());
+        NamedNodeMap atts = element.getAttributes();
+        for (int x = 0; x < atts.getLength(); x++) {
+            Attr att = (Attr)atts.item(x);
+            QName qn = new QName(att.getNamespaceURI(), att.getLocalName());
+            if (PolicyConstants.isOptionalAttribute(qn)) {
+                optional = Boolean.valueOf(att.getValue());                
+            }
         }
     }
 

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java Thu Sep  4 13:36:47 2008
@@ -29,7 +29,6 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.ws.policy.AssertionBuilder;
 import org.apache.cxf.ws.policy.PolicyAssertion;
-import org.apache.cxf.ws.policy.PolicyConstants;
 
 public class PrimitiveAssertionBuilder implements AssertionBuilder {
 
@@ -48,7 +47,7 @@
     }
     
     public PolicyAssertion build(Element element) {  
-        return new PrimitiveAssertion(element, getPolicyConstants());
+        return new PrimitiveAssertion(element);
     }
 
     public Collection<QName> getKnownElements() {
@@ -69,16 +68,5 @@
         }
         return  null;
     }   
-    
-    protected PolicyConstants getPolicyConstants() {
-        PolicyConstants constants = null;
-        if (null != bus) {
-            constants = bus.getExtension(PolicyConstants.class);
-        }
-        if (null == constants) {
-            constants = new PolicyConstants();
-        }
-        return constants;
-        
-    }
+
 }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java Thu Sep  4 13:36:47 2008
@@ -39,6 +39,6 @@
     
     
     public PolicyAssertion build(Element element) {
-        return new XmlPrimitiveAssertion(element, getPolicyConstants());
+        return new XmlPrimitiveAssertion(element);
     }
 }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java Thu Sep  4 13:36:47 2008
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.ws.policy.builder.xml;
 
+import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 
 import org.apache.cxf.ws.policy.PolicyAssertion;
@@ -34,17 +35,15 @@
 public class XmlPrimitiveAssertion extends PrimitiveAssertion {
 
     private Element element;
-    private PolicyConstants constants;
 
     /**
      * Constructs a XmlPrimitiveAssertion from an xml element.
      * 
      * @param e the xml element
      */
-    public XmlPrimitiveAssertion(Element e, PolicyConstants c) {
-        super(e, c);
+    public XmlPrimitiveAssertion(Element e) {
+        super(e);
         element = e;
-        constants = c;
     }
 
     /**
@@ -68,9 +67,11 @@
     protected PolicyAssertion cloneMandatory() {
         Element e = (Element)element.cloneNode(true);
         if (isOptional()) {
-            e.removeAttributeNode(e.getAttributeNodeNS(constants.getNamespace(), 
-                                                       constants.getOptionalAttrName()));
+            Attr att = PolicyConstants.findOptionalAttribute(e);
+            if (att != null) {
+                e.removeAttributeNode(att);
+            }
         }
-        return new XmlPrimitiveAssertion(e, constants);        
+        return new XmlPrimitiveAssertion(e);        
     }
 }

Modified: cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java (original)
+++ cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java Thu Sep  4 13:36:47 2008
@@ -32,7 +32,6 @@
 import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
 import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilder;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.neethi.Policy;
 import org.easymock.classextension.EasyMock;
@@ -112,10 +111,7 @@
         Policy nested = control.createMock(Policy.class);
         EasyMock.expect(builder.getPolicy(EasyMock.isA(Element.class))).andReturn(nested);
         
-        PolicyConstants pc = new PolicyConstants();
-        pc.setNamespace(PolicyConstants.NAMESPACE_W3_200607);
         Bus bus = control.createMock(Bus.class);
-        EasyMock.expect(bus.getExtension(PolicyConstants.class)).andReturn(pc);
         control.replay();
         
         npab.setBus(bus);

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Thu Sep  4 13:36:47 2008
@@ -22,11 +22,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.logging.Logger;
 
 import javax.wsdl.Binding;
@@ -130,7 +132,7 @@
         description.setName(d.getQName());
         description.setBaseURI(d.getDocumentBaseURI());
         copyExtensors(description, d.getExtensibilityElements());
-        copyExtensionAttributes(description, d);
+        copyExtensionAttributes(description, d);        
 
         List<ServiceInfo> serviceList = new ArrayList<ServiceInfo>();
         for (java.util.Iterator<QName> ite = CastUtils.cast(d.getServices().keySet().iterator()); ite
@@ -227,6 +229,21 @@
             description.setBaseURI(def.getDocumentBaseURI());
             copyExtensors(description, def.getExtensibilityElements());
             copyExtensionAttributes(description, def);
+            
+            Set<Definition> done = new HashSet<Definition>();
+            done.add(def);
+            Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
+            for (List<Import> imports : values) {
+                for (Import imp : imports) {
+                    if (!done.contains(imp.getDefinition())) {
+                        done.add(imp.getDefinition());
+                        copyExtensors(description, imp.getExtensibilityElements());
+                        copyExtensionAttributes(description, imp);
+                        copyExtensors(description, imp.getDefinition().getExtensibilityElements());
+                        copyExtensionAttributes(description, imp.getDefinition());
+                    }
+                }
+            }
         }
         for (Port port : cast(serv.getPorts().values(), Port.class)) {
             Binding binding = port.getBinding();

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java (original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java Thu Sep  4 13:36:47 2008
@@ -63,15 +63,14 @@
         QName qn = new QName(elem.getNamespaceURI(), localName);
         
         boolean optional = false;
-        PolicyConstants constants = bus.getExtension(PolicyConstants.class);
-        Attr attribute = elem.getAttributeNodeNS(constants.getNamespace(), 
-                                                 constants.getOptionalAttrName());
+        
+        Attr attribute = PolicyConstants.findOptionalAttribute(elem);
         if (attribute != null) {
             optional = Boolean.valueOf(attribute.getValue());
         }
         if (MetadataConstants.ADDRESSING_ASSERTION_QNAME.equals(qn)) {
             PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
-            return new NestedPrimitiveAssertion(elem, builder, constants);
+            return new NestedPrimitiveAssertion(elem, builder);
         } else if (MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME.equals(qn)) {
             return new PrimitiveAssertion(MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME, 
                                           optional);

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java Thu Sep  4 13:36:47 2008
@@ -141,10 +141,9 @@
     }
 
     private PolicyOperator processOperationElement(Element operationElement, PolicyOperator operator) {
-        
+
         if (Constants.TYPE_POLICY == operator.getType()) {
             Policy policyOperator = (Policy)operator;
-
             QName key;
 
             NamedNodeMap nnm = operationElement.getAttributes();
@@ -166,9 +165,6 @@
             }            
         }
 
-        String policyNsURI = 
-            bus == null ? PolicyConstants.NAMESPACE_WS_POLICY
-                        : bus.getExtension(PolicyConstants.class).getNamespace();
         
         Element childElement;
         for (Node n = operationElement.getFirstChild(); n != null; n = n.getNextSibling()) {
@@ -179,21 +175,15 @@
             String namespaceURI = childElement.getNamespaceURI();
             String localName = childElement.getLocalName();
 
-            if (policyNsURI.equals(namespaceURI)) {
-
-                if (Constants.ELEM_POLICY.equals(localName)) {
-                    operator.addPolicyComponent(getPolicyOperator(childElement));
-
-                } else if (Constants.ELEM_EXACTLYONE.equals(localName)) {
-                    operator.addPolicyComponent(getExactlyOneOperator(childElement));
-
-                } else if (Constants.ELEM_ALL.equals(localName)) {
-                    operator.addPolicyComponent(getAllOperator(childElement));
-
-                } else if (Constants.ELEM_POLICY_REF.equals(localName)) {
-                    operator.addPolicyComponent(getPolicyReference(childElement));
-                }
-
+            QName qn = new QName(namespaceURI, localName);
+            if (PolicyConstants.isPolicyElem(qn)) {
+                operator.addPolicyComponent(getPolicyOperator(childElement));
+            } else if (PolicyConstants.isAll(qn)) {
+                operator.addPolicyComponent(getAllOperator(childElement));
+            } else if (PolicyConstants.isExactlyOne(qn)) {
+                operator.addPolicyComponent(getExactlyOneOperator(childElement));
+            } else if (PolicyConstants.isPolicyRefElem(qn)) {
+                operator.addPolicyComponent(getPolicyReference(childElement));                
             } else if (null != assertionBuilderRegistry) {
                 PolicyAssertion a = assertionBuilderRegistry.build(childElement);
                 if (null != a) {

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java Thu Sep  4 13:36:47 2008
@@ -60,7 +60,6 @@
     private Collection<Element> policyElements;
     private Collection<Element> policyReferenceElements;
     private boolean ignoreUnknownAssertions;
-    private String namespace;
     private AlternativeSelector alternativeSelector; 
     private ApplicationContext context;
   
@@ -90,10 +89,6 @@
         synchronized (pe) {
             pe.setEnabled(true);
             pe.setIgnoreUnknownAssertions(ignoreUnknownAssertions);
-            if (null != namespace) {
-                PolicyConstants pc = bus.getExtension(PolicyConstants.class);
-                pc.setNamespace(namespace);
-            }
             if (null != alternativeSelector) {
                 pe.setAlternativeSelector(alternativeSelector);
             }
@@ -198,9 +193,6 @@
         ignoreUnknownAssertions = ignore;
     } 
     
-    public void setNamespace(String ns) {
-        namespace = ns;
-    }
     
     public void setAlternativeSelector(AlternativeSelector as) {
         alternativeSelector = as;
@@ -248,8 +240,7 @@
     
     protected Policy resolveExternal(PolicyReference ref,  String baseURI, Bus bus) {
         PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
-        ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder,
-            bus.getExtension(PolicyConstants.class));
+        ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
         PolicyRegistry registry = bus.getExtension(PolicyEngine.class).getRegistry();
         Policy resolved = registry.lookup(ref.getURI());
         if (null != resolved) {

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/AbstractPolicyProvider.java Thu Sep  4 13:36:47 2008
@@ -27,7 +27,6 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.ws.policy.PolicyBuilder;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.cxf.ws.policy.PolicyProvider;
@@ -78,8 +77,7 @@
     }
     
     protected Policy resolveExternal(PolicyReference ref,  String baseURI) {
-        ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder,
-            bus.getExtension(PolicyConstants.class));
+        ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
         Policy resolved = registry.lookup(ref.getURI());
         if (null != resolved) {
             return resolved;

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java Thu Sep  4 13:36:47 2008
@@ -29,7 +29,6 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.i18n.BundleUtils;
@@ -157,40 +156,31 @@
             throw new PolicyException(ex);
         }
         
-        PolicyConstants constants = null;
-        if (null != bus) {
-            constants = bus.getExtension(PolicyConstants.class);
-        }
-        if (null == constants) {
-            constants = new PolicyConstants();
-        }
-        NodeList nl = doc.getElementsByTagNameNS(constants.getNamespace(), 
-                                                 constants.getPolicyAttachmentElemName());
-        for (int i = 0; i < nl.getLength(); i++) {
-            
+        for (Element ae 
+                : PolicyConstants
+                    .findAllPolicyElementsOfLocalName(doc, 
+                                                      PolicyConstants.POLICYATTACHMENT_ELEM_NAME)) {    
             PolicyAttachment attachment = new PolicyAttachment();
             
-            Element ae = (Element)nl.item(i);
-            
             for (Node nd = ae.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
                 if (Node.ELEMENT_NODE != nd.getNodeType()) {
                     continue;
                 }
                 QName qn = new QName(nd.getNamespaceURI(), nd.getLocalName());
-                if (constants.getAppliesToElemQName().equals(qn)) {
+                if (PolicyConstants.isAppliesToElem(qn)) {
                     Collection<DomainExpression> des = readDomainExpressions((Element)nd);
                     if (des.isEmpty()) {
                         // forget about this attachment
                         continue;
                     }
                     attachment.setDomainExpressions(des);                    
-                } else if (constants.getPolicyElemQName().equals(qn)) {
+                } else if (PolicyConstants.isPolicyElem(qn)) {
                     Policy p = builder.getPolicy((Element)nd);
                     if (null != attachment.getPolicy()) {
                         p = p.merge(attachment.getPolicy());
                     }
                     attachment.setPolicy(p);
-                } else if (constants.getPolicyReferenceElemQName().equals(qn)) {
+                } else if (PolicyConstants.isPolicyRefElem(qn)) {
                     PolicyReference ref = builder.getPolicyReference((Element)nd);
                     if (null != ref) {   
                         Policy p = resolveReference(ref, doc);
@@ -228,8 +218,7 @@
         if (null != resolved) {
             return resolved;
         }
-        ReferenceResolver resolver = new LocalDocumentReferenceResolver(doc, builder, 
-            bus.getExtension(PolicyConstants.class));
+        ReferenceResolver resolver = new LocalDocumentReferenceResolver(doc, builder);
         resolved = resolver.resolveReference(relativeURI);
         if (null != resolved) {
             ref.setURI(absoluteURI);

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalDocumentReferenceResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalDocumentReferenceResolver.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalDocumentReferenceResolver.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalDocumentReferenceResolver.java Thu Sep  4 13:36:47 2008
@@ -21,8 +21,8 @@
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
 
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.ws.policy.PolicyBuilder;
 import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.neethi.Policy;
@@ -34,24 +34,29 @@
 
     private Document document;
     private PolicyBuilder builder;
-    private PolicyConstants constants;
     
-    public LocalDocumentReferenceResolver(Document di, PolicyBuilder b, PolicyConstants c) {
+    public LocalDocumentReferenceResolver(Document di, PolicyBuilder b) {
         document = di;
         builder = b;
-        constants = c;
     }
-    
     public Policy resolveReference(String uri) {
-        NodeList nl = document.getElementsByTagNameNS(constants.getNamespace(),
-                                                      constants.getPolicyElemName());
-        
-        for (int i = 0; i < nl.getLength(); i++) {
-            Element e = (Element)nl.item(i);
-            if (uri.equals(e.getAttributeNS(constants.getWSUNamespace(),
-                                            constants.getIdAttrName()))) {
-                return builder.getPolicy(e);
+        return resolveReference(uri, document.getDocumentElement());
+    }    
+    public Policy resolveReference(String uri, Element el) {
+        if (el == null) {
+            return null;
+        }
+        if (uri.equals(el.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
+                                         PolicyConstants.WSU_ID_ATTR_NAME))) {
+            return builder.getPolicy(el);
+        }
+        Element el2 = DOMUtils.getFirstElement(el);
+        while (el2 != null) {
+            Policy p = resolveReference(uri, el2);
+            if (p != null) {
+                return p;
             }
+            el2 = DOMUtils.getNextElement(el2);
         }
         return null;
     }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalServiceModelReferenceResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalServiceModelReferenceResolver.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalServiceModelReferenceResolver.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/LocalServiceModelReferenceResolver.java Thu Sep  4 13:36:47 2008
@@ -35,23 +35,22 @@
 
     private DescriptionInfo descriptionInfo;
     private PolicyBuilder builder;
-    private PolicyConstants constants;
     
-    public LocalServiceModelReferenceResolver(DescriptionInfo d, PolicyBuilder b, PolicyConstants c) {
+    public LocalServiceModelReferenceResolver(DescriptionInfo d, PolicyBuilder b) {
         descriptionInfo = d;
         builder = b;
-        constants = c;
     }
     
     public Policy resolveReference(String uri) {
         List<UnknownExtensibilityElement> extensions = 
             descriptionInfo.getExtensors(UnknownExtensibilityElement.class);
-        for (UnknownExtensibilityElement e : extensions) {
-            if (constants.getNamespace().equals(e.getElementType().getNamespaceURI())
-                && constants.getPolicyElemName().equals(e.getElementType().getLocalPart())
-                && uri.equals(e.getElement().getAttributeNS(constants.getWSUNamespace(),
-                                                            constants.getIdAttrName()))) {
-                return builder.getPolicy(e.getElement());
+        if (extensions != null) {
+            for (UnknownExtensibilityElement e : extensions) {
+                if (PolicyConstants.isPolicyElem(e.getElementType())
+                    && uri.equals(e.getElement().getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
+                                                                PolicyConstants.WSU_ID_ATTR_NAME))) {
+                    return builder.getPolicy(e.getElement());
+                }
             }
         }
         return null;

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/reference/RemoteReferenceResolver.java Thu Sep  4 13:36:47 2008
@@ -21,7 +21,6 @@
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
 
 import org.xml.sax.InputSource;
 
@@ -39,12 +38,10 @@
     
     private String baseURI;
     private PolicyBuilder builder;
-    private PolicyConstants constants;
     
-    public RemoteReferenceResolver(String uri, PolicyBuilder b, PolicyConstants c) {
+    public RemoteReferenceResolver(String uri, PolicyBuilder b) {
         baseURI = uri;
         builder = b;
-        constants = c;
     }
 
     public Policy resolveReference(String uri) {
@@ -61,14 +58,13 @@
         } catch (Exception ex) {
             throw new PolicyException(ex);
         }
-
-        NodeList nl = doc.getElementsByTagNameNS(constants.getNamespace(), 
-                                                 constants.getPolicyElemName());
         String id = uri.substring(pos + 1);
-        for (int i = 0; i < nl.getLength(); i++) {
-            Element elem = (Element)nl.item(i);
-            if (id.equals(elem.getAttributeNS(constants.getWSUNamespace(), 
-                                              constants.getIdAttrName()))) {
+        for (Element elem : PolicyConstants
+                .findAllPolicyElementsOfLocalName(doc,
+                                                  PolicyConstants.POLICY_ELEM_NAME)) {
+            
+            if (id.equals(elem.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
+                                              PolicyConstants.WSU_ID_ATTR_NAME))) {
                 return builder.getPolicy(elem);
             }
         }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java Thu Sep  4 13:36:47 2008
@@ -70,6 +70,15 @@
         return getElementPolicy(si);
     }
     
+    private Policy mergePolicies(Policy p1, Policy p2) {
+        if (p1 == null) {
+            return p2;
+        } else if (p2 == null) {
+            return p1;
+        }
+        return p1.merge(p2);
+    }
+    
     /**
      * The effective policy for a WSDL endpoint policy subject includes the element policy of the 
      * wsdl11:port element that defines the endpoint merged with the element policy of the
@@ -81,8 +90,8 @@
      */
     public Policy getEffectivePolicy(EndpointInfo ei) {
         Policy p = getElementPolicy(ei);
-        p = p.merge(getElementPolicy(ei.getBinding()));
-        p = p.merge(getElementPolicy(ei.getInterface(), true));
+        p = mergePolicies(p, getElementPolicy(ei.getBinding()));
+        p = mergePolicies(p, getElementPolicy(ei.getInterface(), true));
         
         return p;
     }
@@ -99,7 +108,7 @@
     public Policy getEffectivePolicy(BindingOperationInfo bi) {
         DescriptionInfo di = bi.getBinding().getDescription();
         Policy p = getElementPolicy(bi, false, di);
-        p = p.merge(getElementPolicy(bi.getOperationInfo(), false, di));
+        p = mergePolicies(p, getElementPolicy(bi.getOperationInfo(), false, di));
         return p;
     }
     
@@ -121,9 +130,9 @@
         DescriptionInfo di = si.getDescription();
         Policy p = getElementPolicy(bmi, false, di);
         MessageInfo mi = bmi.getMessageInfo();
-        p = p.merge(getElementPolicy(mi, true, di));
+        p = mergePolicies(p, getElementPolicy(mi, true, di));
         Extensible ex = getMessageTypeInfo(mi.getName(), di);
-        p = p.merge(getElementPolicy(ex, false, di));
+        p = mergePolicies(p, getElementPolicy(ex, false, di));
 
         return p;
     }
@@ -136,9 +145,9 @@
 
         Policy p = getElementPolicy(bfi, false, di);
         FaultInfo fi = bfi.getFaultInfo();
-        p = p.merge(getElementPolicy(fi, true, di));
+        p = mergePolicies(p, getElementPolicy(fi, true, di));
         Extensible ex = getMessageTypeInfo(fi.getName(), di);
-        p = p.merge(getElementPolicy(ex, false, di));
+        p = mergePolicies(p, getElementPolicy(ex, false, di));
 
         return p;
     }
@@ -153,51 +162,57 @@
   
     Policy getElementPolicy(Extensible ex, boolean includeAttributes, DescriptionInfo di) {
         
-        Policy elementPolicy = new Policy();
         
         if (null == ex || null == di) {
-            return elementPolicy;
+            return null;
         }
-        
+        Policy elementPolicy = null;
         List<UnknownExtensibilityElement> extensions = 
             ex.getExtensors(UnknownExtensibilityElement.class);
-        PolicyConstants constants = bus.getExtension(PolicyConstants.class);
         if (null != extensions) {
             for (UnknownExtensibilityElement e : extensions) {
                 Policy p = null;
-                if (constants.getPolicyElemQName().equals(e.getElementType())) {
+                if (PolicyConstants.isPolicyElem(e.getElementType())) {
                     p = builder.getPolicy(e.getElement());                    
 
-                } else if (constants.getPolicyReferenceElemQName().equals(e.getElementType())) {
+                } else if (PolicyConstants.isPolicyRefElem(e.getElementType())) {
                     PolicyReference ref = builder.getPolicyReference(e.getElement());
                     if (null != ref) {
                         p = resolveReference(ref, di);
                     }
                 }
                 if (null != p) {
+                    if (elementPolicy == null) {
+                        elementPolicy = new Policy();
+                    }
                     elementPolicy = elementPolicy.merge(p);
                 }
             }
         }
         
-        if (includeAttributes) {
-            Object attr = ex.getExtensionAttribute(constants.getPolicyURIsAttrQName());
-            // can be of type a String, a QName, a list of Srings or a list of QNames
-            String uris = null;
-            if (attr instanceof QName) {
-                uris = ((QName)attr).getLocalPart();
-            } else if (attr instanceof String) {
-                uris = (String)attr;
-            }
-            if (null != uris) {
-                StringTokenizer st = new StringTokenizer(uris);
-                while (st.hasMoreTokens()) {
-                    String uri = st.nextToken();
-                    PolicyReference ref = new PolicyReference();
-                    ref.setURI(uri);
-                    Policy p = resolveReference(ref, di);
-                    if (null != p) {
-                        elementPolicy = elementPolicy.merge(p);
+        if (includeAttributes && ex.getExtensionAttributes() != null) {
+            for (Map.Entry<QName, Object> ent : ex.getExtensionAttributes().entrySet()) {
+                if (PolicyConstants.isPolicyURIsAttr(ent.getKey())) {
+                    Object attr = ent.getValue();
+                    // can be of type a String, a QName, a list of Srings or a list of QNames
+                    String uris = null;
+                    if (attr instanceof QName) {
+                        uris = ((QName)attr).getLocalPart();
+                    } else if (attr instanceof String) {
+                        uris = (String)attr;
+                    }
+                    if (null != uris) {
+                        StringTokenizer st = new StringTokenizer(uris);
+                        while (st.hasMoreTokens()) {
+                            String uri = st.nextToken();
+                            PolicyReference ref = new PolicyReference();
+                            ref.setURI(uri);
+                            Policy p = resolveReference(ref, di);
+                            if (null != p) {
+                                elementPolicy = elementPolicy == null 
+                                    ? new Policy().merge(p) : elementPolicy.merge(p);
+                            }
+                        }
                     }
                 }
             }
@@ -219,13 +234,12 @@
     
     Policy resolveLocal(PolicyReference ref, DescriptionInfo di) {
         String uri = ref.getURI().substring(1);
-        String absoluteURI = di.getBaseURI() + uri;
+        String absoluteURI = di.getBaseURI() + ref.getURI();
         Policy resolved = registry.lookup(absoluteURI);
         if (null != resolved) {
             return resolved;
         }
-        ReferenceResolver resolver = new LocalServiceModelReferenceResolver(di, builder,
-            bus.getExtension(PolicyConstants.class));
+        ReferenceResolver resolver = new LocalServiceModelReferenceResolver(di, builder);
         resolved = resolver.resolveReference(uri);
         if (null != resolved) {
             ref.setURI(absoluteURI);

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMAssertionBuilder.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMAssertionBuilder.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMAssertionBuilder.java Thu Sep  4 13:36:47 2008
@@ -28,7 +28,6 @@
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.ws.policy.AssertionBuilder;
 import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyConstants;
@@ -37,29 +36,16 @@
 
 public class MTOMAssertionBuilder implements AssertionBuilder {
     private static final Collection<QName> KNOWN = new ArrayList<QName>();
-    private Bus bus;
     static {
         KNOWN.add(MetadataConstants.MTOM_ASSERTION_QNAME);
     }
     
-    public void setBus(Bus b) {
-        bus = b;
-    }
-
     public PolicyAssertion build(Element elem) {
         String localName = elem.getLocalName();
         QName qn = new QName(elem.getNamespaceURI(), localName);
 
         boolean optional = false;
-        PolicyConstants constants = null;
-        if (null != bus) {
-            constants = bus.getExtension(PolicyConstants.class);
-        }
-        if (null == constants) {
-            constants = new PolicyConstants();
-        }
-        Attr attribute = elem.getAttributeNodeNS(constants.getNamespace(),
-                                                 constants.getOptionalAttrName());
+        Attr attribute = PolicyConstants.findOptionalAttribute(elem);
         if (attribute != null) {
             optional = Boolean.valueOf(attribute.getValue());
         }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/NamespaceHandler.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/NamespaceHandler.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/NamespaceHandler.java Thu Sep  4 13:36:47 2008
@@ -24,7 +24,6 @@
     public void init() {
         registerBeanDefinitionParser("policies", new PolicyFeatureBeanDefinitionParser());
         registerBeanDefinitionParser("engine", new PolicyEngineBeanDefinitionParser());
-        registerBeanDefinitionParser("constants", new PolicyConstantsBeanDefinitionParser());
         registerBeanDefinitionParser("externalAttachment", 
                                      new ExternalAttachmentProviderBeanDefinitionParser()); 
     }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyBeanDefinitionParser.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyBeanDefinitionParser.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyBeanDefinitionParser.java Thu Sep  4 13:36:47 2008
@@ -40,8 +40,8 @@
     @Override
     protected String resolveId(Element element, AbstractBeanDefinition bean, 
                                ParserContext ctx) throws BeanDefinitionStoreException {
-        PolicyConstants constants = new PolicyConstants();        
-        return element.getAttributeNS(constants.getWSUNamespace(), constants.getIdAttrName());
+        return element.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
+                                      PolicyConstants.WSU_ID_ATTR_NAME);
     }
 
     @Override

Modified: cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml (original)
+++ cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml Thu Sep  4 13:36:47 2008
@@ -31,9 +31,6 @@
         </constructor-arg>
     </bean>
     
-    <bean class="org.apache.cxf.ws.policy.PolicyConstants"
-	  id="org.apache.cxf.ws.policy.PolicyConstants"/>
-    
     <bean id="org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry" class="org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistryImpl">
         <constructor-arg>
             <bean class="org.apache.cxf.configuration.spring.SpringBeanQNameMap">
@@ -77,9 +74,7 @@
     
     <!-- MTOM Policy Support -->
     <bean class="org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder"
-	  id="org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder">
-        <property name="bus" ref="cxf"/>
-    </bean>
+	  id="org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder"/>
     <bean class="org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider"
 	  id="org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider"/>
 </beans>

Modified: cxf/trunk/rt/ws/policy/src/main/resources/schemas/policy.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/resources/schemas/policy.xsd?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/resources/schemas/policy.xsd (original)
+++ cxf/trunk/rt/ws/policy/src/main/resources/schemas/policy.xsd Thu Sep  4 13:36:47 2008
@@ -104,20 +104,7 @@
     </xsd:complexType>
   </xsd:element>
  
-  <xsd:element name="constants">
-    <xsd:complexType>
-      <xsd:attribute name="namespace" type="xsd:string" default="http://www.w3.org/2006/07/ws-policy">
-        <xsd:annotation>
-          <xsd:documentation>
-              The namespace of the WS-Policy Framework specification. 
-              This attribute can be set to support older versions of the specification.           
-          </xsd:documentation>
-        </xsd:annotation>
-      </xsd:attribute>
-    </xsd:complexType>
-  </xsd:element>
-  
-    <xsd:element name="externalAttachment">
+  <xsd:element name="externalAttachment">
     <xsd:complexType>
       <xsd:complexContent>
         <xsd:extension base="beans:identifiedType">

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/NormalizeTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/NormalizeTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/NormalizeTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/NormalizeTest.java Thu Sep  4 13:36:47 2008
@@ -91,9 +91,6 @@
     
     private Bus createBus(String policyNamespace) {
         Bus bus = control.createMock(Bus.class);
-        PolicyConstants constants = new PolicyConstants();
-        constants.setNamespace(policyNamespace);
-        EasyMock.expect(bus.getExtension(PolicyConstants.class)).andReturn(constants).anyTimes();
         control.replay();
         return bus;
     }

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java Thu Sep  4 13:36:47 2008
@@ -37,7 +37,6 @@
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilder;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
 import org.apache.neethi.Policy;
@@ -190,10 +189,7 @@
     @Test
     public void testReadDocumentUnknownDomainExpression() throws MalformedURLException {
 
-        PolicyConstants pc = new PolicyConstants();
-        pc.setNamespace(PolicyConstants.NAMESPACE_W3_200607);
         Bus bus = control.createMock(Bus.class);
-        EasyMock.expect(bus.getExtension(PolicyConstants.class)).andReturn(pc);
         
         eap = new ExternalAttachmentProvider(bus);
         DomainExpressionBuilderRegistry debr = control.createMock(DomainExpressionBuilderRegistry.class);

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/reference/ReferenceResolverTest.java Thu Sep  4 13:36:47 2008
@@ -26,9 +26,7 @@
 import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
 
 import org.apache.cxf.service.model.DescriptionInfo;
 import org.apache.cxf.ws.policy.PolicyBuilder;
@@ -46,7 +44,6 @@
 public class ReferenceResolverTest extends Assert {
 
     private IMocksControl control;
-    private PolicyConstants constants = new PolicyConstants();
     
     @Before
     public void setUp() {
@@ -58,7 +55,7 @@
         DescriptionInfo di = control.createMock(DescriptionInfo.class);
         PolicyBuilder builder = control.createMock(PolicyBuilder.class);
         LocalServiceModelReferenceResolver resolver = 
-            new LocalServiceModelReferenceResolver(di, builder, constants);
+            new LocalServiceModelReferenceResolver(di, builder);
         
         List<UnknownExtensibilityElement> extensions = new ArrayList<UnknownExtensibilityElement>();
         EasyMock.expect(di.getExtensors(UnknownExtensibilityElement.class)).andReturn(extensions);
@@ -73,9 +70,11 @@
         EasyMock.expect(di.getExtensors(UnknownExtensibilityElement.class)).andReturn(extensions);
         Element e = control.createMock(Element.class);
         EasyMock.expect(extension.getElement()).andReturn(e).times(2);
-        QName qn = new QName(constants.getNamespace(), constants.getPolicyElemName());
-        EasyMock.expect(extension.getElementType()).andReturn(qn).times(2);
-        EasyMock.expect(e.getAttributeNS(constants.getWSUNamespace(), constants.getIdAttrName()))
+        QName qn = new QName(PolicyConstants.NAMESPACE_WS_POLICY, 
+                             PolicyConstants.POLICY_ELEM_NAME);
+        EasyMock.expect(extension.getElementType()).andReturn(qn).anyTimes();
+        EasyMock.expect(e.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
+                                         PolicyConstants.WSU_ID_ATTR_NAME))
                         .andReturn("A");
         Policy p = control.createMock(Policy.class);
         EasyMock.expect(builder.getPolicy(e)).andReturn(p);        
@@ -87,37 +86,6 @@
     }
     
     @Test
-    public void testLocalDocumentReferenceResolver() {
-        Document doc = control.createMock(Document.class);
-        PolicyBuilder builder = control.createMock(PolicyBuilder.class);
-        LocalDocumentReferenceResolver resolver = new LocalDocumentReferenceResolver(doc, builder, constants);
-        
-        NodeList nl = control.createMock(NodeList.class);
-        EasyMock.expect(doc.getElementsByTagNameNS(constants.getNamespace(),
-                                                   constants.getPolicyElemName())).andReturn(nl);
-        EasyMock.expect(nl.getLength()).andReturn(0);
-        
-        control.replay();
-        assertNull(resolver.resolveReference("A"));
-        control.verify();
-        
-        control.reset();
-        EasyMock.expect(doc.getElementsByTagNameNS(constants.getNamespace(),
-                                                   constants.getPolicyElemName())).andReturn(nl);
-        EasyMock.expect(nl.getLength()).andReturn(1);
-        Element e = control.createMock(Element.class);
-        EasyMock.expect(nl.item(0)).andReturn(e);
-        EasyMock.expect(e.getAttributeNS(constants.getWSUNamespace(), constants.getIdAttrName()))
-                        .andReturn("A");
-        Policy p = control.createMock(Policy.class);
-        EasyMock.expect(builder.getPolicy(e)).andReturn(p);        
-        
-        control.replay();
-        assertSame(p, resolver.resolveReference("A"));
-        control.verify();
-    }
-    
-    @Test
     public void testRemoteReferenceResolverWithOlderNs() {
         
         doTestRemoteResolver(PolicyConstants.NAMESPACE_W3_200607);
@@ -130,11 +98,10 @@
     
     private void doTestRemoteResolver(String policyNs) {
         
-        constants.setNamespace(policyNs);
         URL url = ReferenceResolverTest.class.getResource("referring.wsdl");
         String baseURI = url.toString();
         PolicyBuilder builder = control.createMock(PolicyBuilder.class);
-        RemoteReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder, constants);
+        RemoteReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
     
         assertNull(resolver.resolveReference("referred.wsdl#PolicyB"));
         

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java Thu Sep  4 13:36:47 2008
@@ -36,7 +36,6 @@
 import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
 import org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl;
 import org.apache.cxf.ws.policy.PolicyBuilderImpl;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.cxf.ws.policy.PolicyRegistryImpl;
 import org.apache.cxf.ws.policy.builder.xml.XMLPrimitiveAssertionBuilder;
@@ -66,7 +65,6 @@
     private static ServiceInfo[] services;
     private static EndpointInfo[] endpoints;
     private Wsdl11AttachmentPolicyProvider app;
-    private PolicyConstants constants;
     private Bus bus;
     private IMocksControl control = EasyMock.createNiceControl();
     
@@ -85,10 +83,6 @@
         BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class);
         EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes();
         EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
-        PolicyConstants constants = new PolicyConstants();
-        // test data uses 2004/09 namespace
-        constants.setNamespace(PolicyConstants.NAMESPACE_XMLSOAP_200409);
-        EasyMock.expect(bus.getExtension(PolicyConstants.class)).andReturn(constants).anyTimes();
         control.replay();
         
         int n = 19;
@@ -122,11 +116,7 @@
     @Before
     public void setUp() {   
         control = EasyMock.createNiceControl();
-        constants = new PolicyConstants();
-        // test data uses 2004/09 namespace
-        constants.setNamespace(PolicyConstants.NAMESPACE_XMLSOAP_200409);
         bus = control.createMock(Bus.class);
-        EasyMock.expect(bus.getExtension(PolicyConstants.class)).andReturn(constants).anyTimes();
         AssertionBuilderRegistry abr = new AssertionBuilderRegistryImpl();        
         XMLPrimitiveAssertionBuilder ab = new XMLPrimitiveAssertionBuilder();
         ab.setBus(bus);
@@ -156,13 +146,11 @@
         
         // no extensions       
         p = app.getElementPolicy(services[0]);
-        assertNotNull(p);
-        assertTrue(p.isEmpty());
+        assertTrue(p == null || p.isEmpty());
         
         // extensions not of type Policy or PolicyReference
         p = app.getElementPolicy(services[1]);
-        assertNotNull(p);
-        assertTrue(p.isEmpty());
+        assertTrue(p == null || p.isEmpty());
         
         // one extension of type Policy, without assertion builder
         try {
@@ -185,7 +173,7 @@
         verifyAssertionsOnly(p, 3);
         
         EndpointInfo ei = new EndpointInfo();
-        assertTrue(app.getElementPolicy(ei).isEmpty());
+        assertTrue(app.getElementPolicy(ei) == null);
     }
     
     @Test
@@ -196,15 +184,13 @@
         
         // no extensions        
         ep = app.getEffectivePolicy(services[0]);
-        assertNotNull(ep);
-        assertTrue(ep.isEmpty());
+        assertTrue(ep == null || ep.isEmpty());
         p = app.getElementPolicy(services[0]);
-        assertTrue(PolicyComparator.compare(p, ep));
+        assertTrue(p == null || p.isEmpty());
         
         // extensions not of type Policy or PolicyReference
         ep = app.getEffectivePolicy(services[1]);
-        assertNotNull(ep);
-        assertTrue(ep.isEmpty());
+        assertTrue(ep == null || ep.isEmpty());
         
         // one extension of type Policy, without assertion builder
         try {
@@ -240,8 +226,7 @@
         // porttype has no extensions
         // binding has no extensions
         ep = app.getEffectivePolicy(endpoints[0]);
-        assertNotNull(ep);
-        assertTrue(ep.isEmpty());
+        assertTrue(ep == null || ep.isEmpty());
         
         // port has one extension of type Policy        
         // binding has no extensions
@@ -299,8 +284,7 @@
         // operation has no extensions
         // binding operation has no extensions
         ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[0]));
-        assertNotNull(ep);
-        assertTrue(ep.isEmpty());
+        assertTrue(ep == null || ep.isEmpty());
         
         // operation has no extensions
         // binding operation has one extension of type Policy
@@ -332,8 +316,7 @@
         // operation message has no extensions
         // message has no extensions
         ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[0], true));
-        assertNotNull(ep);
-        assertTrue(ep.isEmpty());
+        assertTrue(ep == null || ep.isEmpty());
         
         // binding operation message has one extension of type Policy
         // operation message has no extensions

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java Thu Sep  4 13:36:47 2008
@@ -31,7 +31,6 @@
 import org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl;
 import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilderImpl;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.util.PolicyComparator;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyComponent;
@@ -56,7 +55,6 @@
     private PolicyBuilderImpl builder;
     private IMocksControl control;
     private Bus bus;
-    private PolicyConstants constants;
     
     @Before
     public void setUp() {
@@ -64,9 +62,6 @@
         control = EasyMock.createNiceControl();
         
         bus = control.createMock(Bus.class);
-        constants = new PolicyConstants();
-        constants.setNamespace(PolicyConstants.NAMESPACE_XMLSOAP_200409);
-        EasyMock.expect(bus.getExtension(PolicyConstants.class)).andReturn(constants).anyTimes();
         
         AssertionBuilderRegistry abr = new AssertionBuilderRegistryImpl();
         builder = new PolicyBuilderImpl();

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyBeansTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyBeansTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyBeansTest.java Thu Sep  4 13:36:47 2008
@@ -23,7 +23,6 @@
 import junit.framework.Assert;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.policy.PolicyEngineImpl;
 import org.apache.cxf.ws.policy.PolicyProvider;
@@ -53,8 +52,6 @@
         assertEquals(MaximalAlternativeSelector.class.getName(), 
                      pe.getAlternativeSelector().getClass().getName()); 
         
-        assertEquals(PolicyConstants.NAMESPACE_WS_POLICY,
-                     bus.getExtension(PolicyConstants.class).getNamespace());
         
         PolicyEngineImpl pei = (PolicyEngineImpl)pe;
         Collection<PolicyProvider> providers = pei.getPolicyProviders();

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/beans.xml?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/beans.xml (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/beans.xml Thu Sep  4 13:36:47 2008
@@ -38,8 +38,6 @@
         </p:alternativeSelector>
     </p:engine>
     
-    <p:constants namespace="http://www.w3.org/ns/ws-policy"/>
-    
     <p:externalAttachment id="external4"
         location="classpath:/org/apache/cxf/ws/policy/attachment/external/attachments4.xml"/>
     

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java Thu Sep  4 13:36:47 2008
@@ -196,6 +196,18 @@
                     ai.setAsserted(true);
                 }                    
             }
+            ais = aim.get(SP12Constants.WSS10);
+            if (ais != null) {
+                for (AssertionInfo ai : ais) {
+                    ai.setAsserted(true);
+                }                    
+            }
+            ais = aim.get(SP12Constants.WSS11);
+            if (ais != null) {
+                for (AssertionInfo ai : ais) {
+                    ai.setAsserted(true);
+                }                    
+            }
             message.put(WSHandlerConstants.ACTION, action.trim());
         }
     }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java Thu Sep  4 13:36:47 2008
@@ -95,6 +95,20 @@
                 if (transport != null) {
                     new TransportBindingHandler(transport, saaj, secHeader, aim, message).handleBinding();
                 }
+                
+                ais = aim.get(SP12Constants.WSS10);
+                if (ais != null) {
+                    for (AssertionInfo ai : ais) {
+                        ai.setAsserted(true);
+                    }                    
+                }
+                ais = aim.get(SP12Constants.WSS11);
+                if (ais != null) {
+                    for (AssertionInfo ai : ais) {
+                        ai.setAsserted(true);
+                    }                    
+                }
+
             }
             
         }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/BindingBuilder.java Thu Sep  4 13:36:47 2008
@@ -33,6 +33,7 @@
 import org.apache.cxf.ws.security.policy.model.SupportingToken;
 import org.apache.cxf.ws.security.policy.model.Token;
 import org.apache.cxf.ws.security.policy.model.UsernameToken;
+import org.apache.velocity.util.ClassUtils;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.message.WSSecHeader;
@@ -111,9 +112,18 @@
             if (StringUtils.isEmpty(password)) {
                 
                 //Then try to get the password from the given callback handler
-                CallbackHandler handler 
-                    = (CallbackHandler)message.getContextualProperty(SecurityConstants.CALLBACK_HANDLER);
+                Object o = message.getContextualProperty(SecurityConstants.CALLBACK_HANDLER);
             
+                CallbackHandler handler = null;
+                if (o instanceof CallbackHandler) {
+                    handler = (CallbackHandler)o;
+                } else if (o instanceof String) {
+                    try {
+                        handler = (CallbackHandler)ClassUtils.getNewInstance(o.toString());
+                    } catch (Exception e) {
+                        handler = null;
+                    }
+                }
                 if (handler == null) {
                     info.setNotAsserted("No callback handler and not password available");
                     return null;

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java Thu Sep  4 13:36:47 2008
@@ -47,7 +47,6 @@
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.ConduitInitiator;
 import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.policy.WSPolicyFeature;
 import org.apache.cxf.ws.policy.selector.FirstAlternativeSelector;
@@ -113,8 +112,6 @@
             policyElements.add(DOMUtils.readXml(
                 getClass().getResourceAsStream("mtom-policy-optional.xml"))
                            .getDocumentElement());
-            getBus().getExtension(PolicyConstants.class)
-               .setNamespace(PolicyConstants.NAMESPACE_W3_200607);
         } 
         policyFeature.setPolicyElements(policyElements);       
         

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java Thu Sep  4 13:36:47 2008
@@ -35,7 +35,6 @@
 import org.apache.cxf.systest.ws.util.ConnectionHelper;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.ServerPolicyInInterceptor;
 import org.apache.cxf.ws.policy.ServerPolicyOutInterceptor;
 import org.junit.BeforeClass;
@@ -88,8 +87,6 @@
         SpringBusFactory bf = new SpringBusFactory();
         
         bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy-old.xml");
-        PolicyTestUtils.setPolicyConstants(bus, 
-                                           PolicyConstants.NAMESPACE_W3_200607);
         
         BusFactory.setDefaultBus(bus);
         

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingOptionalPolicyTest.java Thu Sep  4 13:36:47 2008
@@ -38,7 +38,6 @@
 import org.apache.cxf.systest.ws.util.OutMessageRecorder;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.policy.selector.MinimalAlternativeSelector;
 import org.apache.cxf.ws.rm.RMUtils;
@@ -59,8 +58,6 @@
         protected void run()  {            
             SpringBusFactory bf = new SpringBusFactory();
             Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml");
-            PolicyTestUtils.setPolicyConstants(bus, 
-                                               PolicyConstants.NAMESPACE_W3_200607);
             BusFactory.setDefaultBus(bus);
             LoggingInInterceptor in = new LoggingInInterceptor();
             bus.getInInterceptors().add(in);
@@ -100,8 +97,6 @@
         SpringBusFactory bf = new SpringBusFactory();
         bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml");
         Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml");
-        PolicyTestUtils.setPolicyConstants(bus, 
-                                           PolicyConstants.NAMESPACE_W3_200607);
         BusFactory.setDefaultBus(bus);
         InMessageRecorder in = new InMessageRecorder();
         bus.getInInterceptors().add(in);

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java Thu Sep  4 13:36:47 2008
@@ -40,7 +40,6 @@
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.transport.http.HTTPConduit;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -111,9 +110,6 @@
         bus = bf.createBus(POLICY_ENGINE_ENABLED_CFG);
         BusFactory.setDefaultBus(bus);
         
-        PolicyTestUtils.setPolicyConstants(bus, 
-                                           PolicyConstants.NAMESPACE_W3_200607);
-        
         LoggingInInterceptor in = new LoggingInInterceptor();
         bus.getInInterceptors().add(in);
         bus.getInFaultInterceptors().add(in);

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java?rev=692229&r1=692228&r2=692229&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java Thu Sep  4 13:36:47 2008
@@ -39,7 +39,6 @@
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.ws.policy.PolicyAssertion;
-import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.rm.RMConstants;
 import org.apache.neethi.All;
@@ -123,8 +122,6 @@
     public void testUsingRM() throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
         bus = bf.createBus("org/apache/cxf/systest/ws/policy/rmwsdl.xml");
-        PolicyTestUtils.setPolicyConstants(bus, 
-                                           PolicyConstants.NAMESPACE_W3_200607);
         BusFactory.setDefaultBus(bus);
         OutMessageRecorder outRecorder = new OutMessageRecorder();
         bus.getOutInterceptors().add(outRecorder);



Mime
View raw message