You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by gi...@apache.org on 2011/09/18 15:51:36 UTC

svn commit: r1172285 [7/48] - in /webservices/wss4j/branches/swssf: ./ cxf-integration/ cxf-integration/src/ cxf-integration/src/main/ cxf-integration/src/main/java/ cxf-integration/src/main/java/org/ cxf-integration/src/main/java/org/swssf/ cxf-integr...

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ProtectionToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ProtectionToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ProtectionToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ProtectionToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,144 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public class ProtectionToken extends AbstractSecurityAssertion implements TokenWrapper {
+
+    private Token protectionToken;
+
+    public ProtectionToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the protectionToken.
+     */
+    public Token getProtectionToken() {
+        return protectionToken;
+    }
+
+    /**
+     * @param protectionToken The protectionToken to set.
+     */
+    public void setProtectionToken(Token protectionToken) {
+        this.protectionToken = protectionToken;
+    }
+
+    public void setToken(Token tok) {
+        this.setProtectionToken(tok);
+    }
+
+    public QName getName() {
+        return spConstants.getProtectionToken();
+    }
+
+    public PolicyComponent normalize() {
+        /*
+         *  ProtectionToken can not contain multiple values. Hence we consider it
+         *  to always be in the normalized format.
+         */
+        return this;
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        String localname = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix;
+
+        String writerPrefix = writer.getPrefix(namespaceURI);
+        if (writerPrefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:ProtectionToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+        String policyLocalName = SPConstants.POLICY.getLocalPart();
+        String policyNamespaceURI = SPConstants.POLICY.getNamespaceURI();
+
+        String wspPrefix;
+
+        String wspWriterPrefix = writer.getPrefix(policyNamespaceURI);
+
+        if (wspWriterPrefix == null) {
+            wspPrefix = SPConstants.POLICY.getPrefix();
+            writer.setPrefix(wspPrefix, policyNamespaceURI);
+        } else {
+            wspPrefix = wspWriterPrefix;
+        }
+
+        // <wsp:Policy>
+        writer.writeStartElement(wspPrefix, policyLocalName, policyNamespaceURI);
+
+        if (wspWriterPrefix == null) {
+            // xmlns:wsp=".."
+            writer.writeNamespace(wspPrefix, policyNamespaceURI);
+        }
+
+        if (protectionToken == null) {
+            throw new RuntimeException("ProtectionToken is not set");
+        }
+
+        protectionToken.serialize(writer);
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:ProtectionToken>
+        writer.writeEndElement();
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        //todo
+        return new SecurityEvent.Event[0];
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        //todo
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ProtectionToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RecipientToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RecipientToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RecipientToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RecipientToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,133 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public class RecipientToken extends AbstractSecurityAssertion implements TokenWrapper {
+
+    private Token receipientToken;
+
+    public RecipientToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the receipientToken.
+     */
+    public Token getReceipientToken() {
+        return receipientToken;
+    }
+
+    /**
+     * @param receipientToken The receipientToken to set.
+     */
+    public void setReceipientToken(Token receipientToken) {
+        this.receipientToken = receipientToken;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ws.security.policy.TokenWrapper#setToken(org.apache.ws.security.policy.Token)
+     */
+
+    public void setToken(Token tok) {
+        this.setReceipientToken(tok);
+    }
+
+    public QName getName() {
+        return spConstants.getRecipientToken();
+    }
+
+    public PolicyComponent normalize() {
+        throw new UnsupportedOperationException();
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        String localName = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix = writer.getPrefix(namespaceURI);
+
+        if (prefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        }
+
+        // <sp:RecipientToken>
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+        String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
+        if (pPrefix == null) {
+            pPrefix = SPConstants.POLICY.getPrefix();
+            writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI());
+        }
+
+        // <wsp:Policy>
+        writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
+
+        Token token = getReceipientToken();
+        if (token == null) {
+            throw new RuntimeException("RecipientToken doesn't contain any token assertions");
+        }
+        token.serialize(writer);
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:RecipientToken>
+        writer.writeEndElement();
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{SecurityEvent.Event.EncryptionToken};
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        if (receipientToken != null) {
+            receipientToken.setResponsibleAssertionEvents(getResponsibleAssertionEvents());
+            receipientToken.getAssertions(assertionStateMap, operationPolicy);
+        }
+    }
+
+    @Override
+    public boolean isAsserted(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap) {
+        boolean isAsserted = super.isAsserted(assertionStateMap);
+        if (receipientToken != null) {
+            isAsserted &= receipientToken.isAsserted(assertionStateMap);
+        }
+        return isAsserted;
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RecipientToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredElements.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredElements.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredElements.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredElements.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,169 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.assertionStates.RequiredElementAssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.*;
+
+/**
+ * class lent from apache rampart
+ */
+public class RequiredElements extends AbstractSecurityAssertion {
+
+    private List<String> xPathExpressions = new ArrayList<String>();
+
+    private Map<String, String> declaredNamespaces = new HashMap<String, String>();
+
+    private String xPathVersion;
+
+    public RequiredElements(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the xPathExpressions.
+     */
+    public List<String> getXPathExpressions() {
+        return xPathExpressions;
+    }
+
+    public void addXPathExpression(String expr) {
+        this.xPathExpressions.add(expr);
+    }
+
+    /**
+     * @return Returns the xPathVersion.
+     */
+    public String getXPathVersion() {
+        return xPathVersion;
+    }
+
+    /**
+     * @param pathVersion The xPathVersion to set.
+     */
+    public void setXPathVersion(String pathVersion) {
+        xPathVersion = pathVersion;
+    }
+
+    public Map<String, String> getDeclaredNamespaces() {
+        return declaredNamespaces;
+    }
+
+    public void addDeclaredNamespaces(String uri, String prefix) {
+        declaredNamespaces.put(prefix, uri);
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+
+        String localName = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix;
+        String writerPrefix = writer.getPrefix(namespaceURI);
+
+        if (writerPrefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        } else {
+            prefix = writerPrefix;
+        }
+
+        //  <sp:RequiredElements>
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+        // xmlns:sp=".."
+        writer.writeNamespace(prefix, namespaceURI);
+
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+        if (xPathVersion != null) {
+            writer.writeAttribute(prefix, namespaceURI, SPConstants.XPATH_VERSION, xPathVersion);
+        }
+
+        String xpathExpression;
+
+        for (Iterator<String> iterator = xPathExpressions.iterator(); iterator
+                .hasNext(); ) {
+            xpathExpression = iterator.next();
+            // <sp:XPath ..>
+            writer.writeStartElement(prefix, SPConstants.XPATH_EXPR, namespaceURI);
+            writer.writeCharacters(xpathExpression);
+            writer.writeEndElement();
+        }
+
+        //</sp:RequiredElements>
+        writer.writeEndElement();
+    }
+
+    public QName getName() {
+        return spConstants.getRequiredElements();
+    }
+
+    public PolicyComponent normalize() {
+        return this;
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{SecurityEvent.Event.RequiredElement};
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        Map<Assertion, List<AssertionState>> requiredElementAssertionStates = assertionStateMap.get(SecurityEvent.Event.RequiredElement);
+        List<QName> qNames = getQNamesFromXPath();
+        for (int i = 0; i < qNames.size(); i++) {
+            QName qName = qNames.get(i);
+            addAssertionState(requiredElementAssertionStates, this, new RequiredElementAssertionState(this, false, qName));
+        }
+    }
+
+    private List<QName> getQNamesFromXPath() {
+        List<QName> qNames = new ArrayList<QName>(xPathExpressions.size());
+        for (int i = 0; i < xPathExpressions.size(); i++) {
+            String s = xPathExpressions.get(i);
+            String prefix;
+            String localName;
+            if (s.contains(":")) {
+                int idx = s.indexOf(":");
+                prefix = s.substring(0, idx);
+                localName = s.substring(idx + 1);
+            } else {
+                prefix = "";
+                localName = s;
+            }
+            qNames.add(new QName(declaredNamespaces.get(prefix), localName));
+        }
+        return qNames;
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredElements.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredParts.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredParts.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredParts.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredParts.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,135 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.assertionStates.RequiredPartAssertionState;
+import org.swssf.policy.secpolicy.SP12Constants;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public class RequiredParts extends AbstractSecurityAssertion {
+
+    private List<Header> headers = new ArrayList<Header>();
+
+    public RequiredParts(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the headers.
+     */
+    public List<Header> getHeaders() {
+        return this.headers;
+    }
+
+    /**
+     * @param header The headers to set.
+     */
+    public void addHeader(Header header) {
+        this.headers.add(header);
+    }
+
+
+    public QName getName() {
+        return SP12Constants.REQUIRED_PARTS;
+    }
+
+    public PolicyComponent normalize() {
+        return this;
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        String localName = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix = writer.getPrefix(namespaceURI);
+
+        if (prefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        }
+
+        // <sp:RequiredParts> 
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+        // xmlns:sp=".."
+        writer.writeNamespace(prefix, namespaceURI);
+
+        Header header;
+        for (Iterator iterator = headers.iterator(); iterator.hasNext(); ) {
+            header = (Header) iterator.next();
+            // <sp:Header Name=".." Namespace=".." />
+            writer.writeStartElement(prefix, SPConstants.HEADER, namespaceURI);
+            // Name attribute is optional
+            if (header.getName() != null) {
+                writer.writeAttribute("Name", header.getName());
+            }
+            writer.writeAttribute("Namespace", header.getNamespace());
+
+            writer.writeEndElement();
+        }
+
+        // </sp:RequiredParts>
+        writer.writeEndElement();
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{SecurityEvent.Event.RequiredPart};
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        Map<Assertion, List<AssertionState>> requiredPartsAssertionStates = assertionStateMap.get(SecurityEvent.Event.RequiredPart);
+        List<QName> qNames = getQNamesFromHeaders();
+        for (int i = 0; i < qNames.size(); i++) {
+            QName qName = qNames.get(i);
+            addAssertionState(requiredPartsAssertionStates, this, new RequiredPartAssertionState(this, false, qName));
+        }
+    }
+
+    private List<QName> getQNamesFromHeaders() {
+        List<QName> qNames = new ArrayList<QName>(headers.size());
+        for (int i = 0; i < headers.size(); i++) {
+            Header header = headers.get(i);
+            String localName = header.getName();
+            if (localName == null) {
+                localName = "*";
+            }
+            qNames.add(new QName(header.getNamespace(), localName));
+        }
+        return qNames;
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/RequiredParts.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SamlToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SamlToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SamlToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SamlToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,151 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache cxf
+ */
+public class SamlToken extends Token {
+
+    private boolean useSamlVersion11Profile10;
+    private boolean useSamlVersion11Profile11;
+    private boolean useSamlVersion20Profile11;
+    private boolean requireKeyIdentifierReference;
+
+    public SamlToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    public boolean isUseSamlVersion11Profile10() {
+        return useSamlVersion11Profile10;
+    }
+
+    public void setUseSamlVersion11Profile10(boolean useSamlVersion11Profile10) {
+        this.useSamlVersion11Profile10 = useSamlVersion11Profile10;
+    }
+
+    public boolean isUseSamlVersion11Profile11() {
+        return useSamlVersion11Profile11;
+    }
+
+    public void setUseSamlVersion11Profile11(boolean useSamlVersion11Profile11) {
+        this.useSamlVersion11Profile11 = useSamlVersion11Profile11;
+    }
+
+    public boolean isUseSamlVersion20Profile11() {
+        return useSamlVersion20Profile11;
+    }
+
+    public void setUseSamlVersion20Profile11(boolean useSamlVersion20Profile11) {
+        this.useSamlVersion20Profile11 = useSamlVersion20Profile11;
+    }
+
+    public boolean isRequireKeyIdentifierReference() {
+        return requireKeyIdentifierReference;
+    }
+
+    public void setRequireKeyIdentifierReference(boolean requireKeyIdentifierReference) {
+        this.requireKeyIdentifierReference = requireKeyIdentifierReference;
+    }
+
+    public QName getName() {
+        return spConstants.getSamlToken();
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        String localname = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix = writer.getPrefix(namespaceURI);
+        if (prefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        }
+
+        // <sp:SamlToken
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        writer.writeNamespace(prefix, namespaceURI);
+
+        String inclusion;
+
+        inclusion = spConstants.getAttributeValueFromInclusion(getInclusion());
+
+        if (inclusion != null) {
+            writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
+        }
+
+        if (isUseSamlVersion11Profile10() || isUseSamlVersion11Profile11()
+                || isUseSamlVersion20Profile11()) {
+            String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
+            if (pPrefix == null) {
+                pPrefix = SPConstants.POLICY.getPrefix();
+                writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
+            }
+
+            // <wsp:Policy>
+            writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
+                    .getNamespaceURI());
+
+            // CHECKME
+            if (isUseSamlVersion11Profile10()) {
+                // <sp:WssSamlV11Token10 />
+                writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_10, namespaceURI);
+            } else if (isUseSamlVersion11Profile11()) {
+                // <sp:WssSamlV11Token11 />
+                writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_11, namespaceURI);
+            } else {
+                // <sp:WssSamlV20Token11 />
+                writer.writeStartElement(prefix, SPConstants.SAML_20_TOKEN_11, namespaceURI);
+            }
+
+            writer.writeEndElement();
+
+            // </wsp:Policy>
+            writer.writeEndElement();
+
+        }
+
+        writer.writeEndElement();
+        // </sp:SamlToken>
+
+    }
+
+    @Override
+    public QName getXmlName() {
+        return null;
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        //todo
+    }
+}

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecureConversationToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecureConversationToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecureConversationToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecureConversationToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,191 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.neethi.Policy;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Model class of SecureConversationToken assertion
+ */
+
+/**
+ * class lent from apache rampart
+ */
+public class SecureConversationToken extends SecurityContextToken {
+
+    private Policy bootstrapPolicy;
+
+    private OMElement issuerEpr;
+
+    public SecureConversationToken(SPConstants spConstants) {
+        super(spConstants);
+    }
+
+    /**
+     * @return Returns the bootstrapPolicy.
+     */
+    public Policy getBootstrapPolicy() {
+        return bootstrapPolicy;
+    }
+
+    /**
+     * @param bootstrapPolicy The bootstrapPolicy to set.
+     */
+    public void setBootstrapPolicy(Policy bootstrapPolicy) {
+        this.bootstrapPolicy = bootstrapPolicy;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.neethi.Assertion#getName()
+     */
+
+    public QName getName() {
+        return spConstants.getSecureConversationToken();
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+
+        String localname = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+        String prefix;
+
+        String writerPrefix = writer.getPrefix(namespaceURI);
+
+        if (writerPrefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:SecureConversationToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+        String inclusion = spConstants.getAttributeValueFromInclusion(getInclusion());
+
+        if (inclusion != null) {
+            writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
+        }
+
+        if (issuerEpr != null) {
+            // <sp:Issuer>
+            writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI);
+
+            issuerEpr.serialize(writer);
+
+            writer.writeEndElement();
+        }
+
+        if (isDerivedKeys() || isRequireExternalUriRef()
+                || isSc10SecurityContextToken() || (bootstrapPolicy != null)) {
+
+            String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI();
+
+            String wspPrefix;
+
+            String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);
+
+            if (wspWriterPrefix == null) {
+                wspPrefix = SPConstants.POLICY.getPrefix();
+                writer.setPrefix(wspPrefix, wspNamespaceURI);
+
+            } else {
+                wspPrefix = wspWriterPrefix;
+            }
+
+            // <wsp:Policy>
+            writer.writeStartElement(wspPrefix,
+                    SPConstants.POLICY.getLocalPart(), wspNamespaceURI);
+
+            if (wspWriterPrefix == null) {
+                // xmlns:wsp=".."
+                writer.writeNamespace(wspPrefix, wspNamespaceURI);
+            }
+
+            if (isDerivedKeys()) {
+                // <sp:RequireDerivedKeys />
+                writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
+            }
+
+            if (isRequireExternalUriRef()) {
+                // <sp:RequireExternalUriReference />
+                writer.writeEmptyElement(prefix, SPConstants.REQUIRE_EXTERNAL_URI_REFERNCE, namespaceURI);
+            }
+
+            if (isSc10SecurityContextToken()) {
+                // <sp:SC10SecurityContextToken />
+                writer.writeEmptyElement(prefix, SPConstants.SC10_SECURITY_CONTEXT_TOKEN, namespaceURI);
+            }
+
+            if (bootstrapPolicy != null) {
+                // <sp:BootstrapPolicy ..>
+                writer.writeStartElement(prefix, SPConstants.BOOTSTRAP_POLICY, namespaceURI);
+                bootstrapPolicy.serialize(writer);
+                writer.writeEndElement();
+            }
+
+            // </wsp:Policy>
+            writer.writeEndElement();
+        }
+
+        // </sp:SecureConversationToken>
+        writer.writeEndElement();
+    }
+
+    /**
+     * @return Returns the issuerEpr.
+     */
+    public OMElement getIssuerEpr() {
+        return issuerEpr;
+    }
+
+    /**
+     * @param issuerEpr The issuerEpr to set.
+     */
+    public void setIssuerEpr(OMElement issuerEpr) {
+        this.issuerEpr = issuerEpr;
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        //todo
+        return new SecurityEvent.Event[0];
+    }
+
+    /*
+    @Override
+    public void assertPolicy(SecurityEvent securityEvent) {
+    }
+    */
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecureConversationToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecurityContextToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecurityContextToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecurityContextToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,115 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Model class of SecurityContextToken assertion
+ */
+
+/**
+ * class lent from apache rampart
+ */
+public class SecurityContextToken extends Token {
+
+    boolean requireExternalUriRef;
+
+    boolean sc10SecurityContextToken;
+
+    public SecurityContextToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the requireExternalUriRef.
+     */
+    public boolean isRequireExternalUriRef() {
+        return requireExternalUriRef;
+    }
+
+    /**
+     * @param requireExternalUriRef The requireExternalUriRef to set.
+     */
+    public void setRequireExternalUriRef(boolean requireExternalUriRef) {
+        this.requireExternalUriRef = requireExternalUriRef;
+    }
+
+    /**
+     * @return Returns the sc10SecurityContextToken.
+     */
+    public boolean isSc10SecurityContextToken() {
+        return sc10SecurityContextToken;
+    }
+
+    /**
+     * @param sc10SecurityContextToken The sc10SecurityContextToken to set.
+     */
+    public void setSc10SecurityContextToken(boolean sc10SecurityContextToken) {
+        this.sc10SecurityContextToken = sc10SecurityContextToken;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.neethi.Assertion#getName()
+     */
+
+    public QName getName() {
+        return spConstants.getSecurityContextToken();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.neethi.Assertion#normalize()
+     */
+
+    public PolicyComponent normalize() {
+        // TODO TODO Sanka
+        throw new UnsupportedOperationException("TODO Sanka");
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.neethi.PolicyComponent#serialize(javax.xml.stream.XMLStreamWriter)
+     */
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        // TODO TODO Sanka
+        throw new UnsupportedOperationException("TODO Sanka");
+    }
+
+    @Override
+    public QName getXmlName() {
+        return null;
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+    }
+
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SecurityContextToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignatureToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignatureToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignatureToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignatureToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,137 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public class SignatureToken extends AbstractSecurityAssertion implements TokenWrapper {
+
+    private Token signatureToken;
+
+    public SignatureToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the signatureToken.
+     */
+    public Token getSignatureToken() {
+        return signatureToken;
+    }
+
+    /**
+     * @param signatureToken The signatureToken to set.
+     */
+    public void setSignatureToken(Token signatureToken) {
+        this.signatureToken = signatureToken;
+    }
+
+    public void setToken(Token tok) {
+        this.setSignatureToken(tok);
+    }
+
+    public QName getName() {
+        return spConstants.getSignatureToken();
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+
+        String localname = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix;
+        String writerPrefix = writer.getPrefix(namespaceURI);
+
+        if (writerPrefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:SignatureToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        if (writerPrefix == null) {
+            // xmlns:sp=".."
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+
+        String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI();
+
+        String wspPrefix;
+
+        String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);
+
+        if (wspWriterPrefix == null) {
+            wspPrefix = SPConstants.POLICY.getPrefix();
+            writer.setPrefix(wspPrefix, wspNamespaceURI);
+
+        } else {
+            wspPrefix = wspWriterPrefix;
+        }
+
+        // <wsp:Policy>
+        writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI);
+
+        if (wspWriterPrefix == null) {
+            // xmlns:wsp=".."
+            writer.writeNamespace(wspPrefix, wspNamespaceURI);
+        }
+
+        if (signatureToken == null) {
+            throw new RuntimeException("EncryptionToken is not set");
+        }
+
+        signatureToken.serialize(writer);
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:SignatureToken>
+        writer.writeEndElement();
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        //todo
+        return new SecurityEvent.Event[0];
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        //todo
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignatureToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedElements.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedElements.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedElements.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedElements.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,193 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.assertionStates.EncryptedElementAssertionState;
+import org.swssf.policy.assertionStates.SignedElementAssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.*;
+
+/**
+ * class lent from apache rampart
+ */
+public class SignedEncryptedElements extends AbstractSecurityAssertion {
+
+    private List<String> xPathExpressions = new ArrayList<String>();
+
+    private Map<String, String> declaredNamespaces = new HashMap<String, String>();
+
+    private String xPathVersion;
+
+    /**
+     * Just a flag to identify whether this holds sign element info or encr
+     * elements info
+     */
+    private boolean signedElements;
+
+    public SignedEncryptedElements(Boolean signedElements, SPConstants spConstants) {
+        this.signedElements = signedElements;
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the xPathExpressions.
+     */
+    public List<String> getXPathExpressions() {
+        return xPathExpressions;
+    }
+
+    public void addXPathExpression(String expr) {
+        this.xPathExpressions.add(expr);
+    }
+
+    /**
+     * @return Returns the xPathVersion.
+     */
+    public String getXPathVersion() {
+        return xPathVersion;
+    }
+
+    /**
+     * @param pathVersion The xPathVersion to set.
+     */
+    public void setXPathVersion(String pathVersion) {
+        xPathVersion = pathVersion;
+    }
+
+    /**
+     * @return Returns the signedElements.
+     */
+    public boolean isSignedElements() {
+        return signedElements;
+    }
+
+    public Map getDeclaredNamespaces() {
+        return declaredNamespaces;
+    }
+
+    public void addDeclaredNamespaces(String uri, String prefix) {
+        declaredNamespaces.put(prefix, uri);
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+
+        String localName = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix = writer.getPrefix(namespaceURI);
+
+        if (prefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        }
+
+        // <sp:SignedElements> | <sp:EncryptedElements>
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+        // xmlns:sp=".."
+        writer.writeNamespace(prefix, namespaceURI);
+
+        if (xPathVersion != null) {
+            writer.writeAttribute(prefix, namespaceURI, SPConstants.XPATH_VERSION, xPathVersion);
+        }
+
+        String xpathExpression;
+
+        for (Iterator iterator = xPathExpressions.iterator(); iterator
+                .hasNext(); ) {
+            xpathExpression = (String) iterator.next();
+            // <sp:XPath ..>
+            writer.writeStartElement(prefix, SPConstants.XPATH_EXPR, namespaceURI);
+
+            Iterator<String> namespaces = declaredNamespaces.keySet().iterator();
+
+            while (namespaces.hasNext()) {
+                prefix = namespaces.next();
+                namespaceURI = declaredNamespaces.get(prefix);
+                writer.writeNamespace(prefix, namespaceURI);
+            }
+
+            writer.writeCharacters(xpathExpression);
+            writer.writeEndElement();
+        }
+
+        // </sp:SignedElements> | </sp:EncryptedElements>
+        writer.writeEndElement();
+    }
+
+    public QName getName() {
+        if (signedElements) {
+            return spConstants.getSignedElements();
+        }
+        return spConstants.getEncryptedElements();
+    }
+
+    public PolicyComponent normalize() {
+        return this;
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        if (isSignedElements()) {
+            return new SecurityEvent.Event[]{SecurityEvent.Event.SignedElement};
+        } else {
+            return new SecurityEvent.Event[]{SecurityEvent.Event.EncryptedElement};
+        }
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        if (isSignedElements()) {
+            Map<Assertion, List<AssertionState>> signedElementAssertionStates = assertionStateMap.get(SecurityEvent.Event.SignedElement);
+            addAssertionState(signedElementAssertionStates, this, new SignedElementAssertionState(this, true, getQNamesFromXPath()));
+        } else {
+            Map<Assertion, List<AssertionState>> encryptedElementAssertionStates = assertionStateMap.get(SecurityEvent.Event.EncryptedElement);
+            addAssertionState(encryptedElementAssertionStates, this, new EncryptedElementAssertionState(this, true, getQNamesFromXPath()));
+        }
+    }
+
+    private List<QName> getQNamesFromXPath() {
+        List<QName> qNames = new ArrayList<QName>(xPathExpressions.size());
+        for (int i = 0; i < xPathExpressions.size(); i++) {
+            String s = xPathExpressions.get(i);
+            String prefix;
+            String localName;
+            if (s.contains(":")) {
+                int idx = s.indexOf(":");
+                prefix = s.substring(0, idx);
+                localName = s.substring(idx + 1);
+            } else {
+                prefix = "";
+                localName = s;
+            }
+            qNames.add(new QName(declaredNamespaces.get(prefix), localName));
+        }
+        return qNames;
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedElements.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedParts.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedParts.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedParts.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedParts.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,208 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.ext.Constants;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.assertionStates.EncryptedPartAssertionState;
+import org.swssf.policy.assertionStates.SignedPartAssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public class SignedEncryptedParts extends AbstractSecurityAssertion {
+
+    private boolean body;
+
+    private boolean attachments;
+
+    private List<Header> headers = new ArrayList<Header>();
+
+    private boolean signedParts;
+
+    public SignedEncryptedParts(boolean signedParts, SPConstants spConstants) {
+        this.signedParts = signedParts;
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the body.
+     */
+    public boolean isBody() {
+        return body;
+    }
+
+    /**
+     * @param body The body to set.
+     */
+    public void setBody(boolean body) {
+        this.body = body;
+    }
+
+    /**
+     * @return Returns the attachments.
+     */
+    public boolean isAttachments() {
+        return attachments;
+    }
+
+    /**
+     * @param attachments The attachments to set.
+     */
+    public void setAttachments(boolean attachments) {
+        this.attachments = attachments;
+    }
+
+    /**
+     * @return Returns the headers.
+     */
+    public List<Header> getHeaders() {
+        return this.headers;
+    }
+
+    /**
+     * @param header The headers to set.
+     */
+    public void addHeader(Header header) {
+        this.headers.add(header);
+    }
+
+    /**
+     * @return Returns the signedParts.
+     */
+    public boolean isSignedParts() {
+        return signedParts;
+    }
+
+    public QName getName() {
+        if (signedParts) {
+            return spConstants.getSignedParts();
+        }
+        return spConstants.getEncryptedParts();
+    }
+
+    public PolicyComponent normalize() {
+        return this;
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        String localName = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix = writer.getPrefix(namespaceURI);
+
+        if (prefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        }
+
+        // <sp:SignedParts> | <sp:EncryptedParts> 
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+        // xmlns:sp=".."
+        writer.writeNamespace(prefix, namespaceURI);
+
+        if (isBody()) {
+            // <sp:Body />
+            writer.writeStartElement(prefix, SPConstants.BODY, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        Header header;
+        for (Iterator iterator = headers.iterator(); iterator.hasNext(); ) {
+            header = (Header) iterator.next();
+            // <sp:Header Name=".." Namespace=".." />
+            writer.writeStartElement(prefix, SPConstants.HEADER, namespaceURI);
+            // Name attribute is optional
+            if (header.getName() != null) {
+                writer.writeAttribute("Name", header.getName());
+            }
+            writer.writeAttribute("Namespace", header.getNamespace());
+
+            writer.writeEndElement();
+        }
+
+        if (isAttachments() && spConstants.getVersion() == SPConstants.Version.SP_V12) {
+            // <sp:Attachments />
+            writer.writeStartElement(prefix, SPConstants.ATTACHMENTS, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        // </sp:SignedParts> | </sp:EncryptedParts>
+        writer.writeEndElement();
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        if (isSignedParts()) {
+            return new SecurityEvent.Event[]{SecurityEvent.Event.SignedPart};
+        } else {
+            return new SecurityEvent.Event[]{SecurityEvent.Event.EncryptedPart};
+        }
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        //here we add just one AssertionState for all Parts to get a fail-fast behavior
+        //when we add multiple AssertionStates some of them return true, becauce they don't match
+        //as a result the policy is temporary satisfied for the current event and can only be falsified at last 
+        if (isSignedParts()) {
+            Map<Assertion, List<AssertionState>> signedPartsAssertionStates = assertionStateMap.get(SecurityEvent.Event.SignedPart);
+            List<QName> qNames = getQNamesFromHeaders();
+            if (isBody()) {
+                qNames.add(new QName(operationPolicy.getSoapMessageVersionNamespace(), Constants.TAG_soap_Body_LocalName));
+            }
+            addAssertionState(signedPartsAssertionStates, this, new SignedPartAssertionState(this, true, qNames));
+        } else {
+            Map<Assertion, List<AssertionState>> encryptedPartsAssertionStates = assertionStateMap.get(SecurityEvent.Event.EncryptedPart);
+            List<QName> qNames = getQNamesFromHeaders();
+            if (isBody()) {
+                qNames.add(new QName(operationPolicy.getSoapMessageVersionNamespace(), Constants.TAG_soap_Body_LocalName));
+            }
+            addAssertionState(encryptedPartsAssertionStates, this, new EncryptedPartAssertionState(this, true, qNames));
+        }
+    }
+
+    private List<QName> getQNamesFromHeaders() {
+        List<QName> qNames = new ArrayList<QName>(headers.size());
+        for (int i = 0; i < headers.size(); i++) {
+            Header header = headers.get(i);
+            String localName = header.getName();
+            if (localName == null) {
+                localName = "*";
+            }
+            qNames.add(new QName(header.getNamespace(), localName));
+        }
+        return qNames;
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SignedEncryptedParts.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SupportingToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SupportingToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SupportingToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SupportingToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,347 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.assertionStates.EncryptedElementAssertionState;
+import org.swssf.policy.assertionStates.SignedElementAssertionState;
+import org.swssf.policy.secpolicy.PolicyUtil;
+import org.swssf.policy.secpolicy.SP12Constants;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public class SupportingToken extends AbstractSecurityAssertion implements
+        AlgorithmWrapper, TokenWrapper {
+
+    /**
+     * Type of SupportingToken
+     *
+     * @see SPConstants.SupportingTokenType#SUPPORTING
+     * @see SPConstants.SupportingTokenType#ENDORSING
+     * @see SPConstants.SupportingTokenType#SIGNED
+     * @see SPConstants.SupportingTokenType#SIGNED_ENDORSING
+     */
+    private SPConstants.SupportingTokenType type;
+
+    private AlgorithmSuite algorithmSuite;
+
+    private Token token;
+
+    private SignedEncryptedElements signedElements;
+
+    private SignedEncryptedElements encryptedElements;
+
+    private SignedEncryptedParts signedParts;
+
+    private SignedEncryptedParts encryptedParts;
+
+    public SupportingToken(SPConstants.SupportingTokenType type, SPConstants spConstants) {
+        this.type = type;
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the algorithmSuite.
+     */
+    public AlgorithmSuite getAlgorithmSuite() {
+        return algorithmSuite;
+    }
+
+    /**
+     * @param algorithmSuite The algorithmSuite to set.
+     */
+    public void setAlgorithmSuite(AlgorithmSuite algorithmSuite) {
+        this.algorithmSuite = algorithmSuite;
+    }
+
+    /**
+     * @return Returns the token.
+     */
+    public Token getTokens() {
+        return token;
+    }
+
+    /**
+     * @param token The token to set.
+     */
+    public void setToken(Token token) {
+        this.token = token;
+    }
+
+    /**
+     * @return Returns the type.
+     */
+    public SPConstants.SupportingTokenType getTokenType() {
+        return type;
+    }
+
+    /**
+     * @param type The type to set.
+     */
+    public void setTokenType(SPConstants.SupportingTokenType type) {
+        this.type = type;
+    }
+
+    /**
+     * @return Returns the encryptedElements.
+     */
+    public SignedEncryptedElements getEncryptedElements() {
+        return encryptedElements;
+    }
+
+    /**
+     * @param encryptedElements The encryptedElements to set.
+     */
+    public void setEncryptedElements(SignedEncryptedElements encryptedElements) {
+        this.encryptedElements = encryptedElements;
+    }
+
+    /**
+     * @return Returns the encryptedParts.
+     */
+    public SignedEncryptedParts getEncryptedParts() {
+        return encryptedParts;
+    }
+
+    /**
+     * @param encryptedParts The encryptedParts to set.
+     */
+    public void setEncryptedParts(SignedEncryptedParts encryptedParts) {
+        this.encryptedParts = encryptedParts;
+    }
+
+    /**
+     * @return Returns the signedElements.
+     */
+    public SignedEncryptedElements getSignedElements() {
+        return signedElements;
+    }
+
+    /**
+     * @param signedElements The signedElements to set.
+     */
+    public void setSignedElements(SignedEncryptedElements signedElements) {
+        this.signedElements = signedElements;
+    }
+
+    /**
+     * @return Returns the signedParts.
+     */
+    public SignedEncryptedParts getSignedParts() {
+        return signedParts;
+    }
+
+    /**
+     * @param signedParts The signedParts to set.
+     */
+    public void setSignedParts(SignedEncryptedParts signedParts) {
+        this.signedParts = signedParts;
+    }
+
+    public QName getName() {
+        switch (type) {
+            case SUPPORTING:
+                return spConstants.getSupportingTokens();
+            case ENDORSING:
+                return spConstants.getEndorsingSupportingTokens();
+            case SIGNED:
+                return spConstants.getSignedSupportingTokens();
+            case SIGNED_ENDORSING:
+                return spConstants.getSignedEndorsingSupportingTokens();
+            case SIGNED_ENCRYPTED:
+                return SP12Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS;
+            case ENCRYPTED:
+                return SP12Constants.ENCRYPTED_SUPPORTING_TOKENS;
+            case ENDORSING_ENCRYPTED:
+                return SP12Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS;
+            case SIGNED_ENDORSING_ENCRYPTED:
+                return SP12Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS;
+            default:
+                return null;
+        }
+    }
+
+    /**
+     * @return true if the supporting token should be encrypted
+     */
+
+    public boolean isEncryptedToken() {
+        switch (type) {
+            case SUPPORTING:
+                return false;
+            case ENDORSING:
+                return false;
+            case SIGNED:
+                return false;
+            case SIGNED_ENDORSING:
+                return false;
+            case SIGNED_ENCRYPTED:
+                return true;
+            case ENCRYPTED:
+                return true;
+            case ENDORSING_ENCRYPTED:
+                return true;
+            case SIGNED_ENDORSING_ENCRYPTED:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    public PolicyComponent normalize() {
+        return this;
+    }
+
+    public short getType() {
+        return org.apache.neethi.Constants.TYPE_ASSERTION;
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix = writer.getPrefix(namespaceURI);
+        if (prefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        }
+
+        String localname = getName().getLocalPart();
+
+        // <sp:SupportingToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        // xmlns:sp=".."
+        writer.writeNamespace(prefix, namespaceURI);
+
+        String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
+        if (pPrefix == null) {
+            pPrefix = SPConstants.POLICY.getPrefix();
+            writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI());
+        }
+        // <wsp:Policy>
+        writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(),
+                SPConstants.POLICY.getNamespaceURI());
+
+        // [Token Assertion] +
+        token.serialize(writer);
+
+
+        if (signedParts != null) {
+            signedParts.serialize(writer);
+
+        } else if (signedElements != null) {
+            signedElements.serialize(writer);
+
+        } else if (encryptedParts != null) {
+            encryptedParts.serialize(writer);
+
+        } else if (encryptedElements != null) {
+            encryptedElements.serialize(writer);
+        }
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        writer.writeEndElement();
+        // </sp:SupportingToken>
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{SecurityEvent.Event.SupportingToken};
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        token.getAssertions(assertionStateMap, operationPolicy);
+        boolean signed = false;
+        boolean encrypted = false;
+        switch (type) {
+            case SUPPORTING:
+                break;
+            case ENDORSING:
+                break;
+            case SIGNED:
+                signed = true;
+                break;
+            case SIGNED_ENDORSING:
+                signed = true;
+                break;
+            case SIGNED_ENCRYPTED:
+                signed = true;
+                encrypted = true;
+                break;
+            case ENCRYPTED:
+                encrypted = true;
+                break;
+            case ENDORSING_ENCRYPTED:
+                encrypted = true;
+                break;
+            case SIGNED_ENDORSING_ENCRYPTED:
+                signed = true;
+                encrypted = true;
+                break;
+        }
+        if (signed) {
+            QName xmlName = token.getXmlName();
+            Map<Assertion, List<AssertionState>> signedElementAssertionStates = assertionStateMap.get(SecurityEvent.Event.SignedElement);
+            List<QName> qNames = new ArrayList<QName>();
+            qNames.add(xmlName);
+
+            SignedEncryptedElements signedEncryptedElements = null;
+            List<Assertion> assertions = PolicyUtil.getPolicyAssertionsInSameAlternative(operationPolicy.getPolicy(), this, SignedEncryptedElements.class, Boolean.TRUE, spConstants);
+            for (int i = 0; i < assertions.size(); i++) {
+                signedEncryptedElements = (SignedEncryptedElements) assertions.get(i);
+                if (signedEncryptedElements.isSignedElements()) {
+                    break;
+                }
+            }
+            addAssertionState(signedElementAssertionStates, signedEncryptedElements, new SignedElementAssertionState(signedEncryptedElements, true, qNames));
+        }
+        if (encrypted) {
+            QName xmlName = token.getXmlName();
+            Map<Assertion, List<AssertionState>> encryptedElementAssertionStates = assertionStateMap.get(SecurityEvent.Event.EncryptedElement);
+            List<QName> qNames = new ArrayList<QName>();
+            qNames.add(xmlName);
+
+            SignedEncryptedElements signedEncryptedElements = null;
+            List<Assertion> assertions = PolicyUtil.getPolicyAssertionsInSameAlternative(operationPolicy.getPolicy(), this, SignedEncryptedElements.class, Boolean.TRUE, spConstants);
+            for (int i = 0; i < assertions.size(); i++) {
+                signedEncryptedElements = (SignedEncryptedElements) assertions.get(i);
+                if (signedEncryptedElements.isSignedElements()) {
+                    break;
+                }
+            }
+            addAssertionState(encryptedElementAssertionStates, signedEncryptedElements, new EncryptedElementAssertionState(signedEncryptedElements, true, qNames));
+        }
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SupportingToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricAsymmetricBindingBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricAsymmetricBindingBase.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricAsymmetricBindingBase.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricAsymmetricBindingBase.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,133 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.Assertion;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.assertionStates.ProtectionOrderAssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public abstract class SymmetricAsymmetricBindingBase extends Binding {
+
+    private SPConstants.ProtectionOrder protectionOrder = SPConstants.ProtectionOrder.SignBeforeEncrypting;
+
+    private boolean signatureProtection;
+
+    private boolean tokenProtection;
+
+    private boolean entireHeadersAndBodySignatures;
+
+    public SymmetricAsymmetricBindingBase(SPConstants spConstants) {
+        super(spConstants);
+    }
+
+    /**
+     * @return Returns the entireHeaderAndBodySignatures.
+     */
+    public boolean isEntireHeadersAndBodySignatures() {
+        return entireHeadersAndBodySignatures;
+    }
+
+    /**
+     * @param entireHeaderAndBodySignatures The entireHeaderAndBodySignatures to set.
+     */
+    public void setEntireHeadersAndBodySignatures(
+            boolean entireHeaderAndBodySignatures) {
+        this.entireHeadersAndBodySignatures = entireHeaderAndBodySignatures;
+    }
+
+    /**
+     * @return Returns the protectionOrder.
+     */
+
+    public SPConstants.ProtectionOrder getProtectionOrder() {
+        return protectionOrder;
+    }
+
+    /**
+     * @param protectionOrder The protectionOrder to set.
+     */
+    public void setProtectionOrder(SPConstants.ProtectionOrder protectionOrder) {
+        if (SPConstants.ProtectionOrder.EncryptBeforeSigning.equals(protectionOrder) ||
+                SPConstants.ProtectionOrder.SignBeforeEncrypting.equals(protectionOrder)) {
+            this.protectionOrder = protectionOrder;
+        }
+    }
+
+    /**
+     * @return Returns the signatureProtection.
+     */
+    public boolean isSignatureProtection() {
+        return signatureProtection;
+    }
+
+    /**
+     * @param signatureProtection The signatureProtection to set.
+     */
+    public void setSignatureProtection(boolean signatureProtection) {
+        this.signatureProtection = signatureProtection;
+    }
+
+    /**
+     * @return Returns the tokenProtection.
+     */
+    public boolean isTokenProtection() {
+        return tokenProtection;
+    }
+
+    /**
+     * @param tokenProtection The tokenProtection to set.
+     */
+    public void setTokenProtection(boolean tokenProtection) {
+        this.tokenProtection = tokenProtection;
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        SecurityEvent.Event[] parentEvents = super.getResponsibleAssertionEvents();
+        SecurityEvent.Event[] collectedSecurityEvents = new SecurityEvent.Event[parentEvents.length];
+        System.arraycopy(parentEvents, 0, collectedSecurityEvents, 0, parentEvents.length);
+        return collectedSecurityEvents;
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        super.getAssertions(assertionStateMap, operationPolicy);
+        ProtectionOrderAssertionState protectionOrderAssertionState = new ProtectionOrderAssertionState(this, true);
+        Map<Assertion, List<AssertionState>> assertionStates = assertionStateMap.get(SecurityEvent.Event.SignatureToken);
+        addAssertionState(assertionStates, this, protectionOrderAssertionState);
+        assertionStates = assertionStateMap.get(SecurityEvent.Event.EncryptionToken);
+        addAssertionState(assertionStates, this, protectionOrderAssertionState);
+    }
+
+    @Override
+    public boolean isAsserted(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap) {
+        boolean isAsserted = super.isAsserted(assertionStateMap);
+        return isAsserted;
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricAsymmetricBindingBase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricBinding.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricBinding.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricBinding.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricBinding.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,237 @@
+/**
+ * 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.swssf.policy.secpolicy.model;
+
+import org.apache.neethi.All;
+import org.apache.neethi.ExactlyOne;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * class lent from apache rampart
+ */
+public class SymmetricBinding extends SymmetricAsymmetricBindingBase {
+
+    private EncryptionToken encryptionToken;
+
+    private SignatureToken signatureToken;
+
+    private ProtectionToken protectionToken;
+
+    public SymmetricBinding(SPConstants spConstants) {
+        super(spConstants);
+    }
+
+    /**
+     * @return Returns the encryptionToken.
+     */
+    public EncryptionToken getEncryptionToken() {
+        return encryptionToken;
+    }
+
+    /**
+     * @param encryptionToken The encryptionToken to set.
+     */
+    public void setEncryptionToken(EncryptionToken encryptionToken) {
+        if (this.protectionToken != null) {
+//            throw new WSSPolicyException("Cannot use an EncryptionToken in a " +
+//                    "SymmetricBinding when there is a ProtectionToken");
+        }
+        this.encryptionToken = encryptionToken;
+    }
+
+    /**
+     * @return Returns the protectionToken.
+     */
+    public ProtectionToken getProtectionToken() {
+        return protectionToken;
+    }
+
+    /**
+     * @param protectionToken The protectionToken to set.
+     */
+    public void setProtectionToken(ProtectionToken protectionToken) {
+        if (this.encryptionToken != null || this.signatureToken != null) {
+//            throw new WSSPolicyException("Cannot use a ProtectionToken in a " +
+//            "SymmetricBinding when there is a SignatureToken or an" +
+//            "EncryptionToken");
+        }
+        this.protectionToken = protectionToken;
+    }
+
+    /**
+     * @return Returns the signatureToken.
+     */
+    public SignatureToken getSignatureToken() {
+        return signatureToken;
+    }
+
+    /**
+     * @param signatureToken The signatureToken to set.
+     */
+    public void setSignatureToken(SignatureToken signatureToken) {
+        if (this.protectionToken != null) {
+//            throw new WSSPolicyException("Cannot use a SignatureToken in a " +
+//                    "SymmetricBinding when there is a ProtectionToken");
+        }
+        this.signatureToken = signatureToken;
+    }
+
+    public QName getName() {
+        return spConstants.getSymmetricBinding();
+    }
+
+    public PolicyComponent normalize() {
+        if (isNormalized()) {
+            return this;
+        }
+
+        AlgorithmSuite algorithmSuite = getAlgorithmSuite();
+
+        Policy policy = new Policy();
+        ExactlyOne exactlyOne = new ExactlyOne();
+        policy.addPolicyComponent(exactlyOne);
+        All all = new All();
+        exactlyOne.addPolicyComponent(all);
+
+        SymmetricBinding symmetricBinding = new SymmetricBinding(spConstants);
+
+        symmetricBinding.setAlgorithmSuite(algorithmSuite);
+
+        symmetricBinding.setEncryptionToken(getEncryptionToken());
+        symmetricBinding.setEntireHeadersAndBodySignatures(isEntireHeadersAndBodySignatures());
+        symmetricBinding.setIncludeTimestamp(isIncludeTimestamp());
+        symmetricBinding.setLayout(getLayout());
+        symmetricBinding.setProtectionOrder(getProtectionOrder());
+        symmetricBinding.setProtectionToken(getProtectionToken());
+        symmetricBinding.setSignatureProtection(isSignatureProtection());
+        symmetricBinding.setSignatureToken(getSignatureToken());
+        symmetricBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
+        symmetricBinding.setSignedSupportingToken(getSignedSupportingToken());
+        symmetricBinding.setTokenProtection(isTokenProtection());
+
+        symmetricBinding.setNormalized(true);
+        all.addPolicyComponent(symmetricBinding);
+
+        return policy;
+    }
+
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+
+        String localname = getName().getLocalPart();
+        String namespaceURI = getName().getNamespaceURI();
+
+        String prefix;
+        String writerPrefix = writer.getPrefix(namespaceURI);
+
+        if (writerPrefix == null) {
+            prefix = getName().getPrefix();
+            writer.setPrefix(prefix, namespaceURI);
+        } else {
+            prefix = writerPrefix;
+        }
+
+        // <sp:SymmetricBinding>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        // xmlns:sp=".."
+        writer.writeNamespace(prefix, namespaceURI);
+
+        String policyLocalName = SPConstants.POLICY.getLocalPart();
+        String policyNamespaceURI = SPConstants.POLICY.getNamespaceURI();
+
+        String wspPrefix;
+
+        String wspWriterPrefix = writer.getPrefix(policyNamespaceURI);
+        if (wspWriterPrefix == null) {
+            wspPrefix = SPConstants.POLICY.getPrefix();
+            writer.setPrefix(wspPrefix, policyNamespaceURI);
+
+        } else {
+            wspPrefix = wspWriterPrefix;
+        }
+        // <wsp:Policy>
+        writer.writeStartElement(wspPrefix, policyLocalName, policyNamespaceURI);
+
+        if (encryptionToken != null) {
+            encryptionToken.serialize(writer);
+
+        } else if (protectionToken != null) {
+            protectionToken.serialize(writer);
+
+        } else {
+            throw new RuntimeException("Either EncryptionToken or ProtectionToken must be set");
+        }
+
+        AlgorithmSuite algorithmSuite = getAlgorithmSuite();
+
+        if (algorithmSuite == null) {
+            throw new RuntimeException("AlgorithmSuite must be set");
+        }
+        // <sp:AlgorithmSuite />
+        algorithmSuite.serialize(writer);
+
+        Layout layout = getLayout();
+        if (layout != null) {
+            // <sp:Layout />
+            layout.serialize(writer);
+        }
+
+        if (isIncludeTimestamp()) {
+            // <sp:IncludeTimestamp />
+            writer.writeStartElement(prefix, SPConstants.INCLUDE_TIMESTAMP, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (SPConstants.ProtectionOrder.EncryptBeforeSigning.equals(getProtectionOrder())) {
+            // <sp:EncryptBeforeSigning />
+            writer.writeStartElement(prefix, SPConstants.ENCRYPT_BEFORE_SIGNING, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (isSignatureProtection()) {
+            // <sp:EncryptSignature />
+            writer.writeStartElement(prefix, SPConstants.ENCRYPT_SIGNATURE, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (isEntireHeadersAndBodySignatures()) {
+            writer.writeEmptyElement(prefix, SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY, namespaceURI);
+        }
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:SymmetricBinding>
+        writer.writeEndElement();
+
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        //todo
+        return new SecurityEvent.Event[0];
+    }
+}

Propchange: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/SymmetricBinding.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision