You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ve...@apache.org on 2005/07/21 09:13:26 UTC
cvs commit: ws-wss4j/test/interop TestJAXRPCHandler.java
venkat 2005/07/21 00:13:26
Modified: src/org/apache/ws/security/handler WSS4JHandler.java
test/interop TestJAXRPCHandler.java
Log:
WSS-1 :
- added more test cases to interop.TestJAXRPCHandler.
- updated WSS4JHandler to take care of request-flow-only handling etc.
Revision Changes Path
1.9 +24 -7 ws-wss4j/src/org/apache/ws/security/handler/WSS4JHandler.java
Index: WSS4JHandler.java
===================================================================
RCS file: /home/cvs/ws-wss4j/src/org/apache/ws/security/handler/WSS4JHandler.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WSS4JHandler.java 22 Jun 2005 02:53:53 -0000 1.8
+++ WSS4JHandler.java 21 Jul 2005 07:13:26 -0000 1.9
@@ -126,6 +126,9 @@
static final String DEPLOYMENT = "deployment";
static final String CLIENT_DEPLOYMENT = "client";
static final String SERVER_DEPLOYMENT = "server";
+ static final String FLOW = "flow";
+ static final String REQUEST_ONLY = "request-only";
+ static final String RESPONSE_ONLY = "response-only";
/**
* Initializes the instance of the handler.
@@ -164,33 +167,48 @@
/**
* Switch for transfering control to doReceiver and doSender
*/
- public boolean processMessage(MessageContext mc, boolean messageType) {
+ public boolean processMessage(MessageContext mc, boolean isRequestMessage) {
doDebug = log.isDebugEnabled();
+ msgContext = (SOAPMessageContext) mc;
String deployment = null;
+ String handleFlow = null;
+
if ((deployment = (String) handlerInfo.getHandlerConfig().get(DEPLOYMENT)) == null) {
deployment = (String) msgContext.getProperty(DEPLOYMENT);
}
-
if (deployment == null) {
throw new JAXRPCException("WSS4JHandler.processMessage: No deployment defined");
}
+ if ((handleFlow = (String) handlerInfo.getHandlerConfig().get(FLOW)) == null) {
+ handleFlow = (String) msgContext.getProperty(FLOW);
+ }
+ if (handleFlow == null) {
+ handleFlow = "";
+ }
// call doSender if we are -
// (handling request and client-side deployment) or (handling response and server-side deployment).
// call doReceiver if we are -
// (handling request and server-side deployment) or (handling response and client-side deployment).
- if (deployment.equals(CLIENT_DEPLOYMENT) ^ messageType) {
- return doReceiver(mc);
+
+ boolean needsHandling = ( isRequestMessage && !handleFlow.equals(RESPONSE_ONLY)) ||
+ (!isRequestMessage && !handleFlow.equals(REQUEST_ONLY));
+ if (deployment.equals(CLIENT_DEPLOYMENT) ^ isRequestMessage) {
+ if (needsHandling) {
+ return doReceiver(mc);
+ }
} else {
- return doSender(mc);
+ if (needsHandling) {
+ return doSender(mc);
+ }
}
+ return true;
}
/**
* Handles incoming web service requests and outgoing responses
*/
public boolean doSender(MessageContext mc) {
- msgContext = (SOAPMessageContext) mc;
initialize();
noSerialization = false;
@@ -415,7 +433,6 @@
handle response
*/
public boolean doReceiver(MessageContext mc) {
- msgContext = (SOAPMessageContext) mc;
Vector actions = new Vector();
String action = (String) handlerInfo.getHandlerConfig().get(WSHandlerConstants.RECEIVE + '.' + WSHandlerConstants.ACTION);
1.3 +93 -21 ws-wss4j/test/interop/TestJAXRPCHandler.java
Index: TestJAXRPCHandler.java
===================================================================
RCS file: /home/cvs/ws-wss4j/test/interop/TestJAXRPCHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestJAXRPCHandler.java 4 Jun 2005 21:12:59 -0000 1.2
+++ TestJAXRPCHandler.java 21 Jul 2005 07:13:26 -0000 1.3
@@ -17,18 +17,8 @@
import java.util.List;
import java.util.Map;
-/**
- * Created by IntelliJ IDEA.
- * User: srida01
- * Date: Aug 12, 2004
- * Time: 9:44:32 PM
- * To change this template use File | Settings | File Templates.
- */
public class TestJAXRPCHandler extends TestCase {
/**
- * TestScenario1 constructor
- * <p/>
- *
* @param name name of the test
*/
public TestJAXRPCHandler(String name) {
@@ -36,19 +26,38 @@
}
/**
- * JUnit suite
- * <p/>
- *
* @return a junit test suite
*/
public static Test suite() {
return new TestSuite(TestJAXRPCHandler.class);
}
+ public void testScenario1() throws Exception {
+ Map config = new HashMap();
+ config.put("deployment", "client");
+ config.put("flow", "request-only");
+ config.put("action", "UsernameToken");
+ config.put("user", "Chris");
+ config.put("passwordType", "PasswordText");
+ config.put("passwordCallbackClass", "org.apache.ws.axis.oasis.PWCallback1");
+ invokeService (config, 1);
+ }
+ public void testScenario2() throws Exception {
+ Map config = new HashMap();
+ config.put("deployment", "client");
+ config.put("flow", "request-only");
+ config.put("user", "Chris");
+ config.put("passwordType", "PasswordText");
+ config.put("action", "UsernameToken Encrypt");
+ config.put("addUTElements", "Nonce Created");
+ config.put("encryptionPropFile", "wsstest.properties");
+ config.put("encryptionKeyIdentifier", "SKIKeyIdentifier");
+ config.put("encryptionUser", "bob");
+ config.put("passwordCallbackClass", "org.apache.ws.axis.oasis.PWCallback1");
+ config.put("encryptionParts", "{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken");
+ invokeService (config, 2);
+ }
public void testScenario3() throws Exception {
- PingServiceLocator service = new PingServiceLocator();
-
- List handlerChain = new ArrayList();
Map config = new HashMap();
config.put("deployment", "client");
config.put("action", "Signature Encrypt Timestamp");
@@ -58,17 +67,80 @@
config.put("signaturePropFile", "wsstest.properties");
config.put("encryptionKeyIdentifier", "SKIKeyIdentifier");
config.put("encryptionUser", "bob");
- handlerChain.add(new HandlerInfo(WSS4JHandler.class, config, null));
+ invokeService (config, 3);
+ }
+ public void testScenario4() throws Exception {
+ Map config = new HashMap();
+ config.put("deployment", "client");
+ config.put("action", "Signature Encrypt Timestamp");
+ config.put("user", "alice");
+ config.put("passwordCallbackClass", "org.apache.ws.axis.oasis.PWCallback1");
+ config.put("signatureKeyIdentifier", "DirectReference");
+ config.put("signaturePropFile", "wsstest.properties");
+ config.put("encryptionKeyIdentifier", "EmbeddedKeyName");
+ config.put("EmbeddedKeyCallbackClass", "org.apache.ws.axis.oasis.PWCallback1");
+ config.put("EmbeddedKeyName", "SessionKey");
+ invokeService (config, 4);
+ }
+
+ // testScenario5 - Ping5 fails because there is now way in JAXRPC to
+ // specifiy the parameter signatureKeyIdentifier with different values
+ // for request and response flows
+/* public void testScenario5() throws Exception {
+ Map config = new HashMap();
+ config.put("deployment", "client");
+ config.put("action", "Signature NoSerialization");
+ config.put("user", "alice");
+ config.put("passwordCallbackClass", "org.apache.ws.axis.oasis.PWCallback1");
+ config.put("signatureKeyIdentifier", "DirectReference");
+ config.put("signaturePropFile", "wsstest.properties");
+ config.put("signatureParts", "{}{http://xmlsoap.org/Ping}ticket");
+ invokeService (config, 5);
+ }
+*/ public void testScenario6() throws Exception {
+ Map config = new HashMap();
+ config.put("deployment", "client");
+ config.put("action", "Encrypt Signature Timestamp");
+ config.put("user", "alice");
+ config.put("passwordCallbackClass", "org.apache.ws.axis.oasis.PWCallback1");
+ config.put("signatureKeyIdentifier", "DirectReference");
+ config.put("signaturePropFile", "wsstest.properties");
+ config.put("encryptionKeyIdentifier", "SKIKeyIdentifier");
+ config.put("encryptionUser", "bob");
+ invokeService (config, 6);
+ }
+ public void testScenario7() throws Exception {
+ Map config = new HashMap();
+ config.put("deployment", "client");
+ config.put("action", "Signature Encrypt Timestamp");
+ config.put("user", "alice");
+ config.put("passwordCallbackClass", "org.apache.ws.axis.oasis.PWCallback1");
+ config.put("signatureKeyIdentifier", "DirectReference");
+ config.put("signaturePropFile", "wsstest.properties");
+ config.put("encryptionKeyIdentifier", "SKIKeyIdentifier");
+ config.put("encryptionUser", "bob");
+ config.put("encryptionPropFile", "wsstest.properties");
+ config.put("signatureParts", "{}{http://schemas.xmlsoap.org/soap/envelope/}Body;STRTransform");
+ invokeService (config, 7);
+ }
+
+ public void invokeService (Map config, int interopNum) throws Exception {
+ PingServiceLocator service = new PingServiceLocator();
+
+ List handlerChain = new ArrayList();
+ handlerChain.add(new HandlerInfo( WSS4JHandler.class, config, null));
HandlerRegistry registry = service.getHandlerRegistry();
- registry.setHandlerChain(new QName("Ping3"), handlerChain);
+ registry.setHandlerChain(new QName("Ping" + interopNum), handlerChain);
service.getHandlerRegistry().getHandlerChain(new QName("http://xmlsoap.org/Ping", "ticketType"));
+
+ java.lang.reflect.Method method = service.getClass().getMethod("getPing" + interopNum, new Class[] {URL.class});
- PingPort port = (PingPort) service.getPing3(new URL("http://localhost:8080/axis/services/Ping3"));
+ PingPort port = (PingPort) method.invoke (service, new Object[] {new URL("http://localhost:8080/axis/services/Ping" + interopNum)});
StringHolder text =
- new StringHolder("WSS4J - Scenario3 @ [" + new java.util.Date(System.currentTimeMillis()) + "]");
- port.ping(new org.apache.ws.axis.oasis.ping.TicketType("WSS4J3"), text);
+ new StringHolder("WSS4J - Scenario" + interopNum + " @ [" + new java.util.Date(System.currentTimeMillis()) + "]");
+ port.ping(new org.apache.ws.axis.oasis.ping.TicketType("WSS4J" + interopNum), text);
System.out.println(text.value);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org