You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by we...@apache.org on 2006/01/27 16:06:28 UTC
svn commit: r372868 - in /webservices/wss4j/trunk/test/policy: ./
SecurityPolicyBindings.xml SecurityPolicyBindingsSymm.xml
SecurityPolicyMsg.xml WSSPolicyProcessorTest.java
Author: werner
Date: Fri Jan 27 07:06:24 2006
New Revision: 372868
URL: http://svn.apache.org/viewcvs?rev=372868&view=rev
Log:
Add a test case, copied from Ruchith's test case.
Added:
webservices/wss4j/trunk/test/policy/
webservices/wss4j/trunk/test/policy/SecurityPolicyBindings.xml
webservices/wss4j/trunk/test/policy/SecurityPolicyBindingsSymm.xml
webservices/wss4j/trunk/test/policy/SecurityPolicyMsg.xml
webservices/wss4j/trunk/test/policy/WSSPolicyProcessorTest.java
Added: webservices/wss4j/trunk/test/policy/SecurityPolicyBindings.xml
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/policy/SecurityPolicyBindings.xml?rev=372868&view=auto
==============================================================================
--- webservices/wss4j/trunk/test/policy/SecurityPolicyBindings.xml (added)
+++ webservices/wss4j/trunk/test/policy/SecurityPolicyBindings.xml Fri Jan 27 07:06:24 2006
@@ -0,0 +1,50 @@
+
+<!-- Example Endpoint Policy -->
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+<sp:AsymmetricBinding>
+ <wsp:Policy>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always" />
+ </wsp:Policy> </sp:RecipientToken>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always" />
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic256 />
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict />
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp />
+ <sp:EncryptBeforeSigning />
+ <sp:EncryptSignature />
+ <sp:ProtectTokens />
+ <sp:SignedSupportingTokens>
+ <wsp:Policy>
+ <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Once" />
+ </wsp:Policy>
+ </sp:SignedSupportingTokens>
+ <sp:SignedEndorsingSupportingTokens>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Once" />
+ </wsp:Policy>
+ </sp:SignedEndorsingSupportingTokens>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss11>
+ <wsp:Policy>
+ <sp:RequireSignatureConfirmation />
+ </wsp:Policy>
+ </sp:Wss11>
+ </wsp:Policy>
+
+
\ No newline at end of file
Added: webservices/wss4j/trunk/test/policy/SecurityPolicyBindingsSymm.xml
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/policy/SecurityPolicyBindingsSymm.xml?rev=372868&view=auto
==============================================================================
--- webservices/wss4j/trunk/test/policy/SecurityPolicyBindingsSymm.xml (added)
+++ webservices/wss4j/trunk/test/policy/SecurityPolicyBindingsSymm.xml Fri Jan 27 07:06:24 2006
@@ -0,0 +1,43 @@
+<!-- Example Endpoint Policy -->
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+<sp:SymmetricBinding>
+<wsp:Policy>
+<sp:ProtectionToken>
+<wsp:Policy>
+<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always"/>
+</wsp:Policy>
+</sp:ProtectionToken>
+<sp:AlgorithmSuite>
+<wsp:Policy>
+<sp:Basic256 />
+</wsp:Policy>
+</sp:AlgorithmSuite>
+<sp:Layout>
+<wsp:Policy>
+<sp:Strict />
+</wsp:Policy>
+</sp:Layout>
+<sp:IncludeTimestamp />
+<sp:EncryptBeforeSigning />
+<sp:EncryptSignature />
+<sp:ProtectTokens />
+<sp:SignedSupportingTokens>
+<wsp:Policy>
+<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Once" />
+</wsp:Policy>
+</sp:SignedSupportingTokens>
+<!--<sp:SignedEndorsingSupportingTokens>
+<wsp:Policy>
+<sp:X509V3Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/IncludeToken/Once" />
+</wsp:Policy>
+</sp:SignedEndorsingSupportingTokens> -->
+</wsp:Policy>
+</sp:SymmetricBinding>
+<sp:Wss11>
+<wsp:Policy>
+<sp:RequireSignatureConfirmation />
+</wsp:Policy>
+</sp:Wss11>
+</wsp:Policy>
Added: webservices/wss4j/trunk/test/policy/SecurityPolicyMsg.xml
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/policy/SecurityPolicyMsg.xml?rev=372868&view=auto
==============================================================================
--- webservices/wss4j/trunk/test/policy/SecurityPolicyMsg.xml (added)
+++ webservices/wss4j/trunk/test/policy/SecurityPolicyMsg.xml Fri Jan 27 07:06:24 2006
@@ -0,0 +1,19 @@
+<!-- Example Endpoint Policy -->
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
+
+ <!-- Example Message Policy -->
+
+ <sp:SignedParts>
+ <sp:Header Name="Header1" Namespace="uri:namespace_1" />
+ <sp:Header Name="Header2" Namespace="uri:namespace_2" />
+ <sp:Body/>
+ </sp:SignedParts>
+ <sp:EncryptedParts>
+ <sp:Header Name="Header2" Namespace="uri:namespace_2" />
+ <sp:Body/>
+ </sp:EncryptedParts>
+
+ </wsp:Policy>
+
\ No newline at end of file
Added: webservices/wss4j/trunk/test/policy/WSSPolicyProcessorTest.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/test/policy/WSSPolicyProcessorTest.java?rev=372868&view=auto
==============================================================================
--- webservices/wss4j/trunk/test/policy/WSSPolicyProcessorTest.java (added)
+++ webservices/wss4j/trunk/test/policy/WSSPolicyProcessorTest.java Fri Jan 27 07:06:24 2006
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package policy;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.security.policy.Constants;
+import org.apache.ws.security.policy.model.PolicyEngineData;
+import org.apache.ws.security.policy.model.RootPolicyEngineData;
+import org.apache.ws.security.policy.model.SignedEncryptedParts;
+import org.apache.ws.security.policy.model.SymmetricBinding;
+import org.apache.ws.security.policy.model.Wss11;
+import org.apache.ws.security.policy.parser.WSSPolicyProcessor;
+
+public class WSSPolicyProcessorTest extends TestCase {
+
+ public WSSPolicyProcessorTest(String name) {
+ super(name);
+ }
+
+ public void testSymmetricBinding() {
+ try {
+ WSSPolicyProcessor processor = new WSSPolicyProcessor();
+ if (!processor.setup()) {
+ return;
+ }
+ String[] files = new String[2];
+ files[0] = "test/policy/SecurityPolicyBindingsSymm.xml";
+ files[1] = "test/policy/SecurityPolicyMsg.xml";
+ processor.go(files);
+
+ RootPolicyEngineData rootPolicyEngineData = (RootPolicyEngineData)processor.secProcessorContext.getPedStack().get(0);
+ assertNotNull("RootPolicyEngineData missing", rootPolicyEngineData);
+
+ ArrayList peds = rootPolicyEngineData.getTopLevelPEDs();
+ assertEquals("Incrrect number of PolicyEngineData", 4, peds.size());
+
+ Iterator pedIter = peds.iterator();
+ boolean symmBindingfound = false, wss11found = false, signedPartsFound = false, encryptedPartsFound = false;
+ while (pedIter.hasNext()) {
+ PolicyEngineData ped = (PolicyEngineData) pedIter.next();
+ if(ped instanceof SymmetricBinding) {
+ symmBindingfound = true;
+ SymmetricBinding symmetricBinding = (SymmetricBinding)ped;
+ assertEquals("Incorrect layout",Constants.LAYOUT_STRICT ,symmetricBinding.getLayout().getValue());
+ } else if(ped instanceof Wss11) {
+ wss11found = true;
+ Wss11 wss11 = (Wss11)ped;
+ assertEquals("Signature confirmation must be true", true,
+ wss11.isRequireSignatureConfirmation());
+ } else if(ped instanceof SignedEncryptedParts) {
+ SignedEncryptedParts parts = (SignedEncryptedParts)ped;
+ if(parts.isSignedParts()) {
+ signedPartsFound = true;
+ assertEquals(
+ "Incorrect number of headers in SignedParts",
+ 2, parts.getHeaders().size());
+ } else {
+ encryptedPartsFound = true;
+ assertEquals(
+ "Incorrect number of headers in EncryptedParts",
+ 1, parts.getHeaders().size());
+ }
+ }
+ }
+ assertTrue("SignedParts missing", signedPartsFound);
+ assertTrue("EncryptedParts missing", encryptedPartsFound);
+ assertTrue("SymmetricBinding missing", symmBindingfound);
+ assertTrue("Wss11 missing", wss11found);
+ System.out.println("Success");
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org