ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gi...@apache.org
Subject svn commit: r1172285 [6/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...
Date Sun, 18 Sep 2011 13:51:36 GMT
Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AbstractSecurityAssertion.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AbstractSecurityAssertion.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AbstractSecurityAssertion.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AbstractSecurityAssertion.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,119 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public abstract class AbstractSecurityAssertion implements Assertion {
+
+    private boolean isOptional;
+
+    private boolean normalized = false;
+
+    protected SPConstants spConstants;
+
+    public boolean isOptional() {
+        return isOptional;
+    }
+
+    public void setOptional(boolean isOptional) {
+        this.isOptional = isOptional;
+    }
+
+    public short getType() {
+        return org.apache.neethi.Constants.TYPE_ASSERTION;
+    }
+
+    public boolean equal(PolicyComponent policyComponent) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setNormalized(boolean normalized) {
+        this.normalized = normalized;
+    }
+
+    public boolean isNormalized() {
+        return this.normalized;
+    }
+
+    public PolicyComponent normalize() {
+
+        /*
+        * TODO: Handling the isOptional:TRUE case
+        */
+        return this;
+    }
+
+    public void setVersion(SPConstants spConstants) {
+        this.spConstants = spConstants;
+    }
+
+    public SPConstants.Version getVersion() {
+        return spConstants.getVersion();
+    }
+
+    public abstract SecurityEvent.Event[] getResponsibleAssertionEvents();
+
+    public abstract void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy);
+
+    public boolean isAsserted(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap) {
+
+        boolean asserted = true;
+
+        SecurityEvent.Event[] secEvents = getResponsibleAssertionEvents();
+        for (int i = 0; i < secEvents.length; i++) {
+            SecurityEvent.Event securityEvent = secEvents[i];
+
+            Map<Assertion, List<AssertionState>> assertionStates = assertionStateMap.get(securityEvent);
+            for (Iterator<Map.Entry<Assertion, List<AssertionState>>> assertionStateIterator = assertionStates.entrySet().iterator(); assertionStateIterator.hasNext(); ) {
+                Map.Entry<Assertion, List<AssertionState>> entry = assertionStateIterator.next();
+                if (entry.getKey() == this) {
+                    List<AssertionState> assertionState = entry.getValue();
+                    for (int j = 0; j < assertionState.size(); j++) {
+                        AssertionState state = assertionState.get(j);
+                        asserted &= state.isAsserted();
+                    }
+                }
+            }
+        }
+        return asserted;
+    }
+
+    protected void addAssertionState(Map<Assertion, List<AssertionState>> assertionStates, Assertion keyAssertion, AssertionState assertionState) {
+        List<AssertionState> assertionStateList = assertionStates.get(keyAssertion);
+        if (assertionStateList == null) {
+            assertionStateList = new ArrayList<AssertionState>();
+        }
+        assertionStateList.add(assertionState);
+        assertionStates.put(keyAssertion, assertionStateList);
+    }
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmSuite.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmSuite.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmSuite.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmSuite.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,539 @@
+/**
+ * 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.AlgorithmSuiteAssertionState;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.policy.secpolicy.WSSPolicyException;
+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 AlgorithmSuite extends AbstractSecurityAssertion {
+
+    private String algoSuiteString;
+
+    private String symmetricSignature = SPConstants.HMAC_SHA1;
+
+    private String asymmetricSignature = SPConstants.RSA_SHA1;
+
+    private String computedKey = SPConstants.P_SHA1;
+
+    private int maximumSymmetricKeyLength = 256;
+
+    private int minimumAsymmetricKeyLength = 1024;
+
+    private int maximumAsymmetricKeyLength = 4096;
+
+    private String digest;
+
+    private String encryption;
+
+    private String symmetricKeyWrap;
+
+    private String asymmetricKeyWrap;
+
+    private String encryptionKeyDerivation;
+
+    private int encryptionDerivedKeyLength;
+
+    private String signatureKeyDerivation;
+
+    private int signatureDerivedKeyLength;
+
+    private int minimumSymmetricKeyLength;
+
+    private String c14n = SPConstants.EX_C14N;
+
+    private String soapNormalization;
+
+    private String strTransform;
+
+    private String xPath;
+
+    public AlgorithmSuite(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * Set the algorithm suite
+     *
+     * @param algoSuite
+     * @throws WSSPolicyException
+     * @see SPConstants#ALGO_SUITE_BASIC128
+     * @see SPConstants#ALGO_SUITE_BASIC128_RSA15
+     * @see SPConstants#ALGO_SUITE_BASIC128_SHA256
+     * @see SPConstants#ALGO_SUITE_BASIC128_SHA256_RSA15
+     * @see SPConstants#ALGO_SUITE_BASIC192
+     * @see SPConstants#ALGO_SUITE_BASIC192_RSA15
+     * @see SPConstants#ALGO_SUITE_BASIC192_SHA256
+     * @see SPConstants#ALGO_SUITE_BASIC192_SHA256_RSA15
+     * @see SPConstants#ALGO_SUITE_BASIC256
+     * @see SPConstants#ALGO_SUITE_BASIC256_RSA15
+     * @see SPConstants#ALGO_SUITE_BASIC256_SHA256
+     * @see SPConstants#ALGO_SUITE_BASIC256_SHA256_RSA15
+     * @see SPConstants#ALGO_SUITE_TRIPLE_DES
+     * @see SPConstants#ALGO_SUITE_TRIPLE_DES_RSA15
+     * @see SPConstants#ALGO_SUITE_TRIPLE_DES_SHA256
+     * @see SPConstants#ALGO_SUITE_TRIPLE_DES_SHA256_RSA15
+     */
+    public void setAlgorithmSuite(String algoSuite) throws WSSPolicyException {
+        setAlgoSuiteString(algoSuite);
+        this.algoSuiteString = algoSuite;
+
+        // TODO: Optimize this :-)
+        if (SPConstants.ALGO_SUITE_BASIC256.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.AES256;
+            this.symmetricKeyWrap = SPConstants.KW_AES256;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L256;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 256;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 256;
+            this.encryptionDerivedKeyLength = 256;
+        } else if (SPConstants.ALGO_SUITE_BASIC192.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.AES192;
+            this.symmetricKeyWrap = SPConstants.KW_AES192;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192;
+        } else if (SPConstants.ALGO_SUITE_BASIC128.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.AES128;
+            this.symmetricKeyWrap = SPConstants.KW_AES128;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L128;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L128;
+            this.encryptionDerivedKeyLength = 128;
+            this.signatureDerivedKeyLength = 128;
+            this.minimumSymmetricKeyLength = 128;
+            this.maximumSymmetricKeyLength = 128;
+        } else if (SPConstants.ALGO_SUITE_TRIPLE_DES.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.TRIPLE_DES;
+            this.symmetricKeyWrap = SPConstants.KW_TRIPLE_DES;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192; //due to use of 3des
+        } else if (SPConstants.ALGO_SUITE_BASIC256_RSA15.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.AES256;
+            this.symmetricKeyWrap = SPConstants.KW_AES256;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L256;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 256;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 256;
+        } else if (SPConstants.ALGO_SUITE_BASIC192_RSA15.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.AES192;
+            this.symmetricKeyWrap = SPConstants.KW_AES192;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192;
+        } else if (SPConstants.ALGO_SUITE_BASIC128_RSA15.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.AES128;
+            this.symmetricKeyWrap = SPConstants.KW_AES128;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L128;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L128;
+            this.encryptionDerivedKeyLength = 128;
+            this.signatureDerivedKeyLength = 128;
+            this.minimumSymmetricKeyLength = 128;
+            this.maximumSymmetricKeyLength = 128;
+        } else if (SPConstants.ALGO_SUITE_TRIPLE_DES_RSA15.equals(algoSuite)) {
+            this.digest = SPConstants.SHA1;
+            this.encryption = SPConstants.TRIPLE_DES;
+            this.symmetricKeyWrap = SPConstants.KW_TRIPLE_DES;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192; //due to use of 3des
+        } else if (SPConstants.ALGO_SUITE_BASIC256_SHA256.equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.AES256;
+            this.symmetricKeyWrap = SPConstants.KW_AES256;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L256;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 256;
+            this.signatureDerivedKeyLength = 256;
+            this.minimumSymmetricKeyLength = 256;
+        } else if (SPConstants.ALGO_SUITE_BASIC192_SHA256.equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.AES192;
+            this.symmetricKeyWrap = SPConstants.KW_AES192;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192;
+        } else if (SPConstants.ALGO_SUITE_BASIC128_SHA256.equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.AES128;
+            this.symmetricKeyWrap = SPConstants.KW_AES128;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L128;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L128;
+            this.encryptionDerivedKeyLength = 128;
+            this.signatureDerivedKeyLength = 128;
+            this.minimumSymmetricKeyLength = 128;
+            this.maximumSymmetricKeyLength = 128;
+        } else if (SPConstants.ALGO_SUITE_TRIPLE_DES_SHA256.equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.TRIPLE_DES;
+            this.symmetricKeyWrap = SPConstants.KW_TRIPLE_DES;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA_OAEP;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192; //due to use of 3des
+        } else if (SPConstants.ALGO_SUITE_BASIC256_SHA256_RSA15.equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.AES256;
+            this.symmetricKeyWrap = SPConstants.KW_AES256;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L256;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 256;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 256;
+        } else if (SPConstants.ALGO_SUITE_BASIC192_SHA256_RSA15.equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.AES192;
+            this.symmetricKeyWrap = SPConstants.KW_AES192;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192;
+        } else if (SPConstants.ALGO_SUITE_BASIC128_SHA256_RSA15.equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.AES128;
+            this.symmetricKeyWrap = SPConstants.KW_AES128;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L128;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L128;
+            this.encryptionDerivedKeyLength = 128;
+            this.signatureDerivedKeyLength = 128;
+            this.minimumSymmetricKeyLength = 128;
+            this.maximumSymmetricKeyLength = 192;
+        } else if (SPConstants.ALGO_SUITE_TRIPLE_DES_SHA256_RSA15
+                .equals(algoSuite)) {
+            this.digest = SPConstants.SHA256;
+            this.encryption = SPConstants.TRIPLE_DES;
+            this.symmetricKeyWrap = SPConstants.KW_TRIPLE_DES;
+            this.asymmetricKeyWrap = SPConstants.KW_RSA15;
+            this.encryptionKeyDerivation = SPConstants.P_SHA1_L192;
+            this.signatureKeyDerivation = SPConstants.P_SHA1_L192;
+            this.encryptionDerivedKeyLength = 192;
+            this.signatureDerivedKeyLength = 192;
+            this.minimumSymmetricKeyLength = 192;
+            this.maximumSymmetricKeyLength = 192; //due to use of 3des
+        } else {
+            throw new WSSPolicyException("Invalid algorithm suite : " +
+                    algoSuite);
+        }
+    }
+
+    /**
+     * @return Returns the asymmetricKeyWrap.
+     */
+    public String getAsymmetricKeyWrap() {
+        return asymmetricKeyWrap;
+    }
+
+    /**
+     * @return Returns the asymmetricSignature.
+     */
+    public String getAsymmetricSignature() {
+        return asymmetricSignature;
+    }
+
+    /**
+     * @return Returns the computedKey.
+     */
+    public String getComputedKey() {
+        return computedKey;
+    }
+
+    /**
+     * @return Returns the digest.
+     */
+    public String getDigest() {
+        return digest;
+    }
+
+    /**
+     * @return Returns the encryption.
+     */
+    public String getEncryption() {
+        return encryption;
+    }
+
+    /**
+     * @return Returns the encryptionKeyDerivation.
+     */
+    public String getEncryptionKeyDerivation() {
+        return encryptionKeyDerivation;
+    }
+
+    /**
+     * @return Returns the maximumAsymmetricKeyLength.
+     */
+    public int getMaximumAsymmetricKeyLength() {
+        return maximumAsymmetricKeyLength;
+    }
+
+    /**
+     * @return Returns the maximumSymmetricKeyLength.
+     */
+    public int getMaximumSymmetricKeyLength() {
+        return maximumSymmetricKeyLength;
+    }
+
+    /**
+     * @return Returns the minimumAsymmetricKeyLength.
+     */
+    public int getMinimumAsymmetricKeyLength() {
+        return minimumAsymmetricKeyLength;
+    }
+
+    /**
+     * @return Returns the minimumSymmetricKeyLength.
+     */
+    public int getMinimumSymmetricKeyLength() {
+        return minimumSymmetricKeyLength;
+    }
+
+    /**
+     * @return Returns the signatureKeyDerivation.
+     */
+    public String getSignatureKeyDerivation() {
+        return signatureKeyDerivation;
+    }
+
+    /**
+     * @return Returns the symmetricKeyWrap.
+     */
+    public String getSymmetricKeyWrap() {
+        return symmetricKeyWrap;
+    }
+
+    /**
+     * @return Returns the symmetricSignature.
+     */
+    public String getSymmetricSignature() {
+        return symmetricSignature;
+    }
+
+    /**
+     * @return Returns the c14n.
+     */
+    public String getC14n() {
+        return c14n;
+    }
+
+    /**
+     * @param c14n The c14n to set.
+     */
+    public void setC14n(String c14n) {
+        this.c14n = c14n;
+    }
+
+    /**
+     * @return Returns the soapNormalization.
+     */
+    public String getSoapNormalization() {
+        return soapNormalization;
+    }
+
+    /**
+     * @param soapNormalization The soapNormalization to set.
+     */
+    public void setSoapNormalization(String soapNormalization) {
+        this.soapNormalization = soapNormalization;
+    }
+
+    /**
+     * @return Returns the strTransform.
+     */
+    public String getStrTransform() {
+        return strTransform;
+    }
+
+    /**
+     * @param strTransform The strTransform to set.
+     */
+    public void setStrTransform(String strTransform) {
+        this.strTransform = strTransform;
+    }
+
+    /**
+     * @return Returns the xPath.
+     */
+    public String getXPath() {
+        return xPath;
+    }
+
+    /**
+     * @param path The xPath to set.
+     */
+    public void setXPath(String path) {
+        xPath = path;
+    }
+
+    private void setAlgoSuiteString(String algoSuiteString) {
+        this.algoSuiteString = algoSuiteString;
+    }
+
+    private String getAlgoSuiteString() {
+        return algoSuiteString;
+    }
+
+    public QName getName() {
+        return spConstants.getAlgorithmSuite();
+    }
+
+    public PolicyComponent normalize() {
+        throw new UnsupportedOperationException(
+                "AlgorithmSuite.normalize() is not supported");
+    }
+
+    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);
+        }
+
+        writer.writeStartElement(prefix, localName, namespaceURI);
+        writer.writeNamespace(prefix, namespaceURI);
+
+        // <wsp:Policy>
+        writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY
+                .getLocalPart(), SPConstants.POLICY.getNamespaceURI());
+
+        //
+        writer.writeStartElement(prefix, getAlgoSuiteString(), namespaceURI);
+        writer.writeEndElement();
+
+        if (SPConstants.C14N.equals(getC14n())) {
+            writer.writeStartElement(prefix, SPConstants.INCLUSIVE_C14N, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (SPConstants.SNT.equals(getSoapNormalization())) {
+            writer.writeStartElement(prefix, SPConstants.SOAP_NORMALIZATION_10,
+                    namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (SPConstants.STRT10.equals(getStrTransform())) {
+            writer.writeStartElement(prefix, SPConstants.STR_TRANSFORM_10,
+                    namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (SPConstants.XPATH.equals(getXPath())) {
+            writer.writeStartElement(prefix, SPConstants.XPATH10, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (SPConstants.XPATH20.equals(getXPath())) {
+            writer.writeStartElement(prefix, SPConstants.XPATH_FILTER20,
+                    namespaceURI);
+            writer.writeEndElement();
+        }
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:AlgorithmSuite>
+        writer.writeEndElement();
+    }
+
+    public int getEncryptionDerivedKeyLength() {
+        return encryptionDerivedKeyLength;
+    }
+
+    public int getSignatureDerivedKeyLength() {
+        return signatureDerivedKeyLength;
+    }
+
+    public void setAsymmetricKeyWrap(String asymmetricKeyWrap) {
+        this.asymmetricKeyWrap = asymmetricKeyWrap;
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{
+                SecurityEvent.Event.AlgorithmSuite
+        };
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        Map<Assertion, List<AssertionState>> assertionStates = assertionStateMap.get(SecurityEvent.Event.AlgorithmSuite);
+        AlgorithmSuiteAssertionState algorithmSuiteAssertionState = new AlgorithmSuiteAssertionState(this, true);
+        addAssertionState(assertionStates, this, algorithmSuiteAssertionState);
+    }
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmWrapper.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmWrapper.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmWrapper.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AlgorithmWrapper.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,29 @@
+/**
+ * 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;
+
+/**
+ * class lent from apache rampart
+ */
+public interface AlgorithmWrapper {
+
+    public void setAlgorithmSuite(AlgorithmSuite algorithmSuite);
+
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AsymmetricBinding.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AsymmetricBinding.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AsymmetricBinding.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/AsymmetricBinding.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,246 @@
+/**
+ * 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.*;
+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 AsymmetricBinding extends SymmetricAsymmetricBindingBase {
+
+    private InitiatorToken initiatorToken;
+
+    private RecipientToken recipientToken;
+
+    public AsymmetricBinding(SPConstants spConstants) {
+        super(spConstants);
+    }
+
+    /**
+     * @return Returns the initiatorToken.
+     */
+    public InitiatorToken getInitiatorToken() {
+        return initiatorToken;
+    }
+
+    /**
+     * @param initiatorToken The initiatorToken to set.
+     */
+    public void setInitiatorToken(InitiatorToken initiatorToken) {
+        this.initiatorToken = initiatorToken;
+    }
+
+    /**
+     * @return Returns the recipientToken.
+     */
+    public RecipientToken getRecipientToken() {
+        return recipientToken;
+    }
+
+    /**
+     * @param recipientToken The recipientToken to set.
+     */
+    public void setRecipientToken(RecipientToken recipientToken) {
+        this.recipientToken = recipientToken;
+    }
+
+    public QName getName() {
+        return spConstants.getAsymmetricBinding();
+    }
+
+    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);
+
+        AsymmetricBinding asymmetricBinding = new AsymmetricBinding(spConstants);
+
+        asymmetricBinding.setAlgorithmSuite(algorithmSuite);
+        asymmetricBinding.setEntireHeadersAndBodySignatures(isEntireHeadersAndBodySignatures());
+        asymmetricBinding.setIncludeTimestamp(isIncludeTimestamp());
+        asymmetricBinding.setInitiatorToken(getInitiatorToken());
+        asymmetricBinding.setLayout(getLayout());
+        asymmetricBinding.setProtectionOrder(getProtectionOrder());
+        asymmetricBinding.setRecipientToken(getRecipientToken());
+        asymmetricBinding.setSignatureProtection(isSignatureProtection());
+        asymmetricBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
+        asymmetricBinding.setSignedSupportingToken(getSignedSupportingToken());
+        asymmetricBinding.setTokenProtection(isTokenProtection());
+
+        asymmetricBinding.setNormalized(true);
+        all.addPolicyComponent(asymmetricBinding);
+
+        return policy;
+
+    }
+
+    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:AsymmetricBinding>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+        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());
+
+        if (initiatorToken == null) {
+            throw new RuntimeException("InitiatorToken is not set");
+        }
+
+        // <sp:InitiatorToken>
+        initiatorToken.serialize(writer);
+        // </sp:InitiatorToken>
+
+        if (recipientToken == null) {
+            throw new RuntimeException("RecipientToken is not set");
+        }
+
+        // <sp:RecipientToken>
+        recipientToken.serialize(writer);
+        // </sp:RecipientToken>
+
+        AlgorithmSuite algorithmSuite = getAlgorithmSuite();
+        if (algorithmSuite == null) {
+            throw new RuntimeException("AlgorithmSuite is not set");
+        }
+
+        // <sp:AlgorithmSuite>
+        algorithmSuite.serialize(writer);
+        // </sp:AlgorithmSuite>
+
+        Layout layout = getLayout();
+        if (layout != null) {
+            // <sp:Layout>
+            layout.serialize(writer);
+            // </sp:Layout>
+        }
+
+        if (isIncludeTimestamp()) {
+            // <sp:IncludeTimestamp>
+            writer.writeStartElement(prefix, SPConstants.INCLUDE_TIMESTAMP,
+                    namespaceURI);
+            writer.writeEndElement();
+            // </sp:IncludeTimestamp>
+        }
+
+        if (SPConstants.ProtectionOrder.EncryptBeforeSigning.equals(getProtectionOrder())) {
+            // <sp:EncryptBeforeSign />
+            writer.writeStartElement(prefix, SPConstants.ENCRYPT_BEFORE_SIGNING,
+                    namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (isSignatureProtection()) {
+            // <sp:EncryptSignature />
+            // FIXME move the String constants to a QName
+            writer.writeStartElement(prefix, SPConstants.ENCRYPT_SIGNATURE,
+                    namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (isTokenProtection()) {
+            // <sp:ProtectTokens />
+            writer.writeStartElement(prefix, SPConstants.PROTECT_TOKENS,
+                    namespaceURI);
+            writer.writeEndElement();
+        }
+
+        if (isEntireHeadersAndBodySignatures()) {
+            // <sp:OnlySignEntireHeaderAndBody />
+            writer.writeStartElement(prefix,
+                    SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY, namespaceURI);
+            writer.writeEndElement();
+        }
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:AsymmetircBinding>
+        writer.writeEndElement();
+    }
+
+    @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);
+        if (initiatorToken != null) {
+            initiatorToken.getAssertions(assertionStateMap, operationPolicy);
+        }
+        if (recipientToken != null) {
+            recipientToken.getAssertions(assertionStateMap, operationPolicy);
+        }
+    }
+
+    @Override
+    public boolean isAsserted(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap) {
+        boolean isAsserted = true;
+        if (initiatorToken != null) {
+            isAsserted &= initiatorToken.isAsserted(assertionStateMap);
+        }
+        if (recipientToken != null) {
+            isAsserted &= recipientToken.isAsserted(assertionStateMap);
+        }
+        isAsserted &= super.isAsserted(assertionStateMap);
+        return isAsserted;
+    }
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Binding.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Binding.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Binding.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Binding.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,178 @@
+/**
+ * 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.ext.Constants;
+import org.swssf.policy.OperationPolicy;
+import org.swssf.policy.assertionStates.AssertionState;
+import org.swssf.policy.assertionStates.IncludeTimeStampAssertionState;
+import org.swssf.policy.assertionStates.SignedElementAssertionState;
+import org.swssf.policy.secpolicy.PolicyUtil;
+import org.swssf.policy.secpolicy.SPConstants;
+import org.swssf.securityEvent.SecurityEvent;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * class lent from apache rampart
+ */
+public abstract class Binding extends AbstractSecurityAssertion implements AlgorithmWrapper {
+
+    private AlgorithmSuite algorithmSuite;
+    private boolean includeTimestamp;
+    private Layout layout;
+    //todo are these defined in an old ws-securityPolicy schema? if not, remove them
+    private SupportingToken signedSupportingToken;
+    private SupportingToken signedEndorsingSupportingTokens;
+
+    public Binding(SPConstants spConstants) {
+        setVersion(spConstants);
+        layout = new Layout(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 includeTimestamp.
+     */
+    public boolean isIncludeTimestamp() {
+        return includeTimestamp;
+    }
+
+    /**
+     * @param includeTimestamp The includeTimestamp to set.
+     */
+    public void setIncludeTimestamp(boolean includeTimestamp) {
+        this.includeTimestamp = includeTimestamp;
+    }
+
+    /**
+     * @return Returns the layout.
+     */
+    public Layout getLayout() {
+        return layout;
+    }
+
+    /**
+     * @param layout The layout to set.
+     */
+    public void setLayout(Layout layout) {
+        this.layout = layout;
+    }
+
+    public SupportingToken getSignedEndorsingSupportingTokens() {
+        return signedEndorsingSupportingTokens;
+    }
+
+    public void setSignedEndorsingSupportingTokens(
+            SupportingToken signedEndorsingSupportingTokens) {
+        this.signedEndorsingSupportingTokens = signedEndorsingSupportingTokens;
+    }
+
+    public SupportingToken getSignedSupportingToken() {
+        return signedSupportingToken;
+    }
+
+    public void setSignedSupportingToken(SupportingToken signedSupportingToken) {
+        this.signedSupportingToken = signedSupportingToken;
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{
+                SecurityEvent.Event.Timestamp,
+                SecurityEvent.Event.SignedElement
+        };
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        if (algorithmSuite != null) {
+            algorithmSuite.getAssertions(assertionStateMap, operationPolicy);
+        }
+        if (layout != null) {
+            layout.getAssertions(assertionStateMap, operationPolicy);
+        }
+        if (signedSupportingToken != null) {
+            signedSupportingToken.getAssertions(assertionStateMap, operationPolicy);
+        }
+        if (signedEndorsingSupportingTokens != null) {
+            signedEndorsingSupportingTokens.getAssertions(assertionStateMap, operationPolicy);
+        }
+
+        Map<Assertion, List<AssertionState>> timestampAssertionStates = assertionStateMap.get(SecurityEvent.Event.Timestamp);
+        //ws-securitypolicy-1.3-spec: 6.2 [Timestamp] Property
+        if (isIncludeTimestamp()) {
+            addAssertionState(timestampAssertionStates, this, new IncludeTimeStampAssertionState(this, false));
+
+            Map<Assertion, List<AssertionState>> signedElementAssertionStates = assertionStateMap.get(SecurityEvent.Event.SignedElement);
+            List<QName> qNames = new ArrayList<QName>();
+            qNames.add(Constants.TAG_wsu_Timestamp);
+
+            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));
+        } else {
+            addAssertionState(timestampAssertionStates, this, new IncludeTimeStampAssertionState(this, true));
+        }
+    }
+
+    @Override
+    public boolean isAsserted(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap) {
+        boolean isAsserted = super.isAsserted(assertionStateMap);
+        //todo early returns?
+        if (algorithmSuite != null) {
+            isAsserted &= algorithmSuite.isAsserted(assertionStateMap);
+        }
+        if (layout != null) {
+            isAsserted &= layout.isAsserted(assertionStateMap);
+        }
+        if (signedSupportingToken != null) {
+            isAsserted &= signedSupportingToken.isAsserted(assertionStateMap);
+        }
+        if (signedEndorsingSupportingTokens != null) {
+            isAsserted &= signedEndorsingSupportingTokens.isAsserted(assertionStateMap);
+        }
+        return isAsserted;
+    }
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ContentEncryptedElements.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ContentEncryptedElements.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ContentEncryptedElements.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/ContentEncryptedElements.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,166 @@
+/**
+ * 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.ContentEncryptedElementAssertionState;
+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.*;
+
+/**
+ * class lent from apache rampart
+ */
+public class ContentEncryptedElements extends AbstractSecurityAssertion {
+
+    private List<String> xPathExpressions = new ArrayList<String>();
+
+    private Map<String, String> declaredNamespaces = new HashMap<String, String>();
+
+    private String xPathVersion;
+
+    public ContentEncryptedElements(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:ContentEncryptedElements>
+        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:ContentEncryptedElements>
+        writer.writeEndElement();
+    }
+
+    public QName getName() {
+        return SP12Constants.CONTENT_ENCRYPTED_ELEMENTS;
+    }
+
+    public PolicyComponent normalize() {
+        return this;
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{SecurityEvent.Event.ContentEncrypted};
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        Map<Assertion, List<AssertionState>> encryptedElementAssertionStates = assertionStateMap.get(SecurityEvent.Event.ContentEncrypted);
+        addAssertionState(encryptedElementAssertionStates, this, new ContentEncryptedElementAssertionState(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/ContentEncryptedElements.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/EncryptionToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/EncryptionToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/EncryptionToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/EncryptionToken.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.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 EncryptionToken extends AbstractSecurityAssertion implements TokenWrapper {
+
+    private Token encryptionToken;
+
+    public EncryptionToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the encryptionToken.
+     */
+    public Token getEncryptionToken() {
+        return encryptionToken;
+    }
+
+    /**
+     * @param encryptionToken The encryptionToken to set.
+     */
+    public void setEncryptionToken(Token encryptionToken) {
+        this.encryptionToken = encryptionToken;
+    }
+
+    public void setToken(Token tok) {
+        this.setEncryptionToken(tok);
+    }
+
+    public QName getName() {
+        return spConstants.getEncryptionToken();
+    }
+
+    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:EncryptionToken>
+        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 (encryptionToken == null) {
+            throw new RuntimeException("EncryptionToken is not set");
+        }
+
+        encryptionToken.serialize(writer);
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:EncryptionToken>
+        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/EncryptionToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Header.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Header.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Header.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Header.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,58 @@
+/**
+ * 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;
+
+/**
+ * class lent from apache rampart
+ */
+public class Header {
+
+    private String name;
+    private String namespace;
+
+    /**
+     * @return Returns the name.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name The name to set.
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * @return Returns the namespace.
+     */
+    public String getNamespace() {
+        return namespace;
+    }
+
+    /**
+     * @param namespace The namespace to set.
+     */
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/HttpsToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/HttpsToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/HttpsToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/HttpsToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,163 @@
+/**
+ * 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.TokenAssertionState;
+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;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+
+/**
+ * class lent from apache rampart
+ */
+public class HttpsToken extends Token {
+
+    public HttpsToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    private boolean requireClientCertificate = false;
+    private boolean httpBasicAuthentication = false;
+    private boolean httpDigestAuthentication = false;
+
+    public boolean isRequireClientCertificate() {
+        return requireClientCertificate;
+    }
+
+    public void setRequireClientCertificate(boolean requireClientCertificate) {
+        this.requireClientCertificate = requireClientCertificate;
+    }
+
+    /**
+     * @return the httpBasicAuthentication
+     */
+    public boolean isHttpBasicAuthentication() {
+        return httpBasicAuthentication;
+    }
+
+    /**
+     * @param httpBasicAuthentication the httpBasicAuthentication to set
+     */
+    public void setHttpBasicAuthentication(boolean httpBasicAuthentication) {
+        this.httpBasicAuthentication = httpBasicAuthentication;
+    }
+
+    /**
+     * @return the httpDigestAuthentication
+     */
+    public boolean isHttpDigestAuthentication() {
+        return httpDigestAuthentication;
+    }
+
+    /**
+     * @param httpDigestAuthentication the httpDigestAuthentication to set
+     */
+    public void setHttpDigestAuthentication(boolean httpDigestAuthentication) {
+        this.httpDigestAuthentication = httpDigestAuthentication;
+    }
+
+    public QName getName() {
+        return spConstants.getHttpsToken();
+    }
+
+    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:HttpsToken
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+
+        if (spConstants.getVersion() == SPConstants.Version.SP_V12) {
+
+            if (isRequireClientCertificate() ||
+                    isHttpBasicAuthentication() ||
+                    isHttpDigestAuthentication()) {
+                // <wsp:Policy>
+                writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
+
+                /*
+                *  The ws policy 1.2 specification states that only one of those should be present, although
+                * a web server (say tomcat) could be normally configured to require both a client certificate and
+                * a http user/pwd authentication. Nevertheless stick to the specification.
+                */
+                if (isHttpBasicAuthentication()) {
+                    writer.writeStartElement(prefix, spConstants.getHttpBasicAuthentication().getLocalPart(), namespaceURI);
+                    writer.writeEndElement();
+                } else if (isHttpDigestAuthentication()) {
+                    writer.writeStartElement(prefix, spConstants.getHttpDigestAuthentication().getLocalPart(), namespaceURI);
+                    writer.writeEndElement();
+                } else if (isRequireClientCertificate()) {
+                    writer.writeStartElement(prefix, spConstants.getRequireClientCertificate().getLocalPart(), namespaceURI);
+                    writer.writeEndElement();
+                }
+                // </wsp:Policy>
+                writer.writeEndElement();
+            }
+        } else {
+            // RequireClientCertificate=".."
+            writer.writeAttribute(spConstants.getRequireClientCertificate().getLocalPart(), Boolean
+                    .toString(isRequireClientCertificate()));
+        }
+
+        writer.writeEndElement();
+        // </sp:HttpsToken>
+    }
+
+    @Override
+    public QName getXmlName() {
+        return null;
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        SecurityEvent.Event[] responsibleAssertionEvents = getResponsibleAssertionEvents();
+        for (int i = 0; i < responsibleAssertionEvents.length; i++) {
+            SecurityEvent.Event responsibleAssertionEvent = responsibleAssertionEvents[i];
+            TokenAssertionState tokenAssertionState = new TokenAssertionState(this, false);
+            Map<Assertion, List<AssertionState>> assertionStates = assertionStateMap.get(responsibleAssertionEvent);
+            addAssertionState(assertionStates, this, tokenAssertionState);
+        }
+    }
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/InitiatorToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/InitiatorToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/InitiatorToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/InitiatorToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,120 @@
+/**
+ * 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 InitiatorToken extends AbstractSecurityAssertion implements TokenWrapper {
+
+    private Token initiatorToken;
+
+    public InitiatorToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the initiatorToken.
+     */
+    public Token getInitiatorToken() {
+        return initiatorToken;
+    }
+
+    /**
+     * @param initiatorToken The initiatorToken to set.
+     */
+    public void setInitiatorToken(Token initiatorToken) {
+        this.initiatorToken = initiatorToken;
+    }
+
+    public void setToken(Token tok) {
+        this.setInitiatorToken(tok);
+    }
+
+    public QName getName() {
+        return spConstants.getInitiatorToken();
+    }
+
+    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:InitiatorToken>
+        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 = getInitiatorToken();
+        if (token == null) {
+            throw new RuntimeException("InitiatorToken doesn't contain any token assertions");
+        }
+        token.serialize(writer);
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:InitiatorToken>
+        writer.writeEndElement();
+    }
+
+    @Override
+    public SecurityEvent.Event[] getResponsibleAssertionEvents() {
+        return new SecurityEvent.Event[]{SecurityEvent.Event.SignatureToken};
+    }
+
+    @Override
+    public void getAssertions(Map<SecurityEvent.Event, Map<Assertion, List<AssertionState>>> assertionStateMap, OperationPolicy operationPolicy) {
+        if (initiatorToken != null) {
+            initiatorToken.setResponsibleAssertionEvents(getResponsibleAssertionEvents());
+            initiatorToken.getAssertions(assertionStateMap, operationPolicy);
+        }
+    }
+}

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

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/IssuedToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/IssuedToken.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/IssuedToken.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/IssuedToken.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,228 @@
+/**
+ * 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.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;
+
+/**
+ * Model bean for the IssuedToken assertion.
+ */
+
+/**
+ * class lent from apache rampart
+ */
+public class IssuedToken extends Token {
+
+    private OMElement issuerEpr;
+
+    private OMElement issuerMex;
+
+    private OMElement rstTemplate;
+
+    boolean requireExternalReference;
+
+    boolean requireInternalReference;
+
+    public IssuedToken(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the issuerEpr.
+     */
+    public OMElement getIssuerEpr() {
+        return issuerEpr;
+    }
+
+    /**
+     * @param issuerEpr The issuerEpr to set.
+     */
+    public void setIssuerEpr(OMElement issuerEpr) {
+        this.issuerEpr = issuerEpr;
+    }
+
+    /**
+     * @return Returns the requireExternalReference.
+     */
+    public boolean isRequireExternalReference() {
+        return requireExternalReference;
+    }
+
+    /**
+     * @param requireExternalReference The requireExternalReference to set.
+     */
+    public void setRequireExternalReference(boolean requireExternalReference) {
+        this.requireExternalReference = requireExternalReference;
+    }
+
+    /**
+     * @return Returns the requireInternalReference.
+     */
+    public boolean isRequireInternalReference() {
+        return requireInternalReference;
+    }
+
+    /**
+     * @param requireInternalReference The requireInternalReference to set.
+     */
+    public void setRequireInternalReference(boolean requireInternalReference) {
+        this.requireInternalReference = requireInternalReference;
+    }
+
+    /**
+     * @return Returns the rstTemplate.
+     */
+    public OMElement getRstTemplate() {
+        return rstTemplate;
+    }
+
+    /**
+     * @param rstTemplate The rstTemplate to set.
+     */
+    public void setRstTemplate(OMElement rstTemplate) {
+        this.rstTemplate = rstTemplate;
+    }
+
+    public QName getName() {
+        return spConstants.getIssuedToken();
+    }
+
+    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:IssuedToken>
+        writer.writeStartElement(prefix, localname, namespaceURI);
+
+        if (writerPrefix == null) {
+            writer.writeNamespace(prefix, namespaceURI);
+        }
+
+        String inclusion = spConstants.getAttributeValueFromInclusion(getInclusion());
+
+        if (inclusion != null) {
+            writer.writeAttribute(prefix, namespaceURI,
+                    SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
+        }
+
+        if (issuerEpr != null) {
+            writer.writeStartElement(prefix, SPConstants.ISSUER,
+                    namespaceURI);
+            issuerEpr.serialize(writer);
+            writer.writeEndElement();
+        }
+
+        if (rstTemplate != null) {
+            // <sp:RequestSecurityTokenTemplate>
+            rstTemplate.serialize(writer);
+
+        }
+
+        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;
+        }
+
+        if (isRequireExternalReference() || isRequireInternalReference() ||
+                this.isDerivedKeys()) {
+
+            // <wsp:Policy>
+            writer.writeStartElement(wspPrefix, policyLocalName,
+                    policyNamespaceURI);
+
+            if (wspWriterPrefix == null) {
+                // xmlns:wsp=".."
+                writer.writeNamespace(wspPrefix, policyNamespaceURI);
+            }
+
+            if (isRequireExternalReference()) {
+                // <sp:RequireExternalReference />
+                writer.writeEmptyElement(prefix, SPConstants.REQUIRE_EXTERNAL_REFERNCE,
+                        namespaceURI);
+            }
+
+            if (isRequireInternalReference()) {
+                // <sp:RequireInternalReference />
+                writer.writeEmptyElement(prefix, SPConstants.REQUIRE_INTERNAL_REFERNCE,
+                        namespaceURI);
+            }
+
+            if (this.isDerivedKeys()) {
+                // <sp:RequireDerivedKeys />
+                writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS,
+                        namespaceURI);
+            }
+
+            // <wsp:Policy>
+            writer.writeEndElement();
+        }
+
+        // </sp:IssuedToken>
+        writer.writeEndElement();
+    }
+
+    public OMElement getIssuerMex() {
+        return issuerMex;
+    }
+
+    public void setIssuerMex(OMElement issuerMex) {
+        this.issuerMex = issuerMex;
+    }
+
+    @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/IssuedToken.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Layout.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Layout.java?rev=1172285&view=auto
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Layout.java (added)
+++ webservices/wss4j/branches/swssf/streaming-ws-policy/src/main/java/org/swssf/policy/secpolicy/model/Layout.java Sun Sep 18 13:51:23 2011
@@ -0,0 +1,128 @@
+/**
+ * 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 Layout extends AbstractSecurityAssertion {
+
+    private String value = SPConstants.LAYOUT_LAX;
+
+    public Layout(SPConstants spConstants) {
+        setVersion(spConstants);
+    }
+
+    /**
+     * @return Returns the value.
+     */
+    public String getValue() {
+        return value;
+    }
+
+    /**
+     * @param value The value to set.
+     */
+    public void setValue(String value) {
+        if (SPConstants.LAYOUT_LAX.equals(value)
+                || SPConstants.LAYOUT_STRICT.equals(value)
+                || SPConstants.LAYOUT_LAX_TIMESTAMP_FIRST.equals(value)
+                || SPConstants.LAYOUT_LAX_TIMESTAMP_LAST.equals(value)) {
+            this.value = value;
+        } else {
+            // throw new WSSPolicyException("Incorrect layout value : " +
+            // value);
+        }
+    }
+
+    public QName getName() {
+        return spConstants.getLayout();
+    }
+
+    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:Layout>
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+        // <wsp:Policy>
+        writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY
+                .getLocalPart(), SPConstants.POLICY.getNamespaceURI());
+
+        // .. <sp:Strict /> | <sp:Lax /> | <sp:LaxTsFirst /> | <sp:LaxTsLast /> ..
+        if (SPConstants.LAYOUT_STRICT.equals(value)) {
+            writer.writeStartElement(prefix, SPConstants.LAYOUT_STRICT, namespaceURI);
+
+        } else if (SPConstants.LAYOUT_LAX.equals(value)) {
+            writer.writeStartElement(prefix, SPConstants.LAYOUT_LAX, namespaceURI);
+
+        } else if (SPConstants.LAYOUT_LAX_TIMESTAMP_FIRST.equals(value)) {
+            writer.writeStartElement(prefix, SPConstants.LAYOUT_LAX_TIMESTAMP_FIRST, namespaceURI);
+
+        } else if (SPConstants.LAYOUT_LAX_TIMESTAMP_LAST.equals(value)) {
+            writer.writeStartElement(prefix, SPConstants.LAYOUT_LAX_TIMESTAMP_LAST, namespaceURI);
+        }
+
+        writer.writeEndElement();
+
+        // </wsp:Policy>
+        writer.writeEndElement();
+
+        // </sp:Layout>
+        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/Layout.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message