You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2005/09/01 11:40:25 UTC
svn commit: r265685 - in /webservices/axis2/trunk/java/modules:
integration/test-resources/security/
integration/test/org/apache/axis2/security/
security/src/org/apache/axis2/security/
security/src/org/apache/axis2/security/handler/ security/src/org/ap...
Author: ruchithf
Date: Thu Sep 1 02:39:59 2005
New Revision: 265685
URL: http://svn.apache.org/viewcvs?rev=265685&view=rev
Log:
WS-Securty scenario 5. Now we can repete the WSDoAllSender N number of time with the parameters names ending with N E.g.: see modules/integration/test-resources/security/s5.client.axis2.xml
Added:
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/security/Scenario5Test.java
Modified:
webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.client.axis2.xml
webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.service.axis2.xml
webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllSender.java
webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSDoAllHandler.java
webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSSHandlerConstants.java
webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/WSHandlerConstantsMapper.java
Modified: webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.client.axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.client.axis2.xml?rev=265685&r1=265684&r2=265685&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.client.axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.client.axis2.xml Thu Sep 1 02:39:59 2005
@@ -12,10 +12,21 @@
<!-- Scenario 5: Client's Configuration:START-->
- <parameter name="OutAction" locked="false">UsernameToken</parameter>
+ <parameter name="OutAction" locked="false">Signature NoSerialization</parameter>
<parameter name="user" locked="false">alice</parameter>
<parameter name="OutPasswordCallbackClass" locked="false">org.apache.axis2.security.PWCallback</parameter>
- <parameter name="passwordType" locked="false">PasswordText</parameter>
+ <parameter name="OutSignatureKeyIdentifier" locked="false">DirectReference</parameter>
+ <parameter name="signatureParts" locked="false">{}{http://xmlsoap.org/Ping}ticket</parameter>
+ <parameter name="OutSignaturePropFile" locked="false">interop.properties</parameter>
+
+ <!-- Repeat the WSDoAllSender -->
+ <parameter name="senderRepeteCount" locked="false">1</parameter>
+
+ <!-- Parameters for repetition #1 -->
+ <parameter name="user1" locked="false">alice</parameter>
+ <parameter name="OutAction1" locked="false">Signature Timestamp</parameter>
+ <parameter name="OutPasswordCallbackClass1" locked="false">org.apache.axis2.security.PWCallback</parameter>
+ <parameter name="OutSignaturePropFile1" locked="false">interop.properties</parameter>
<parameter name="InAction" locked="false">NoSecurity</parameter>
Modified: webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.service.axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.service.axis2.xml?rev=265685&r1=265684&r2=265685&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.service.axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/test-resources/security/s5.service.axis2.xml Thu Sep 1 02:39:59 2005
@@ -12,8 +12,9 @@
<!-- Scenario 5: Service's Configuration: START-->
<!-- Also we can switch back to hte normal parameter names when we can seperately assign them to the flows -->
- <parameter name="InAction" locked="false">UsernameToken</parameter>
+ <parameter name="InAction" locked="false">Signature Signature Timestamp</parameter>
<parameter name="InPasswordCallbackClass" locked="false">org.apache.axis2.security.PWCallback</parameter>
+ <parameter name="InSignaturePropFile" locked="false">interop.properties</parameter>
<parameter name="OutAction" locked="false">NoSecurity</parameter>
Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/security/Scenario5Test.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/security/Scenario5Test.java?rev=265685&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/security/Scenario5Test.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/security/Scenario5Test.java Thu Sep 1 02:39:59 2005
@@ -0,0 +1,30 @@
+/*
+* 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;
+
+/**
+ * WS-Security interop scenario 5
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class Scenario5Test extends InteropTestBase {
+
+ protected void setUp() throws Exception {
+ this.setClientRepo(SCENARIO5_CLIENT_REPOSITORY);
+ this.setServiceRepo(SCENARIO5_SERVICE_REPOSITORY);
+ super.setUp();
+ }
+}
Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllSender.java?rev=265685&r1=265684&r2=265685&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllSender.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllSender.java Thu Sep 1 02:39:59 2005
@@ -24,6 +24,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.security.handler.WSDoAllHandler;
+import org.apache.axis2.security.handler.WSSHandlerConstants;
import org.apache.axis2.security.util.Axis2Util;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.commons.logging.Log;
@@ -262,12 +263,44 @@
if (doDebug) {
log.debug("WSDoAllSender: exit invoke()");
}
+
+ //Enable handler repetition
+ String repeat;
+ int repeatCount;
+ if ((repeat = (String) getOption(WSSHandlerConstants.Out.SENDER_REPEAT_COUNT)) == null) {
+ repeat = (String)
+ getProperty(reqData.getMsgContext(), WSSHandlerConstants.Out.SENDER_REPEAT_COUNT);
+ }
+
+ if(repeat != null) {
+ try {
+ repeatCount = Integer.parseInt(repeat);
+ } catch (NumberFormatException nfex) {
+ throw new AxisFault("Repetition count of WSDoAllSender should be an integer");
+ }
+
+ //Get the current repetition from message context
+ int repetition = this.getRepetition(msgContext);
+
+ if(repeatCount > 0 && repetition < repeatCount) {
+ reqData.clear();
+ reqData = null;
+
+ //Increment the repetition to indicate the next repetition
+ //of the same handler
+ repetition++;
+ msgContext.setProperty(WSSHandlerConstants.Out.REPETITON,new Integer(repetition));
+ this.invoke(msgContext);
+ }
+ }
} catch (WSSecurityException e) {
e.printStackTrace();
throw new AxisFault(e.getMessage(), e);
} finally {
- reqData.clear();
- reqData = null;
+ if(reqData != null) {
+ reqData.clear();
+ reqData = null;
+ }
}
}
}
Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSDoAllHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSDoAllHandler.java?rev=265685&r1=265684&r2=265685&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSDoAllHandler.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSDoAllHandler.java Thu Sep 1 02:39:59 2005
@@ -140,11 +140,31 @@
public Object getProperty(Object msgContext, String axisKey) {
- String key = WSHandlerConstantsMapper.getMapping(axisKey,inHandler);
+
+ int repetition = getRepetition(msgContext);
+
+ String key = WSHandlerConstantsMapper.getMapping(axisKey,inHandler, repetition);
log.debug("wss4j key: " + axisKey + " Key : " + key);
return ((MessageContext)msgContext).getProperty(key);
}
+ /**
+ * Returns the repetition number from the message context
+ * @param msgContext
+ * @return
+ */
+ protected int getRepetition(Object msgContext) {
+ //get the repetition from the message context
+ int repetition = 0;
+ if(!inHandler) {//We only need to repete the out handler
+ Integer count = (Integer)((MessageContext)msgContext).getProperty(WSSHandlerConstants.Out.REPETITON);
+ if(count != null) { //When we are repeting the handler
+ repetition = count.intValue();
+ }
+ }
+ return repetition;
+ }
+
public String getPassword(Object msgContext) {
return (String)((MessageContext)msgContext).getProperty(WSS_PASSWORD);
}
@@ -169,11 +189,13 @@
*/
public Object getOption(String axisKey) {
- String key = WSHandlerConstantsMapper.getMapping(axisKey,inHandler);
-
MessageContext msgContext = (MessageContext)this.reqData.getMsgContext();
- Object value = null;
+ int repetition = this.getRepetition(msgContext);
+
+ String key = WSHandlerConstantsMapper.getMapping(axisKey,inHandler, repetition);
+
+ Object value = null;
// If the parameters are set in the scope of an peration in service.xml
OperationContext operationContext = msgContext.getOperationContext();
Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSSHandlerConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSSHandlerConstants.java?rev=265685&r1=265684&r2=265685&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSSHandlerConstants.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/handler/WSSHandlerConstants.java Thu Sep 1 02:39:59 2005
@@ -33,8 +33,11 @@
public static final String PW_CALLBACK_CLASS = "OutPasswordCallbackClass";
public static final String SIG_PROP_FILE = "OutSignaturePropFile";
public static final String SIG_KEY_ID = "OutSignatureKeyIdentifier";
+
+ //Repetition count
+ public static final String SENDER_REPEAT_COUNT = "senderRepeteCount";
+ public static final String REPETITON = "repetition";
}
-
}
Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/WSHandlerConstantsMapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/WSHandlerConstantsMapper.java?rev=265685&r1=265684&r2=265685&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/WSHandlerConstantsMapper.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/WSHandlerConstantsMapper.java Thu Sep 1 02:39:59 2005
@@ -32,6 +32,10 @@
private static Hashtable outHandlerConstants = new Hashtable();
+
+ /**
+ * The parameter names that are shared across the two handlers are mapped in this situation
+ */
static {
//Mapping the in handler constants
inHandlerConstants.put(WSHandlerConstants.ACTION, WSSHandlerConstants.In.ACTION);
@@ -53,12 +57,19 @@
* @param axiskey
* @return
*/
- public static String getMapping(String axiskey, boolean inHandler) {
+ public static String getMapping(String axiskey, boolean inHandler, int repetition) {
String newKey = null;
if(inHandler) {
newKey = (String)inHandlerConstants.get(axiskey);
} else {
- newKey = (String)outHandlerConstants.get(axiskey);
+ newKey = (String)outHandlerConstants.get(axiskey);
+ }
+ if(repetition > 0 && axiskey != WSSHandlerConstants.Out.SENDER_REPEAT_COUNT && !inHandler) {
+ if(newKey == null) {
+ return axiskey + repetition;
+ } else {
+ return newKey + repetition;
+ }
}
return (newKey == null)?axiskey:newKey;
}