cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r675332 [3/6] - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/helpers/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/ rt/ws/security/src/m...
Date Wed, 09 Jul 2008 20:11:48 GMT
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SignedPartsBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SignedPartsBuilder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SignedPartsBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SignedPartsBuilder.java Wed Jul  9 13:11:45 2008
@@ -1,69 +1,94 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
-import java.util.Iterator;
+import java.util.Arrays;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.Header;
-import org.apache.ws.secpolicy.model.SignedEncryptedParts;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.Header;
+import org.apache.cxf.ws.security.policy.model.SignedEncryptedParts;
+
 
 public class SignedPartsBuilder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.SIGNED_PARTS, SP12Constants.SIGNED_PARTS);
+    
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
+    }
+    
+    
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
         
-    public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-        SignedEncryptedParts signedEncryptedParts = new SignedEncryptedParts(true, SPConstants.SP_V11);
-        
-        for (Iterator iterator = element.getChildElements(); iterator.hasNext();) {
-            processElement((OMElement) iterator.next(), signedEncryptedParts);
+        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
+            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
+
+        SignedEncryptedParts signedEncryptedParts = new SignedEncryptedParts(true, consts);
+
+
+        Node nd = element.getFirstChild();
+        while (nd != null) {
+            if (nd instanceof Element) {
+                processElement((Element)nd, signedEncryptedParts);                
+            }
+            nd = nd.getNextSibling();
         }
         
         return signedEncryptedParts;
     }
-       
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.SIGNED_PARTS};
-    }
 
-    private void processElement(OMElement element, SignedEncryptedParts parent) {
-        
-        QName name = element.getQName();
-        
-        if (SP11Constants.HEADER.equals(name)) {
+
+    private void processElement(Element element, SignedEncryptedParts parent) {
+
+        if ("Header".equals(element.getLocalName())) {
             Header header = new Header();
-            
-            OMAttribute nameAttribute = element.getAttribute(SPConstants.NAME);
-            if( nameAttribute != null ) {
-                header.setName(nameAttribute.getAttributeValue());
+
+            String nameAttribute = element.getAttribute(SPConstants.NAME);
+            if (nameAttribute != null) {
+                header.setName(nameAttribute);
             }
-            
-            OMAttribute namespaceAttribute = element.getAttribute(SPConstants.NAMESPACE);
-            header.setNamespace(namespaceAttribute.getAttributeValue());
-            
+
+            String namespaceAttribute = element.getAttribute(SPConstants.NAMESPACE);
+            header.setNamespace(namespaceAttribute);
+
             parent.addHeader(header);
-            
-        } else if (SP11Constants.BODY.equals(name)) {
-            parent.setBody(true);            
-        }        
+
+        } else if ("Body".equals(element.getLocalName())) {
+            parent.setBody(true);
+        }
     }
+
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

Added: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java?rev=675332&view=auto
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java (added)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java Wed Jul  9 13:11:45 2008
@@ -0,0 +1,146 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.security.policy.builders;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants.SupportTokenType;
+import org.apache.cxf.ws.security.policy.model.AlgorithmSuite;
+import org.apache.cxf.ws.security.policy.model.SignedEncryptedElements;
+import org.apache.cxf.ws.security.policy.model.SignedEncryptedParts;
+import org.apache.cxf.ws.security.policy.model.SupportingToken;
+import org.apache.cxf.ws.security.policy.model.Token;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+
+public class SupportingTokens12Builder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP12Constants.SUPPORTING_TOKENS,
+                        SP12Constants.SIGNED_SUPPORTING_TOKENS,
+                        SP12Constants.ENDORSING_SUPPORTING_TOKENS,
+                        SP12Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS,
+                        SP12Constants.ENCRYPTED_SUPPORTING_TOKENS,
+                        SP12Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS,
+                        SP12Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS,
+                        SP12Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS  
+                        );
+
+
+    PolicyBuilder builder;
+    public SupportingTokens12Builder(PolicyBuilder b) {
+        builder = b;
+    }
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
+    }
+    
+    
+    public PolicyAssertion build(Element element) {
+        QName name = DOMUtils.getElementQName(element);
+        SupportingToken supportingToken = null;
+
+        if (SP12Constants.SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_SUPPORTING, SP12Constants.INSTANCE);
+        } else if (SP12Constants.SIGNED_SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_SIGNED, SP12Constants.INSTANCE);
+        } else if (SP12Constants.ENDORSING_SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_ENDORSING, SP12Constants.INSTANCE);
+        } else if (SP12Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENDORSING, SP12Constants.INSTANCE);
+        } else if (SP12Constants.ENCRYPTED_SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_ENCRYPTED, SP12Constants.INSTANCE);
+        } else if (SP12Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENCRYPTED, SP12Constants.INSTANCE);
+        } else if (SP12Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_ENDORSING_ENCRYPTED, SP12Constants.INSTANCE);
+        } else if (SP12Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) {
+            supportingToken = new SupportingToken(
+                    SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENDORSING_ENCRYPTED, SP12Constants.INSTANCE);
+        }
+
+        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
+        policy = (Policy) policy.normalize(false);
+
+        for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
+            processAlternative((List) iterator.next(), supportingToken);
+            /*
+             * for the moment we will say there should be only one alternative 
+             */
+            break;            
+        }
+
+        return supportingToken;
+    }
+
+
+    private void processAlternative(List assertions, SupportingToken supportingToken) {
+        
+        for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
+
+            Assertion primitive = (Assertion) iterator.next();
+            QName qname = primitive.getName();
+
+            if (SP12Constants.ALGORITHM_SUITE.equals(qname)) {
+                supportingToken.setAlgorithmSuite((AlgorithmSuite) primitive);
+
+            } else if (SP12Constants.SIGNED_PARTS.equals(qname)) {
+                supportingToken
+                        .setSignedParts((SignedEncryptedParts) primitive);
+
+            } else if (SP12Constants.SIGNED_ELEMENTS.equals(qname)) {
+                supportingToken
+                        .setSignedElements((SignedEncryptedElements) primitive);
+
+            } else if (SP12Constants.ENCRYPTED_PARTS.equals(qname)) {
+                supportingToken
+                        .setEncryptedParts((SignedEncryptedParts) primitive);
+
+            } else if (SP12Constants.ENCRYPTED_ELEMENTS.equals(qname)) {
+                supportingToken
+                        .setEncryptedElements((SignedEncryptedElements) primitive);
+
+            } else if (primitive instanceof Token) {
+                supportingToken.addToken((Token) primitive);
+            }
+        }
+    }
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokens12Builder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokensBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokensBuilder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokensBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SupportingTokensBuilder.java Wed Jul  9 13:11:45 2008
@@ -1,106 +1,130 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SPConstants.SupportTokenType;
+import org.apache.cxf.ws.security.policy.model.AlgorithmSuite;
+import org.apache.cxf.ws.security.policy.model.SignedEncryptedElements;
+import org.apache.cxf.ws.security.policy.model.SignedEncryptedParts;
+import org.apache.cxf.ws.security.policy.model.SupportingToken;
+import org.apache.cxf.ws.security.policy.model.Token;
 import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
 import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.AlgorithmSuite;
-import org.apache.ws.secpolicy.model.SignedEncryptedElements;
-import org.apache.ws.secpolicy.model.SignedEncryptedParts;
-import org.apache.ws.secpolicy.model.SupportingToken;
-import org.apache.ws.secpolicy.model.Token;
+
 
 public class SupportingTokensBuilder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.SUPPORTING_TOKENS, 
+                        SP11Constants.SIGNED_SUPPORTING_TOKENS,
+                        SP11Constants.ENDORSING_SUPPORTING_TOKENS,
+                        SP11Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS);
+
+    
+    PolicyBuilder builder;
+    public SupportingTokensBuilder(PolicyBuilder b) {
+        builder = b;
+    }
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
+    }
 
-    public Assertion build(OMElement element, AssertionBuilderFactory factory)
-            throws IllegalArgumentException {
-        QName name = element.getQName();
+    
+    
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
+        QName name = DOMUtils.getElementQName(element);
         SupportingToken supportingToken = null;
 
         if (SP11Constants.SUPPORTING_TOKENS.equals(name)) {
-            supportingToken = new SupportingToken(SPConstants.SUPPORTING_TOKEN_SUPPORTING, SPConstants.SP_V11);
+            supportingToken = new SupportingToken(SupportTokenType.SUPPORTING_TOKEN_SUPPORTING,
+                                                  SP11Constants.INSTANCE);
         } else if (SP11Constants.SIGNED_SUPPORTING_TOKENS.equals(name)) {
-            supportingToken = new SupportingToken(SPConstants.SUPPORTING_TOKEN_SIGNED, SPConstants.SP_V11);
+            supportingToken = new SupportingToken(SupportTokenType.SUPPORTING_TOKEN_SIGNED, 
+                                                  SP11Constants.INSTANCE);
         } else if (SP11Constants.ENDORSING_SUPPORTING_TOKENS.equals(name)) {
-            supportingToken = new SupportingToken(SPConstants.SUPPORTING_TOKEN_ENDORSING, SPConstants.SP_V11);
+            supportingToken = new SupportingToken(SupportTokenType.SUPPORTING_TOKEN_ENDORSING, 
+                                                  SP11Constants.INSTANCE);
         } else if (SP11Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS.equals(name)) {
-            supportingToken = new SupportingToken(SPConstants.SUPPORTING_TOKEN_SIGNED_ENDORSING, SPConstants.SP_V11);
+            supportingToken = new SupportingToken(SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENDORSING,
+                                                  SP11Constants.INSTANCE);
         }
 
-        Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
-        policy = (Policy) policy.normalize(false);
+        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
+        policy = (Policy)policy.normalize(false);
 
         for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
-            processAlternative((List) iterator.next(), supportingToken);
+            processAlternative((List)iterator.next(), supportingToken);
             /*
-             * for the moment we will say there should be only one alternative 
+             * for the moment we will say there should be only one alternative
              */
-            break;            
+            break;
         }
 
         return supportingToken;
     }
 
-    public QName[] getKnownElements() {
-        return new QName[] {  SP11Constants.SUPPORTING_TOKENS,
-                SP11Constants.SIGNED_SUPPORTING_TOKENS,
-                SP11Constants.ENDORSING_SUPPORTING_TOKENS,
-                SP11Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS};
-    }
 
     private void processAlternative(List assertions, SupportingToken supportingToken) {
-        
+
         for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
 
-            Assertion primitive = (Assertion) iterator.next();
+            Assertion primitive = (Assertion)iterator.next();
             QName qname = primitive.getName();
 
             if (SP11Constants.ALGORITHM_SUITE.equals(qname)) {
-                supportingToken.setAlgorithmSuite((AlgorithmSuite) primitive);
+                supportingToken.setAlgorithmSuite((AlgorithmSuite)primitive);
 
             } else if (SP11Constants.SIGNED_PARTS.equals(qname)) {
-                supportingToken
-                        .setSignedParts((SignedEncryptedParts) primitive);
+                supportingToken.setSignedParts((SignedEncryptedParts)primitive);
 
             } else if (SP11Constants.SIGNED_ELEMENTS.equals(qname)) {
-                supportingToken
-                        .setSignedElements((SignedEncryptedElements) primitive);
+                supportingToken.setSignedElements((SignedEncryptedElements)primitive);
 
             } else if (SP11Constants.ENCRYPTED_PARTS.equals(qname)) {
-                supportingToken
-                        .setEncryptedParts((SignedEncryptedParts) primitive);
+                supportingToken.setEncryptedParts((SignedEncryptedParts)primitive);
 
             } else if (SP11Constants.ENCRYPTED_ELEMENTS.equals(qname)) {
-                supportingToken
-                        .setEncryptedElements((SignedEncryptedElements) primitive);
+                supportingToken.setEncryptedElements((SignedEncryptedElements)primitive);
 
             } else if (primitive instanceof Token) {
-                supportingToken.addToken((Token) primitive);
+                supportingToken.addToken((Token)primitive);
             }
         }
     }
+
+
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SymmetricBindingBuilder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SymmetricBindingBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/SymmetricBindingBuilder.java Wed Jul  9 13:11:45 2008
@@ -1,92 +1,120 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.AlgorithmSuite;
+import org.apache.cxf.ws.security.policy.model.Layout;
+import org.apache.cxf.ws.security.policy.model.ProtectionToken;
+import org.apache.cxf.ws.security.policy.model.SymmetricBinding;
 import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
 import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.AlgorithmSuite;
-import org.apache.ws.secpolicy.model.Layout;
-import org.apache.ws.secpolicy.model.ProtectionToken;
-import org.apache.ws.secpolicy.model.SymmetricBinding;
 
-public class SymmetricBindingBuilder implements AssertionBuilder {
 
-    public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-        SymmetricBinding symmetricBinding = new SymmetricBinding(SPConstants.SP_V11); 
-        
-        Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
-        policy = (Policy) policy.normalize(false);
+public class SymmetricBindingBuilder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.SYMMETRIC_BINDING, SP12Constants.SYMMETRIC_BINDING);
+    
+    PolicyBuilder builder;
+    public SymmetricBindingBuilder(PolicyBuilder b) {
+        builder = b;
+    }
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
+    }
+    
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
         
+        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
+            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
+
+        SymmetricBinding symmetricBinding = new SymmetricBinding(consts);
+
+        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
+        policy = (Policy)policy.normalize(false);
+
         for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
-            processAlternatives((List) iterator.next(), symmetricBinding);
-            
+            processAlternatives((List)iterator.next(), symmetricBinding, consts);
+
             /*
              * since there should be only one alternative ..
              */
-            break; 
+            break;
         }
         return symmetricBinding;
     }
 
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.SYMMETRIC_BINDING};
-    }
-    
-    private void processAlternatives(List assertions, SymmetricBinding symmetricBinding) {
+
+    private void processAlternatives(List assertions, SymmetricBinding symmetricBinding, SPConstants consts) {
         Assertion assertion;
         QName name;
-        
+
         for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
-            assertion = (Assertion) iterator.next();
+            assertion = (Assertion)iterator.next();
             name = assertion.getName();
-            
-            if (SP11Constants.ALGORITHM_SUITE.equals(name)) {
-                symmetricBinding.setAlgorithmSuite((AlgorithmSuite) assertion);
-                
-            } else if (SP11Constants.LAYOUT.equals(name)) {
-                symmetricBinding.setLayout((Layout) assertion);
-                
-            } else if (SP11Constants.INCLUDE_TIMESTAMP.equals(name)) {
+
+            if (!consts.getNamespace().equals(name.getNamespaceURI())) {
+                continue;
+            }
+
+            if (SPConstants.ALGO_SUITE.equals(name.getLocalPart())) {
+                symmetricBinding.setAlgorithmSuite((AlgorithmSuite)assertion);
+
+            } else if (SPConstants.LAYOUT.equals(name.getLocalPart())) {
+                symmetricBinding.setLayout((Layout)assertion);
+
+            } else if (SPConstants.INCLUDE_TIMESTAMP.equals(name.getLocalPart())) {
                 symmetricBinding.setIncludeTimestamp(true);
-                
-            } else if (SP11Constants.PROTECTION_TOKEN.equals(name)) {
-                symmetricBinding.setProtectionToken((ProtectionToken) assertion);
-                
+
+            } else if (SPConstants.PROTECTION_TOKEN.equals(name.getLocalPart())) {
+                symmetricBinding.setProtectionToken((ProtectionToken)assertion);
+
             } else if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(name.getLocalPart())) {
                 symmetricBinding.setProtectionOrder(SPConstants.ENCRYPT_BEFORE_SIGNING);
-                
+
             } else if (SPConstants.SIGN_BEFORE_ENCRYPTING.equals(name.getLocalPart())) {
                 symmetricBinding.setProtectionOrder(SPConstants.SIGN_BEFORE_ENCRYPTING);
-                
+
             } else if (SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY.equals(name.getLocalPart())) {
                 symmetricBinding.setEntireHeadersAndBodySignatures(true);
-            } else if (SP11Constants.ENCRYPT_SIGNATURE.equals(name)) {
+            } else if (SPConstants.ENCRYPT_SIGNATURE.equals(name.getLocalPart())) {
                 symmetricBinding.setSignatureProtection(true);
             }
-        }        
+        }
+    }
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
     }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportBindingBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportBindingBuilder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportBindingBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportBindingBuilder.java Wed Jul  9 13:11:45 2008
@@ -1,88 +1,114 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.AlgorithmSuite;
+import org.apache.cxf.ws.security.policy.model.Layout;
+import org.apache.cxf.ws.security.policy.model.SupportingToken;
+import org.apache.cxf.ws.security.policy.model.TransportBinding;
+import org.apache.cxf.ws.security.policy.model.TransportToken;
 import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
 import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.AlgorithmSuite;
-import org.apache.ws.secpolicy.model.Layout;
-import org.apache.ws.secpolicy.model.SupportingToken;
-import org.apache.ws.secpolicy.model.TransportBinding;
-import org.apache.ws.secpolicy.model.TransportToken;
 
 public class TransportBindingBuilder implements AssertionBuilder {
- 
-    public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-        TransportBinding transportBinding = new TransportBinding(SPConstants.SP_V11);
-       
-        Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
-        policy = (Policy) policy.normalize(false);
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.TRANSPORT_BINDING, SP12Constants.TRANSPORT_BINDING);
+
+    
+    PolicyBuilder builder;
+    public TransportBindingBuilder(PolicyBuilder b) {
+        builder = b;
+    }
+    
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
         
+        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
+            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
+
+        TransportBinding transportBinding = new TransportBinding(consts);
+
+        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
+        policy = (Policy)policy.normalize(false);
+
         for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
-            processAlternative((List) iterator.next(), transportBinding, factory);
-            
+            processAlternative((List)iterator.next(), transportBinding, consts);
+
             /*
              * since there should be only one alternative
              */
-            break; 
+            break;
         }
-        
+
         return transportBinding;
     }
-    
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.TRANSPORT_BINDING};
+
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
     }
 
-    private void processAlternative(List assertionList, TransportBinding parent, AssertionBuilderFactory factory) {
-        
-        for (Iterator iterator = assertionList.iterator(); iterator.hasNext(); ) {
-            
-            Assertion primitive = (Assertion) iterator.next();
+    private void processAlternative(List assertionList, 
+                                    TransportBinding parent,
+                                    SPConstants consts) {
+
+        for (Iterator iterator = assertionList.iterator(); iterator.hasNext();) {
+
+            Assertion primitive = (Assertion)iterator.next();
             QName name = primitive.getName();
+
+            if (!consts.getNamespace().equals(name.getNamespaceURI())) {
+                continue;
+            }
             
-            if (name.equals(SP11Constants.ALGORITHM_SUITE)) {
-                parent.setAlgorithmSuite((AlgorithmSuite) primitive);
-                
-            } else if (name.equals(SP11Constants.TRANSPORT_TOKEN)) {
-                parent.setTransportToken(((TransportToken) primitive));
-                
-            } else if (name.equals(SP11Constants.INCLUDE_TIMESTAMP)) {
+            if (name.getLocalPart().equals(SPConstants.ALGO_SUITE)) {
+                parent.setAlgorithmSuite((AlgorithmSuite)primitive);
+            } else if (name.getLocalPart().equals(SPConstants.TRANSPORT_TOKEN)) {
+                parent.setTransportToken((TransportToken)primitive);
+            } else if (name.getLocalPart().equals(SPConstants.INCLUDE_TIMESTAMP)) {
                 parent.setIncludeTimestamp(true);
-                
-            } else if (name.equals(SP11Constants.LAYOUT)) {
-                parent.setLayout((Layout) primitive);
-                 
-            } else if (name.equals(SP11Constants.SIGNED_SUPPORTING_TOKENS)) {
-                parent.setSignedSupportingToken((SupportingToken) primitive);
-                
-            } else if (name.equals(SP11Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS)) {
-                parent.setSignedEndorsingSupportingTokens((SupportingToken) primitive);
+            } else if (name.getLocalPart().equals(SPConstants.LAYOUT)) {
+                parent.setLayout((Layout)primitive);
+            } else if (name.getLocalPart().equals(SPConstants.SIGNED_SUPPORTING_TOKENS)) {
+                parent.setSignedSupportingToken((SupportingToken)primitive);
+            } else if (name.getLocalPart().equals(SPConstants.SIGNED_ENDORSING_SUPPORTING_TOKENS)) {
+                parent.setSignedEndorsingSupportingTokens((SupportingToken)primitive);
             }
         }
     }
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportTokenBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportTokenBuilder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportTokenBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/TransportTokenBuilder.java Wed Jul  9 13:11:45 2008
@@ -1,74 +1,119 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.policy.builder.xml.XmlPrimitiveAssertion;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.HttpsToken;
+import org.apache.cxf.ws.security.policy.model.TransportToken;
 import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.neethi.builders.xml.XmlPrimtiveAssertion;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.HttpsToken;
-import org.apache.ws.secpolicy.model.TransportToken;
+
 
 public class TransportTokenBuilder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.TRANSPORT_TOKEN, SP12Constants.TRANSPORT_TOKEN);
+
     
-   
     
-    public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-        TransportToken transportToken = new TransportToken(SPConstants.SP_V11);
+    PolicyBuilder builder;
+    public TransportTokenBuilder(PolicyBuilder b) {
+        builder = b;
+    }
+    
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
         
-        Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
-        policy = (Policy) policy.normalize(false);
+        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
+            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
+
         
+        TransportToken transportToken = new TransportToken(consts);
+
+        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
+        policy = (Policy)policy.normalize(false);
+
         for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
-            processAlternative((List) iterator.next(), transportToken);
+            processAlternative((List)iterator.next(), transportToken);
             break; // since there should be only one alternative
         }
-        
+
         return transportToken;
     }
-        
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.TRANSPORT_TOKEN};
+
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
     }
-    
+
     private void processAlternative(List assertions, TransportToken parent) {
-        
+
         for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
-            XmlPrimtiveAssertion primtive = (XmlPrimtiveAssertion) iterator.next();
+            XmlPrimitiveAssertion primtive = (XmlPrimitiveAssertion)iterator.next();
             QName qname = primtive.getName();
-            
+
             if (SP11Constants.HTTPS_TOKEN.equals(qname)) {
-                HttpsToken httpsToken = new HttpsToken(SPConstants.SP_V11);
-                OMAttribute attr = primtive.getValue().getAttribute(SPConstants.REQUIRE_CLIENT_CERTIFICATE);
-                if(attr != null) {
-                    httpsToken.setRequireClientCertificate("true".equals(attr.getAttributeValue()));
+                HttpsToken httpsToken = new HttpsToken(SP11Constants.INSTANCE);
+                String attr = DOMUtils.getAttribute(primtive.getValue(),
+                                                    SPConstants.REQUIRE_CLIENT_CERTIFICATE);
+                if (attr != null) {
+                    httpsToken.setRequireClientCertificate("true".equals(attr));
                 }
                 parent.setToken(httpsToken);
+            } else if (SP12Constants.HTTPS_TOKEN.equals(qname)) {
+                HttpsToken httpsToken = new HttpsToken(SP12Constants.INSTANCE);
+                                 
+                Element element = DOMUtils.getFirstChildWithName(primtive.getValue(), SPConstants.POLICY);
+                 
+                if (element != null) {
+                    Element child = DOMUtils.getFirstElement(element);
+                    if (child != null) {
+                        if (SP12Constants.HTTP_BASIC_AUTHENTICATION.equals(DOMUtils.getElementQName(child))) {
+                            httpsToken.setHttpBasicAuthentication(true);
+                        } else if (SP12Constants.HTTP_DIGEST_AUTHENTICATION
+                                .equals(DOMUtils.getElementQName(child))) {
+                            httpsToken.setHttpDigestAuthentication(true);
+                        } else if (SP12Constants.REQUIRE_CLIENT_CERTIFICATE
+                                .equals(DOMUtils.getElementQName(child))) {
+                            httpsToken.setRequireClientCertificate(true);
+                        }
+                    }
+                }
             }
         }
     }
+
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust10Builder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust10Builder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust10Builder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust10Builder.java Wed Jul  9 13:11:45 2008
@@ -1,71 +1,85 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
+
+import java.util.Collections;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
-import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.Trust10;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.Trust10;
+
 
 public class Trust10Builder implements AssertionBuilder {
+    public Trust10Builder() {
+    }
+    
 
-    public Assertion build(OMElement element, AssertionBuilderFactory factory)
-            throws IllegalArgumentException {
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
 
-        element = element.getFirstChildWithName(SPConstants.POLICY);
+        element = DOMUtils.getFirstChildWithName(element, SPConstants.POLICY);
 
         if (element == null) {
-            throw new IllegalArgumentException(
-                    "Trust10 assertion doesn't contain any Policy");
+            throw new IllegalArgumentException("Trust10 assertion doesn't contain any Policy");
         }
+        
+        Trust10 trust10 = new Trust10(SP11Constants.INSTANCE);
 
-        Trust10 trust10 = new Trust10(SPConstants.SP_V11);
-
-        if (element
-                .getFirstChildWithName(SP11Constants.MUST_SUPPORT_CLIENT_CHALLENGE) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP11Constants.MUST_SUPPORT_CLIENT_CHALLENGE) != null) {
             trust10.setMustSupportClientChallenge(true);
         }
 
-        if (element
-                .getFirstChildWithName(SP11Constants.MUST_SUPPORT_SERVER_CHALLENGE) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP11Constants.MUST_SUPPORT_SERVER_CHALLENGE) != null) {
             trust10.setMustSupportServerChallenge(true);
         }
 
-        if (element.getFirstChildWithName(SP11Constants.REQUIRE_CLIENT_ENTROPY) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP11Constants.REQUIRE_CLIENT_ENTROPY) != null) {
             trust10.setRequireClientEntropy(true);
         }
 
-        if (element.getFirstChildWithName(SP11Constants.REQUIRE_SERVER_ENTROPY) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP11Constants.REQUIRE_SERVER_ENTROPY) != null) {
             trust10.setRequireServerEntropy(true);
         }
 
-        if (element.getFirstChildWithName(SP11Constants.MUST_SUPPORT_ISSUED_TOKENS) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP11Constants.MUST_SUPPORT_ISSUED_TOKENS) != null) {
             trust10.setMustSupportIssuedTokens(true);
         }
 
         return trust10;
     }
 
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.TRUST_10};
+    public List<QName> getKnownElements() {
+        return Collections.singletonList(SP11Constants.TRUST_10);
+    }
+
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
     }
 
 }

Copied: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust13Builder.java (from r674910, webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/Trust13Builder.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust13Builder.java?p2=cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust13Builder.java&p1=webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/Trust13Builder.java&r1=674910&r2=675332&rev=675332&view=diff
==============================================================================
--- webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy12/builders/Trust13Builder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust13Builder.java Wed Jul  9 13:11:45 2008
@@ -1,79 +1,90 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy12.builders;
+package org.apache.cxf.ws.security.policy.builders;
+
+import java.util.Collections;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
-import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.model.Trust13;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.Trust13;
+
 
 public class Trust13Builder implements AssertionBuilder {
 
-    public Assertion build(OMElement element, AssertionBuilderFactory factory)
-            throws IllegalArgumentException {
+    public PolicyAssertion build(Element element) {
 
-        element = element.getFirstChildWithName(SPConstants.POLICY);
+        element = DOMUtils.getFirstChildWithName(element, SPConstants.POLICY);
 
         if (element == null) {
             throw new IllegalArgumentException(
                     "Trust10 assertion doesn't contain any Policy");
         }
 
-        Trust13 trust13 = new Trust13(SPConstants.SP_V12);
+        Trust13 trust13 = new Trust13(SP12Constants.INSTANCE);
 
-        if (element
-                .getFirstChildWithName(SP12Constants.MUST_SUPPORT_CLIENT_CHALLENGE) != null) {
+        if (DOMUtils
+                .getFirstChildWithName(element, SP12Constants.MUST_SUPPORT_CLIENT_CHALLENGE) != null) {
             trust13.setMustSupportClientChallenge(true);
         }
 
-        if (element
-                .getFirstChildWithName(SP12Constants.MUST_SUPPORT_SERVER_CHALLENGE) != null) {
+        if (DOMUtils
+                .getFirstChildWithName(element, SP12Constants.MUST_SUPPORT_SERVER_CHALLENGE) != null) {
             trust13.setMustSupportServerChallenge(true);
         }
 
-        if (element.getFirstChildWithName(SP12Constants.REQUIRE_CLIENT_ENTROPY) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP12Constants.REQUIRE_CLIENT_ENTROPY) != null) {
             trust13.setRequireClientEntropy(true);
         }
 
-        if (element.getFirstChildWithName(SP12Constants.REQUIRE_SERVER_ENTROPY) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP12Constants.REQUIRE_SERVER_ENTROPY) != null) {
             trust13.setRequireServerEntropy(true);
         }
 
-        if (element.getFirstChildWithName(SP12Constants.MUST_SUPPORT_ISSUED_TOKENS) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP12Constants.MUST_SUPPORT_ISSUED_TOKENS) != null) {
             trust13.setMustSupportIssuedTokens(true);
         }
         
-        if (element.getFirstChildWithName(SP12Constants.REQUIRE_REQUEST_SECURITY_TOKEN_COLLECTION) != null) {
+        if (DOMUtils.getFirstChildWithName(element,
+                                           SP12Constants.REQUIRE_REQUEST_SECURITY_TOKEN_COLLECTION) != null) {
             trust13.setRequireRequestSecurityTokenCollection(true);
         }
         
-        if (element.getFirstChildWithName(SP12Constants.REQUIRE_APPLIES_TO) != null) {
+        if (DOMUtils.getFirstChildWithName(element, SP12Constants.REQUIRE_APPLIES_TO) != null) {
             trust13.setRequireAppliesTo(true);
         }
 
         return trust13;
     }
-
-    public QName[] getKnownElements() {
-        return new QName[] {SP12Constants.TRUST_13};
+    public List<QName> getKnownElements() {
+        return Collections.singletonList(SP12Constants.TRUST_13);
+    }
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
     }
 
 }

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust13Builder.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/Trust13Builder.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/UsernameTokenBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/UsernameTokenBuilder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/UsernameTokenBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/UsernameTokenBuilder.java Wed Jul  9 13:11:45 2008
@@ -1,85 +1,118 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.UsernameToken;
 import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
 import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.UsernameToken;
+
 
 public class UsernameTokenBuilder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.USERNAME_TOKEN, SP12Constants.USERNAME_TOKEN);
 
+    PolicyBuilder builder;
+    public UsernameTokenBuilder(PolicyBuilder b) {
+        builder = b;
+    }
     
-    public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException {
-        UsernameToken usernameToken = new UsernameToken(SPConstants.SP_V11);
-        
-        OMAttribute attribute = element.getAttribute(SP11Constants.INCLUDE_TOKEN);
+    public PolicyAssertion build(Element element) {
         
-        if(attribute != null) {
-            int inclusion = SP11Constants.getInclusionFromAttributeValue(attribute.getAttributeValue());
-            usernameToken.setInclusion(inclusion);
+        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
+            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
+
+        UsernameToken usernameToken = new UsernameToken(consts);
+
+        String attribute = DOMUtils.getAttribute(element, SP11Constants.INCLUDE_TOKEN);
+        if (attribute != null) {
+            usernameToken.setInclusion(consts.getInclusionFromAttributeValue(attribute));
         }
-        
-        OMElement policyElement = element.getFirstElement();
-        
-        if (policyElement != null && !policyElement.getQName().equals(org.apache.neethi.Constants.Q_ELEM_POLICY)) {
-        
-            Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
-            policy = (Policy) policy.normalize(false);
-            
+
+        Element policyElement = DOMUtils.getFirstElement(element);
+
+        if (policyElement != null) {
+
+            Policy policy = builder.getPolicy(policyElement);
+            policy = (Policy)policy.normalize(false);
+
             for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
-                processAlternative((List) iterator.next(), usernameToken);
-                
+                processAlternative((List)iterator.next(), usernameToken, consts);
+
                 /*
                  * since there should be only one alternative
                  */
                 break;
-            }            
+            }
         }
-        
+
         return usernameToken;
     }
-        
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.USERNAME_TOKEN};
+
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
     }
 
-    private void processAlternative(List assertions, UsernameToken parent) {
-                
+    private void processAlternative(List assertions, UsernameToken parent, SPConstants consts) {
+
         for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
-            Assertion assertion = (Assertion) iterator.next();
+            Assertion assertion = (Assertion)iterator.next();
             QName qname = assertion.getName();
+
+            if (!consts.getNamespace().equals(qname.getNamespaceURI())) {
+                continue;
+            }
             
-            if (SP11Constants.WSS_USERNAME_TOKEN10.equals(qname)) {
+            if (SPConstants.USERNAME_TOKEN10.equals(qname.getLocalPart())) {
                 parent.setUseUTProfile10(true);
-                
-            } else if (SP11Constants.WSS_USERNAME_TOKEN11.equals(qname)) {
+            } else if (SPConstants.USERNAME_TOKEN11.equals(qname.getLocalPart())) {
                 parent.setUseUTProfile11(true);
+            } else if (SP12Constants.NO_PASSWORD.equals(qname)) {
+                parent.setNoPassword(true);
+            } else if (SP12Constants.HASH_PASSWORD.equals(qname)) {
+                parent.setHashPassword(true);
+            } else if (SP12Constants.REQUIRE_DERIVED_KEYS.equals(qname)) {
+                parent.setDerivedKeys(true);
+            } else if (SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS.equals(qname)) {
+                parent.setExplicitDerivedKeys(true);
+            } else if (SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS.equals(qname)) {
+                parent.setImpliedDerivedKeys(true);
             }
         }
     }
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS10Builder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS10Builder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS10Builder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS10Builder.java Wed Jul  9 13:11:45 2008
@@ -1,81 +1,106 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.Wss10;
 import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
 import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.Wss10;
+
 
 public class WSS10Builder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.WSS10, SP12Constants.WSS10);
+    
+    PolicyBuilder builder;
+    public WSS10Builder(PolicyBuilder b) {
+        builder = b;
+    }
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
+    }
+    
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
 
-    public Assertion build(OMElement element, AssertionBuilderFactory factory)
-            throws IllegalArgumentException {
-        
-        Wss10 wss10 = new Wss10(SPConstants.SP_V11);
-        
-        Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
-        policy = (Policy) policy.normalize(false);
+        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
+            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
         
+        Wss10 wss10 = new Wss10(consts);
+
+        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
+        policy = (Policy)policy.normalize(false);
+
         for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
-            processAlternative((List) iterator.next(), wss10);
+            processAlternative((List)iterator.next(), wss10, consts);
             /*
              * since there should be only one alternative
              */
             break;
         }
-        
+
         return wss10;
     }
 
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.WSS10};
-    }
-    
-    private void processAlternative(List assertions, Wss10 parent) {
-        
+    private void processAlternative(List assertions, Wss10 parent, SPConstants consts) {
+
         Assertion assertion;
         QName name;
-        
-        for (Iterator iterator = assertions.iterator(); iterator.hasNext(); ) {
-            assertion = (Assertion) iterator.next();
+
+        for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
+            assertion = (Assertion)iterator.next();
             name = assertion.getName();
-            
-            if (SP11Constants.MUST_SUPPORT_REF_KEY_IDENTIFIER.equals(name)) {
+
+            if (!consts.getNamespace().equals(name.getNamespaceURI())) {
+                continue;
+            }
+            if (SPConstants.MUST_SUPPORT_REF_KEY_IDENTIFIER.equals(name.getLocalPart())) {
                 parent.setMustSupportRefKeyIdentifier(true);
-                
-            } else if (SP11Constants.MUST_SUPPORT_REF_ISSUER_SERIAL.equals(name)) {
+
+            } else if (SPConstants.MUST_SUPPORT_REF_ISSUER_SERIAL.equals(name.getLocalPart())) {
                 parent.setMustSupportRefIssuerSerial(true);
-                
-            } else if (SP11Constants.MUST_SUPPORT_REF_EXTERNAL_URI.equals(name)) {
+
+            } else if (SPConstants.MUST_SUPPORT_REF_EXTERNAL_URI.equals(name.getLocalPart())) {
                 parent.setMustSupportRefExternalURI(true);
-                
-            } else if (SP11Constants.MUST_SUPPORT_REF_EMBEDDED_TOKEN.equals(name)) {
+
+            } else if (SPConstants.MUST_SUPPORT_REF_EMBEDDED_TOKEN.equals(name.getLocalPart())) {
                 parent.setMustSupportRefEmbeddedToken(true);
             }
         }
     }
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS11Builder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS11Builder.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS11Builder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/WSS11Builder.java Wed Jul  9 13:11:45 2008
@@ -1,46 +1,65 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.ws.secpolicy11.builders;
+package org.apache.cxf.ws.security.policy.builders;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.model.Wss11;
 import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
 import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.model.Wss11;
+
 
 public class WSS11Builder implements AssertionBuilder {
+    private static final List<QName> KNOWN_ELEMENTS 
+        = Arrays.asList(SP11Constants.WSS11, SP12Constants.WSS11);
+
+    PolicyBuilder builder;
+    public WSS11Builder(PolicyBuilder b) {
+        builder = b;
+    }
 
-    public Assertion build(OMElement element, AssertionBuilderFactory factory)
-            throws IllegalArgumentException {
-        Wss11 wss11 = new Wss11(SPConstants.SP_V11);
+    
+    
+    public PolicyAssertion build(Element element)
+        throws IllegalArgumentException {
+        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
+            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
+        Wss11 wss11 = new Wss11(consts);
 
-        Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
-        policy = (Policy) policy.normalize(false);
+        Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
+        policy = (Policy)policy.normalize(false);
 
         for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
-            processAlternative((List) iterator.next(), wss11);
+            processAlternative((List)iterator.next(), wss11, consts);
             /*
              * since there should be only one alternative
              */
@@ -50,40 +69,49 @@
         return wss11;
     }
 
-    public QName[] getKnownElements() {
-        return new QName[] {SP11Constants.WSS11};
+    public List<QName> getKnownElements() {
+        return KNOWN_ELEMENTS;
     }
 
-    private void processAlternative(List assertions, Wss11 parent) {
-        
+    private void processAlternative(List assertions, Wss11 parent, SPConstants consts) {
+
         Assertion assertion;
         QName name;
 
         for (Iterator iterator = assertions.iterator(); iterator.hasNext();) {
-            assertion = (Assertion) iterator.next();
+            assertion = (Assertion)iterator.next();
             name = assertion.getName();
 
-            if (SP11Constants.MUST_SUPPORT_REF_KEY_IDENTIFIER.equals(name)) {
+            if (!consts.getNamespace().equals(name.getNamespaceURI())) {
+                continue;
+            }
+
+            if (SPConstants.MUST_SUPPORT_REF_KEY_IDENTIFIER.equals(name.getLocalPart())) {
                 parent.setMustSupportRefKeyIdentifier(true);
 
-            } else if (SP11Constants.MUST_SUPPORT_REF_ISSUER_SERIAL.equals(name)) {
+            } else if (SPConstants.MUST_SUPPORT_REF_ISSUER_SERIAL.equals(name.getLocalPart())) {
                 parent.setMustSupportRefIssuerSerial(true);
 
-            } else if (SP11Constants.MUST_SUPPORT_REF_EXTERNAL_URI.equals(name)) {
+            } else if (SPConstants.MUST_SUPPORT_REF_EXTERNAL_URI.equals(name.getLocalPart())) {
                 parent.setMustSupportRefExternalURI(true);
 
-            } else if (SP11Constants.MUST_SUPPORT_REF_EMBEDDED_TOKEN.equals(name)) {
+            } else if (SPConstants.MUST_SUPPORT_REF_EMBEDDED_TOKEN.equals(name.getLocalPart())) {
                 parent.setMustSupportRefEmbeddedToken(true);
-                
-            } else if (SP11Constants.MUST_SUPPORT_REF_THUMBPRINT.equals(name)) {
+
+            } else if (SPConstants.MUST_SUPPORT_REF_THUMBPRINT.equals(name.getLocalPart())) {
                 parent.setMustSupportRefThumbprint(true);
-                
-            } else if (SP11Constants.MUST_SUPPORT_REF_ENCRYPTED_KEY.equals(name)) {
+
+            } else if (SPConstants.MUST_SUPPORT_REF_ENCRYPTED_KEY.equals(name.getLocalPart())) {
                 parent.setMustSupportRefEncryptedKey(true);
-                
-            } else if (SP11Constants.REQUIRE_SIGNATURE_CONFIRMATION.equals(name)) {
+
+            } else if (SPConstants.REQUIRE_SIGNATURE_CONFIRMATION.equals(name.getLocalPart())) {
                 parent.setRequireSignatureConfirmation(true);
             }
         }
     }
+
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }



Mime
View raw message