Added: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust10Test.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust10Test.java?rev=1210203&view=auto
==============================================================================
--- 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust10Test.java
 (added)
+++ 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust10Test.java
 Sun Dec  4 20:33:05 2011
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ws.secpolicy.tests;
+
+import org.apache.neethi.*;
+import org.apache.ws.secpolicy.SP11Constants;
+import org.apache.ws.secpolicy.model.Trust10;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author $Author: giger $
+ * @version $Revision: 1181995 $ $Date: 2011-10-11 20:03:00 +0200 (Tue, 11 Oct 
2011) $
+ */
+public class Trust10Test extends AbstractTestBase {
+
+    public void testTrust10_11() throws Exception {
+        String fileName = "Trust10.xml";
+        String policyFile = loadPolicyFile("policy/model/sp11/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp11/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp11/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof Trust10);
+            Trust10 trust10 = (Trust10) alternative.get(0);
+            assertFalse(trust10.isNormalized());
+            assertTrue(trust10.isIgnorable());
+            assertTrue(trust10.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, trust10.getType());
+            assertEquals(SP11Constants.TRUST_10, trust10.getName());
+            assertTrue(trust10.isMustSupportClientChallenge());
+            assertTrue(trust10.isMustSupportServerChallenge());
+            assertTrue(trust10.isRequireClientEntropy());
+            assertTrue(trust10.isRequireServerEntropy());
+            assertTrue(trust10.isMustSupportIssuedTokens());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        Trust10 trust13 = (Trust10) policyComponentIterator.next();
+        assertTrue(trust13.isNormalized());
+        assertTrue(trust13.isIgnorable());
+        assertFalse(trust13.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, trust13.getType());
+        assertEquals(SP11Constants.TRUST_10, trust13.getName());
+        assertTrue(trust13.isMustSupportClientChallenge());
+        assertTrue(trust13.isMustSupportServerChallenge());
+        assertTrue(trust13.isRequireClientEntropy());
+        assertTrue(trust13.isRequireServerEntropy());
+        assertTrue(trust13.isMustSupportIssuedTokens());
+    }
+}

Added: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust13Test.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust13Test.java?rev=1210203&view=auto
==============================================================================
--- 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust13Test.java
 (added)
+++ 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust13Test.java
 Sun Dec  4 20:33:05 2011
@@ -0,0 +1,180 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ws.secpolicy.tests;
+
+import org.apache.neethi.*;
+import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.SP13Constants;
+import org.apache.ws.secpolicy.model.Trust13;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class Trust13Test extends AbstractTestBase {
+
+    public void testTrust13_12() throws Exception {
+        String fileName = "Trust13.xml";
+        String policyFile = loadPolicyFile("policy/model/sp12/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp12/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp12/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof Trust13);
+            Trust13 trust13 = (Trust13) alternative.get(0);
+            assertFalse(trust13.isNormalized());
+            assertTrue(trust13.isIgnorable());
+            assertTrue(trust13.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, trust13.getType());
+            assertEquals(SP12Constants.TRUST_13, trust13.getName());
+            assertTrue(trust13.isMustSupportClientChallenge());
+            assertTrue(trust13.isMustSupportServerChallenge());
+            assertTrue(trust13.isRequireClientEntropy());
+            assertTrue(trust13.isRequireServerEntropy());
+            assertTrue(trust13.isMustSupportIssuedTokens());
+            assertTrue(trust13.isRequireRequestSecurityTokenCollection());
+            assertTrue(trust13.isRequireAppliesTo());
+            assertFalse(trust13.isScopePolicy15());
+            assertFalse(trust13.isMustSupportInteractiveChallenge());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        Trust13 trust13 = (Trust13) policyComponentIterator.next();
+        assertTrue(trust13.isNormalized());
+        assertTrue(trust13.isIgnorable());
+        assertFalse(trust13.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, trust13.getType());
+        assertEquals(SP12Constants.TRUST_13, trust13.getName());
+        assertTrue(trust13.isMustSupportClientChallenge());
+        assertTrue(trust13.isMustSupportServerChallenge());
+        assertTrue(trust13.isRequireClientEntropy());
+        assertTrue(trust13.isRequireServerEntropy());
+        assertTrue(trust13.isMustSupportIssuedTokens());
+        assertTrue(trust13.isRequireRequestSecurityTokenCollection());
+        assertTrue(trust13.isRequireAppliesTo());
+        assertFalse(trust13.isScopePolicy15());
+        assertFalse(trust13.isMustSupportInteractiveChallenge());
+    }
+
+    public void testTrust13_13() throws Exception {
+        String fileName = "Trust13.xml";
+        String policyFile = loadPolicyFile("policy/model/sp13/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp13/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp13/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof Trust13);
+            Trust13 trust13 = (Trust13) alternative.get(0);
+            assertFalse(trust13.isNormalized());
+            assertTrue(trust13.isIgnorable());
+            assertTrue(trust13.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, trust13.getType());
+            assertEquals(SP13Constants.TRUST_13, trust13.getName());
+            assertTrue(trust13.isMustSupportClientChallenge());
+            assertTrue(trust13.isMustSupportServerChallenge());
+            assertTrue(trust13.isRequireClientEntropy());
+            assertTrue(trust13.isRequireServerEntropy());
+            assertTrue(trust13.isMustSupportIssuedTokens());
+            assertTrue(trust13.isRequireRequestSecurityTokenCollection());
+            assertTrue(trust13.isRequireAppliesTo());
+            assertTrue(trust13.isScopePolicy15());
+            assertTrue(trust13.isMustSupportInteractiveChallenge());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        Trust13 trust13 = (Trust13) policyComponentIterator.next();
+        assertTrue(trust13.isNormalized());
+        assertTrue(trust13.isIgnorable());
+        assertFalse(trust13.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, trust13.getType());
+        assertEquals(SP13Constants.TRUST_13, trust13.getName());
+        assertTrue(trust13.isMustSupportClientChallenge());
+        assertTrue(trust13.isMustSupportServerChallenge());
+        assertTrue(trust13.isRequireClientEntropy());
+        assertTrue(trust13.isRequireServerEntropy());
+        assertTrue(trust13.isMustSupportIssuedTokens());
+        assertTrue(trust13.isRequireRequestSecurityTokenCollection());
+        assertTrue(trust13.isRequireAppliesTo());
+        assertTrue(trust13.isScopePolicy15());
+        assertTrue(trust13.isMustSupportInteractiveChallenge());
+    }
+}

Propchange: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Trust13Test.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/UsernameTokenTest.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/UsernameTokenTest.java?rev=1210203&view=auto
==============================================================================
--- 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/UsernameTokenTest.java
 (added)
+++ 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/UsernameTokenTest.java
 Sun Dec  4 20:33:05 2011
@@ -0,0 +1,155 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ws.secpolicy.tests;
+
+import org.apache.neethi.*;
+import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.model.UsernameToken;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class UsernameTokenTest extends AbstractTestBase {
+
+    public void testUsernameToken12() throws Exception {
+        String fileName = "UsernameToken.xml";
+        String policyFile = loadPolicyFile("policy/model/sp12/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp12/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp12/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof UsernameToken);
+            UsernameToken usernameToken = (UsernameToken) alternative.get(0);
+            assertFalse(usernameToken.isNormalized());
+            assertTrue(usernameToken.isIgnorable());
+            assertTrue(usernameToken.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, usernameToken.getType());
+            assertEquals(SP12Constants.USERNAME_TOKEN, 
usernameToken.getName());
+            assertEquals(UsernameToken.PasswordType.HashPassword, 
usernameToken.getPasswordType());
+            assertEquals(UsernameToken.UsernameTokenType.WssUsernameToken10, 
usernameToken.getUsernameTokenType());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        UsernameToken usernameToken = (UsernameToken) 
policyComponentIterator.next();
+        assertTrue(usernameToken.isNormalized());
+        assertTrue(usernameToken.isIgnorable());
+        assertFalse(usernameToken.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, usernameToken.getType());
+        assertEquals(SP12Constants.USERNAME_TOKEN, usernameToken.getName());
+        assertEquals(UsernameToken.PasswordType.HashPassword, 
usernameToken.getPasswordType());
+        assertEquals(UsernameToken.UsernameTokenType.WssUsernameToken10, 
usernameToken.getUsernameTokenType());
+    }
+
+    public void testUsernameToken13() throws Exception {
+        String fileName = "UsernameToken.xml";
+        String policyFile = loadPolicyFile("policy/model/sp13/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp13/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp13/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof UsernameToken);
+            UsernameToken usernameToken = (UsernameToken) alternative.get(0);
+            assertFalse(usernameToken.isNormalized());
+            assertTrue(usernameToken.isIgnorable());
+            assertTrue(usernameToken.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, usernameToken.getType());
+            assertEquals(SP12Constants.USERNAME_TOKEN, 
usernameToken.getName());
+            assertTrue(usernameToken.isCreated());
+            assertTrue(usernameToken.isNonce());
+            assertNull(usernameToken.getPasswordType());
+            assertEquals(UsernameToken.UsernameTokenType.WssUsernameToken10, 
usernameToken.getUsernameTokenType());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        UsernameToken usernameToken = (UsernameToken) 
policyComponentIterator.next();
+        assertTrue(usernameToken.isNormalized());
+        assertTrue(usernameToken.isIgnorable());
+        assertFalse(usernameToken.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, usernameToken.getType());
+        assertEquals(SP12Constants.USERNAME_TOKEN, usernameToken.getName());
+        assertTrue(usernameToken.isCreated());
+        assertTrue(usernameToken.isNonce());
+        assertNull(usernameToken.getPasswordType());
+        assertEquals(UsernameToken.UsernameTokenType.WssUsernameToken10, 
usernameToken.getUsernameTokenType());
+    }
+}

Propchange: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/UsernameTokenTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss10Test.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss10Test.java?rev=1210203&view=auto
==============================================================================
--- 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss10Test.java
 (added)
+++ 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss10Test.java
 Sun Dec  4 20:33:05 2011
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ws.secpolicy.tests;
+
+import org.apache.neethi.*;
+import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.model.Wss10;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class Wss10Test extends AbstractTestBase {
+
+    public void testWss10() throws Exception {
+        String fileName = "Wss10.xml";
+        String policyFile = loadPolicyFile("policy/model/sp12/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp12/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp12/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof Wss10);
+            Wss10 wss10 = (Wss10) alternative.get(0);
+            assertFalse(wss10.isNormalized());
+            assertTrue(wss10.isIgnorable());
+            assertTrue(wss10.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, wss10.getType());
+            assertEquals(SP12Constants.WSS10, wss10.getName());
+            assertTrue(wss10.isMustSupportRefEmbeddedToken());
+            assertTrue(wss10.isMustSupportRefExternalURI());
+            assertTrue(wss10.isMustSupportRefIssuerSerial());
+            assertTrue(wss10.isMustSupportRefKeyIdentifier());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        Wss10 wss10 = (Wss10) policyComponentIterator.next();
+        assertTrue(wss10.isNormalized());
+        assertTrue(wss10.isIgnorable());
+        assertFalse(wss10.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, wss10.getType());
+        assertEquals(SP12Constants.WSS10, wss10.getName());
+        assertTrue(wss10.isMustSupportRefEmbeddedToken());
+        assertTrue(wss10.isMustSupportRefExternalURI());
+        assertTrue(wss10.isMustSupportRefIssuerSerial());
+        assertTrue(wss10.isMustSupportRefKeyIdentifier());
+    }
+}

Propchange: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss10Test.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss11Test.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss11Test.java?rev=1210203&view=auto
==============================================================================
--- 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss11Test.java
 (added)
+++ 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss11Test.java
 Sun Dec  4 20:33:05 2011
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ws.secpolicy.tests;
+
+import org.apache.neethi.*;
+import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.model.Wss11;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class Wss11Test extends AbstractTestBase {
+
+    public void testWss11() throws Exception {
+        String fileName = "Wss11.xml";
+        String policyFile = loadPolicyFile("policy/model/sp12/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp12/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp12/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof Wss11);
+            Wss11 wss11 = (Wss11) alternative.get(0);
+            assertFalse(wss11.isNormalized());
+            assertTrue(wss11.isIgnorable());
+            assertTrue(wss11.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, wss11.getType());
+            assertEquals(SP12Constants.WSS11, wss11.getName());
+            assertTrue(wss11.isMustSupportRefEmbeddedToken());
+            assertTrue(wss11.isMustSupportRefExternalURI());
+            assertTrue(wss11.isMustSupportRefIssuerSerial());
+            assertTrue(wss11.isMustSupportRefKeyIdentifier());
+            assertTrue(wss11.isMustSupportRefEncryptedKey());
+            assertTrue(wss11.isMustSupportRefThumbprint());
+            assertTrue(wss11.isRequireSignatureConfirmation());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        Wss11 wss11 = (Wss11) policyComponentIterator.next();
+        assertTrue(wss11.isNormalized());
+        assertTrue(wss11.isIgnorable());
+        assertFalse(wss11.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, wss11.getType());
+        assertEquals(SP12Constants.WSS11, wss11.getName());
+        assertTrue(wss11.isMustSupportRefEmbeddedToken());
+        assertTrue(wss11.isMustSupportRefExternalURI());
+        assertTrue(wss11.isMustSupportRefIssuerSerial());
+        assertTrue(wss11.isMustSupportRefKeyIdentifier());
+        assertTrue(wss11.isMustSupportRefEncryptedKey());
+        assertTrue(wss11.isMustSupportRefThumbprint());
+        assertTrue(wss11.isRequireSignatureConfirmation());
+    }
+}

Propchange: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/Wss11Test.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/X509TokenTest.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/X509TokenTest.java?rev=1210203&view=auto
==============================================================================
--- 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/X509TokenTest.java
 (added)
+++ 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/X509TokenTest.java
 Sun Dec  4 20:33:05 2011
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ws.secpolicy.tests;
+
+import org.apache.neethi.*;
+import org.apache.ws.secpolicy.SP12Constants;
+import org.apache.ws.secpolicy.model.X509Token;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author $Author$
+ * @version $Revision$ $Date$
+ */
+public class X509TokenTest extends AbstractTestBase {
+
+    public void testX509Token() throws Exception {
+        String fileName = "X509Token.xml";
+        String policyFile = loadPolicyFile("policy/model/sp12/" + fileName);
+        String serializedPolicyRefereneFile = 
loadPolicyFile("policy/model/sp12/serialized/" + fileName);
+        String normalizedPolicyReferenceFile = 
loadPolicyFile("policy/model/sp12/normalized/" + fileName);
+        Policy policy = loadPolicy(policyFile);
+        String serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, serializedPolicyRefereneFile);
+
+        Iterator<List<Assertion>> alternativeIterator = 
policy.getAlternatives();
+        int count = 0;
+        while (alternativeIterator.hasNext()) {
+            List<Assertion> alternative = alternativeIterator.next();
+            assertEquals(1, alternative.size());
+            assertTrue(alternative.get(0) instanceof X509Token);
+            X509Token x509Token = (X509Token) alternative.get(0);
+            assertFalse(x509Token.isNormalized());
+            assertTrue(x509Token.isIgnorable());
+            assertTrue(x509Token.isOptional());
+            assertEquals(Constants.TYPE_ASSERTION, x509Token.getType());
+            assertEquals(SP12Constants.X509_TOKEN, x509Token.getName());
+            assertTrue(x509Token.isRequireEmbeddedTokenReference());
+            assertTrue(x509Token.isRequireIssuerSerialReference());
+            assertTrue(x509Token.isRequireKeyIdentifierReference());
+            assertTrue(x509Token.isRequireThumbprintReference());
+            assertEquals(X509Token.TokenType.WssX509V1Token11, 
x509Token.getTokenType());
+            count++;
+        }
+        assertEquals(1, count);
+
+        policy = policy.normalize(true);
+        serializedPolicy = serializePolicy(policy);
+        assertXMLisEqual(serializedPolicy, normalizedPolicyReferenceFile);
+
+        alternativeIterator = policy.getAlternatives();
+        List<Assertion> alternative = alternativeIterator.next();
+        assertEquals(0, alternative.size());
+
+        List<PolicyComponent> policyComponents = policy.getPolicyComponents();
+        assertEquals(1, policyComponents.size());
+        PolicyOperator policyOperator = (PolicyOperator) 
policyComponents.get(0);
+        policyComponents = policyOperator.getPolicyComponents();
+        assertEquals(2, policyComponents.size());
+        All all = (All) policyComponents.get(0);
+        List<PolicyComponent> policyComponentsAll = all.getAssertions();
+        assertEquals(0, policyComponentsAll.size());
+
+        all = (All) policyComponents.get(1);
+        policyComponentsAll = all.getAssertions();
+        assertEquals(1, policyComponentsAll.size());
+
+        Iterator<PolicyComponent> policyComponentIterator = 
policyComponentsAll.iterator();
+        X509Token x509Token = (X509Token) policyComponentIterator.next();
+        assertTrue(x509Token.isNormalized());
+        assertTrue(x509Token.isIgnorable());
+        assertFalse(x509Token.isOptional());
+        assertEquals(Constants.TYPE_ASSERTION, x509Token.getType());
+        assertEquals(SP12Constants.X509_TOKEN, x509Token.getName());
+        assertTrue(x509Token.isRequireEmbeddedTokenReference());
+        assertTrue(x509Token.isRequireIssuerSerialReference());
+        assertTrue(x509Token.isRequireKeyIdentifierReference());
+        assertTrue(x509Token.isRequireThumbprintReference());
+        assertEquals(X509Token.TokenType.WssX509V1Token11, 
x509Token.getTokenType());
+    }
+}

Propchange: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/java/org/apache/ws/secpolicy/tests/X509TokenTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
webservices/wss4j/branches/swssf/rampart-policy/src/test/resources/policy/WSP15_432-compact.xml
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/rampart-policy/src/test/resources/policy/WSP15_432-compact.xml?rev=1210203&view=auto
==============================================================================
--- 
webservices/wss4j/branches/swssf/rampart-policy/src/test/resources/policy/WSP15_432-compact.xml
 (added)
+++ 
webservices/wss4j/branches/swssf/rampart-policy/src/test/resources/policy/WSP15_432-compact.xml
 Sun Dec  4 20:33:05 2011
@@ -0,0 +1,65 @@
+<wsp:Policy
+        xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702";
+        xmlns:wsp="http://www.w3.org/ns/ws-policy";>
+    <sp:SymmetricBinding wsp:Optional="true">
+        <wsp:Policy>
+            <sp:ProtectionToken>
+                <wsp:Policy>
+                    <wsp:ExactlyOne>
+                        <sp:HttpsToken>
+                            <wsp:Policy/>
+                        </sp:HttpsToken>
+                        <sp:X509Token 
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Once";>
+                            <sp:IssuerName>xs:anyURI</sp:IssuerName>
+                            <wsp:Policy>
+                                <wsp:ExactlyOne>
+                                    <wsp:All>
+                                        <sp:RequireDerivedKeys/>
+                                        <sp:RequireKeyIdentifierReference/>
+                                        <sp:RequireIssuerSerialReference/>
+                                        <sp:RequireEmbeddedTokenReference/>
+                                        <sp:RequireThumbprintReference/>
+                                        <sp:WssX509V3Token10/>
+                                    </wsp:All>
+                                    <wsp:All>
+                                        <sp:RequireImpliedDerivedKeys/>
+                                        <sp:RequireKeyIdentifierReference/>
+                                        <sp:RequireIssuerSerialReference/>
+                                        <sp:RequireEmbeddedTokenReference/>
+                                        <sp:RequireThumbprintReference/>
+                                        <sp:WssX509PkiPathV1Token11/>
+                                    </wsp:All>
+                                </wsp:ExactlyOne>
+                            </wsp:Policy>
+                        </sp:X509Token>
+                    </wsp:ExactlyOne>
+                </wsp:Policy>
+            </sp:ProtectionToken>
+            <sp:AlgorithmSuite>
+                <wsp:Policy>
+                    <wsp:ExactlyOne>
+                        <sp:Basic256/>
+                        <sp:TripleDesRsa15/>
+                        <sp:InclusiveC14N/>
+                        <sp:SOAPNormalization10/>
+                        <sp:STRTransform10/>
+                        <sp:XPath10/>
+                    </wsp:ExactlyOne>
+                </wsp:Policy>
+            </sp:AlgorithmSuite>
+            <sp:Layout>
+                <wsp:Policy>
+                    <wsp:ExactlyOne>
+                        <sp:Strict/>
+                        <sp:Lax/>
+                    </wsp:ExactlyOne>
+                </wsp:Policy>
+            </sp:Layout>
+            <sp:IncludeTimestamp/>
+        </wsp:Policy>
+    </sp:SymmetricBinding>
+    <sp:SignedParts wsp:Ignorable="true">
+        <sp:Body/>
+        <sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
+    </sp:SignedParts>
+</wsp:Policy>
\ No newline at end of file


Reply via email to