axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r350307 - in /webservices/axis2/trunk/java/modules/security/test/org: ./ apache/ apache/axis2/ apache/axis2/security/ apache/axis2/security/handler/ apache/axis2/security/handler/config/
Date Thu, 01 Dec 2005 19:40:07 GMT
Author: ruchithf
Date: Thu Dec  1 11:38:57 2005
New Revision: 350307

URL: http://svn.apache.org/viewcvs?rev=350307&view=rev
Log:
Oops ... just found some test cases that I have not added. These test the outflow and inflow
security configuration classes


Added:
    webservices/axis2/trunk/java/modules/security/test/org/
    webservices/axis2/trunk/java/modules/security/test/org/apache/
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/InflowConfigurationTest.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/OutflowConfigurationTest.java

Added: webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/InflowConfigurationTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/InflowConfigurationTest.java?rev=350307&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/InflowConfigurationTest.java
(added)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/InflowConfigurationTest.java
Thu Dec  1 11:38:57 2005
@@ -0,0 +1,73 @@
+/*
+ * 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 org.apache.axis2.security.handler.config;
+
+import org.apache.axis2.security.handler.WSSHandlerConstants;
+import org.apache.ws.security.handler.WSHandlerConstants;
+
+import junit.framework.TestCase;
+
+public class InflowConfigurationTest extends TestCase {
+
+	public InflowConfigurationTest() {
+		super();
+	}
+
+	public InflowConfigurationTest(String name) {
+		super(name);
+	}
+	
+	public void testGetProperty() {
+		String actionItems = "Timestamp Signature Encrypt";
+		String sigPropFile = "sig.properties";
+		String decPropFile = "enc.properties";
+		String pwcb = "org.apache.axis2.security.PWCallback";
+		
+		InflowConfiguration ifc = new InflowConfiguration();
+		
+		ifc.setActionItems(actionItems);
+		ifc.setSignaturePropFile(sigPropFile);
+		ifc.setDecryptionPropFile(decPropFile);
+		ifc.setPasswordCallbackClass(pwcb);
+		
+		// Check whether the props are there
+		assertTrue("Action items missing", -1 < ifc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSSHandlerConstants.ACTION_ITEMS + ">"
+								+ actionItems + "</"
+								+ WSSHandlerConstants.ACTION_ITEMS + ">"));
+		
+		assertTrue("passwordCallbackClass missing", -1 < ifc.getProperty().getParameterElement()
+				.toString().indexOf(
+						"<" + WSHandlerConstants.PW_CALLBACK_CLASS + ">" + pwcb
+								+ "</" + WSHandlerConstants.PW_CALLBACK_CLASS
+								+ ">"));
+
+		assertTrue("sigPropFile missing", -1 < ifc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.SIG_PROP_FILE + ">"
+								+ sigPropFile + "</"
+								+ WSHandlerConstants.SIG_PROP_FILE + ">"));
+		
+		assertTrue("decPropFile missing", -1 < ifc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.DEC_PROP_FILE + ">"
+								+ decPropFile + "</"
+								+ WSHandlerConstants.DEC_PROP_FILE + ">"));
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/OutflowConfigurationTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/OutflowConfigurationTest.java?rev=350307&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/OutflowConfigurationTest.java
(added)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/handler/config/OutflowConfigurationTest.java
Thu Dec  1 11:38:57 2005
@@ -0,0 +1,198 @@
+/*
+ * 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 org.apache.axis2.security.handler.config;
+
+import org.apache.axis2.security.handler.WSSHandlerConstants;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.handler.WSHandlerConstants;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the org.apache.axis2.security.handler.config.OutflowConfiguration
+ * 
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class OutflowConfigurationTest extends TestCase {
+
+	public OutflowConfigurationTest() {
+		super();
+	}
+
+	public OutflowConfigurationTest(String name) {
+		super(name);
+	}
+
+	/**
+	 * This sets all the possible properties that can be set with 
+	 * the outflow configuration
+	 */
+	public void testGetProperty() {
+
+		OutflowConfiguration ofc = new OutflowConfiguration();
+
+		String actionItems = "Timestamp Signature Encrypt";
+		String user = "alice";
+		String pwcb = "org.apache.axis2.security.PWCallback";
+		String sigKeyId = "interop.properties";
+		String sigParts = "{Element}{http://schemas.xmlsoap.org/ws/2004/08/"
+				+ "addressing}MessageID;{Element}{http://docs.oasis-open.org/wss/"
+				+ "2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp";
+		String optimizeParts = "//xenc:EncryptedData/xenc:CipherData/xenc:CipherValue";
+		String embeddedKeyCallbackClass = "org.apache.axis2.security.PWCallback";
+		String encrUser = "bob";
+		String samlPropFile = "saml.properties";
+		String sigPropFile = "sig.properties";
+		String encPropFile = "enc.properties";
+
+		// Setting the properties in the ofc
+		ofc.setActionItems(actionItems);
+		ofc.setUser(user);
+		ofc.setPasswordCallbackClass(pwcb);
+		ofc.setSignatureKeyIdentifier(sigKeyId);
+		ofc.setEncryptionKeyIdentifier(WSSHandlerConstants.SKI_KEY_IDENTIFIER);
+		ofc.setSignatureParts(sigParts);
+		ofc.setOptimizeParts(optimizeParts);
+		ofc.setEmbeddedKeyCallbackClass(embeddedKeyCallbackClass);
+		ofc.setEncryptionKeyTransportAlgorithm(WSConstants.KEYTRANSPORT_RSA15);
+		ofc.setEncryptionSymAlgorithm(WSConstants.AES_128);
+		ofc.setEncryptionUser(encrUser);
+		ofc.setPasswordType(WSConstants.PW_DIGEST);
+		ofc.setSamlPropFile(samlPropFile);
+		ofc.setSignaturePropFile(sigPropFile);
+		ofc.setEncryptionPropFile(encPropFile);
+
+		// Check whether the props are there
+		assertTrue("Action items missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSSHandlerConstants.ACTION_ITEMS + ">"
+								+ actionItems + "</"
+								+ WSSHandlerConstants.ACTION_ITEMS + ">"));
+
+		assertTrue("User missing", -1 < ofc.getProperty().getParameterElement().toString().indexOf(
+				"<" + WSHandlerConstants.USER + ">" + user + "</"
+						+ WSHandlerConstants.USER + ">"));
+
+		assertTrue("passwordCallbackClass missing", -1 < ofc.getProperty().getParameterElement()
+				.toString().indexOf(
+						"<" + WSHandlerConstants.PW_CALLBACK_CLASS + ">" + pwcb
+								+ "</" + WSHandlerConstants.PW_CALLBACK_CLASS
+								+ ">"));
+
+		assertTrue("sigKeyId missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.SIG_KEY_ID + ">" + sigKeyId
+								+ "</" + WSHandlerConstants.SIG_KEY_ID + ">"));
+
+		assertTrue("encKeyId missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.ENC_KEY_ID + ">"
+								+ WSSHandlerConstants.SKI_KEY_IDENTIFIER + "</"
+								+ WSHandlerConstants.ENC_KEY_ID + ">"));
+
+		assertTrue("signature parts missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.SIGNATURE_PARTS + ">"
+								+ sigParts + "</"
+								+ WSHandlerConstants.SIGNATURE_PARTS + ">"));
+
+		assertTrue("optimize parts missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSSHandlerConstants.OPTIMIZE_PARTS + ">"
+								+ optimizeParts + "</"
+								+ WSSHandlerConstants.OPTIMIZE_PARTS + ">"));
+
+		assertTrue("EmbeddedKeyCallbackClass missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.ENC_CALLBACK_CLASS + ">"
+								+ embeddedKeyCallbackClass + "</"
+								+ WSHandlerConstants.ENC_CALLBACK_CLASS + ">"));
+
+		assertTrue("encryptionKeyTransportAlgorithm missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.ENC_KEY_TRANSPORT + ">"
+								+ WSConstants.KEYTRANSPORT_RSA15 + "</"
+								+ WSHandlerConstants.ENC_KEY_TRANSPORT + ">"));
+
+		assertTrue("encryptionSymAlgorithm missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.ENC_SYM_ALGO + ">"
+								+ WSConstants.AES_128 + "</"
+								+ WSHandlerConstants.ENC_SYM_ALGO + ">"));
+		
+		assertTrue("encrUser missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.ENCRYPTION_USER + ">"
+								+ encrUser + "</"
+								+ WSHandlerConstants.ENCRYPTION_USER + ">"));
+		
+		assertTrue("passwordType missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.PASSWORD_TYPE + ">"
+								+ WSConstants.PW_DIGEST + "</"
+								+ WSHandlerConstants.PASSWORD_TYPE + ">"));
+
+		assertTrue("samlPropFile missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.SAML_PROP_FILE + ">"
+								+ samlPropFile + "</"
+								+ WSHandlerConstants.SAML_PROP_FILE + ">"));
+		
+		assertTrue("sigPropFile missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.SIG_PROP_FILE + ">"
+								+ sigPropFile + "</"
+								+ WSHandlerConstants.SIG_PROP_FILE + ">"));
+		assertTrue("encPropFile missing", -1 < ofc.getProperty().getParameterElement().toString()
+				.indexOf(
+						"<" + WSHandlerConstants.ENC_PROP_FILE + ">"
+								+ encPropFile + "</"
+								+ WSHandlerConstants.ENC_PROP_FILE + ">"));
+	}
+	
+	/**
+	 * This tests multiple action configurations
+	 */
+	public void testMultipleActions() {
+		OutflowConfiguration ofc = new OutflowConfiguration(2);
+
+		String actionItems1 = "Timestamp Signature Encrypt";
+		String user1 = "alice";
+
+		String actionItems2 = "Signature Encrypt Timestamp";
+		String user2 = "alice2";
+		
+		ofc.setActionItems(actionItems1);
+		ofc.setUser(user1);
+		
+		ofc.nextAction();
+		
+		ofc.setActionItems(actionItems2);
+		ofc.setUser(user2);
+
+		assertEquals("Action items mismatch", actionItems2, ofc.getActionItems());
+		assertEquals("Action items mismatch", user2, ofc.getUser());
+		
+		ofc.previousAction();
+		
+		assertEquals("Action items mismatch", actionItems1, ofc.getActionItems());
+		assertEquals("Action items mismatch", user1, ofc.getUser());
+		
+		System.out.println(ofc.getProperty().getParameterElement());
+	}
+
+}



Mime
View raw message