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/24 23:42:48 UTC

svn commit: r291336 - in /webservices/axis2/trunk/java/modules: samples/src/sample/security/ samples/src/sample/security/META-INF/ security/ security/src/org/apache/axis2/security/

Author: ruchithf
Date: Sat Sep 24 14:42:33 2005
New Revision: 291336

URL: http://svn.apache.org/viewcvs?rev=291336&view=rev
Log:
Fixed the classloader problem in the security module, now we can include the password callback class and otehr resources in the service archive it self

Modified:
    webservices/axis2/trunk/java/modules/samples/src/sample/security/Client.java
    webservices/axis2/trunk/java/modules/samples/src/sample/security/META-INF/services.xml
    webservices/axis2/trunk/java/modules/security/maven.xml
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllSender.java

Modified: webservices/axis2/trunk/java/modules/samples/src/sample/security/Client.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/security/Client.java?rev=291336&r1=291335&r2=291336&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/security/Client.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/security/Client.java Sat Sep 24 14:42:33 2005
@@ -45,7 +45,7 @@
 			OMElement payload = getEchoElement();
 			Call call = new Call(repo);
 			
-			call.setTo(new EndpointReference("http://127.0.0.1:" + port + "/axis2/services/SecureService/echo"));
+			call.setTo(new EndpointReference("http://127.0.0.1:" + port + "/axis2/services/SecureService"));
 			call.setTransportInfo(Constants.TRANSPORT_HTTP,
 					Constants.TRANSPORT_HTTP, false);
 			call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

Modified: webservices/axis2/trunk/java/modules/samples/src/sample/security/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/security/META-INF/services.xml?rev=291336&r1=291335&r2=291336&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/security/META-INF/services.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/security/META-INF/services.xml Sat Sep 24 14:42:33 2005
@@ -19,7 +19,7 @@
     <parameter name="encryptionKeyIdentifier" locked="false">SKIKeyIdentifier</parameter>
     <parameter name="encryptionUser" locked="false">alice</parameter>
     <parameter name="encryptionSymAlgorithm" locked="false">http://www.w3.org/2001/04/xmlenc#aes128-cbc</parameter>
-    <parameter name="OutSignatureParts" locked="false">{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}To;{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}ReplyTo;{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}From;{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}RelatesTo;{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</parameter>
+    <!--<parameter name="OutSignatureParts" locked="false">{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}To;{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}ReplyTo;{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}From;{Element}{http://schemas.xmlsoap.org/ws/2004/08/addressing}RelatesTo;{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</parameter> -->
 
     <parameter name="optimizeParts" locked="false">//xenc:EncryptedData/xenc:CipherData/xenc:CipherValue</parameter>
 

Modified: webservices/axis2/trunk/java/modules/security/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/maven.xml?rev=291336&r1=291335&r2=291336&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/security/maven.xml Sat Sep 24 14:42:33 2005
@@ -42,7 +42,7 @@
 
 	<!-- Create the client specific security module -->
 	<copy file="src/META-INF/client.module.xml"
-            tofile="target/classes/META-INF/module.xml"/>
+            tofile="target/classes/META-INF/module.xml" overwrite="true"/>
 
         <jar jarfile="target/client.security.mar" basedir="target/classes">
             <include name="**/*"/>

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java?rev=291336&r1=291335&r2=291336&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java Sat Sep 24 14:42:33 2005
@@ -60,13 +60,6 @@
     	/**
     	 * Cannot do the following right now since we cannot access the req 
     	 * mc when this handler runs in the client side.
-    	 * This is the same even if the handler is placed at the end of the 
-    	 * post dispatch phase
-    	 *     <inflow>
-         *			<handler name="SecurityInHandler" class="org.apache.axis2.security.WSDoAllReceiver">
-         *				<order phase="PostDispatch" phaseLast="true"/>
-         *			</handler>
-         *		</inflow> 
     	 */
     	
 //    	//Copy the WSHandlerConstants.SEND_SIGV over to the new message 
@@ -120,6 +113,15 @@
 
             Document doc = null;
 
+            ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+            
+           //Setting the class loader
+            if(msgContext.isServerSide()) {
+            	Thread.currentThread().setContextClassLoader(msgContext.getServiceDescription().getClassLoader());
+            } else {
+            	//Thread.currentThread().setContextClassLoader(msgContext.getClass().getClassLoader());
+            }
+            
             try {
             	doc = Axis2Util.getDocumentFromSOAPEnvelope(msgContext.getEnvelope());
             } catch (WSSecurityException wssEx) {
@@ -132,8 +134,8 @@
 					soapConstants.getEnvelopeURI()) != null) {
 				return;
 			}
-            
 
+            
             /*
             * To check a UsernameToken or to decrypt an encrypted message we
             * need a password.
@@ -143,9 +145,8 @@
                 cbHandler = getPasswordCB(reqData);
             }
             
-//          Setting the class loader
-        	//Thread.currentThread().setContextClassLoader(msgContext.getServiceDescription().getClassLoader());
-        	
+
+            
             /*
             * Get and check the Signature specific parameters first because
             * they may be used for encryption too.
@@ -174,6 +175,10 @@
             if (reqData.getWssConfig().isEnableSignatureConfirmation() && !msgContext.isServerSide()) {
                 checkSignatureConfirmation(reqData, wsResult);
             }
+            
+            //Setting the original class loader
+            Thread.currentThread().setContextClassLoader(originalClassLoader);
+            
             //TODO: Copy the processed headers
             
             

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=291336&r1=291335&r2=291336&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 Sat Sep 24 14:42:33 2005
@@ -46,6 +46,11 @@
 	 * But in the simple case where only the wsse:Security header is inserted into the document
 	 * we can insert only the wsse:Security header into the OM-SOAPEnvelope and preserve the 
 	 * metadata of OM such as base64 MTOM optimization
+	 * 
+	 * TODO: Get this as an option from the user or 
+	 * go through the actions and set it appropriately
+	 * Earlier this handler traversed the actions and at that point we used to
+	 * set this value, but now WSS4J goes through the action vector
 	 */
 	private boolean preserveOriginalEnvelope = false;
 	
@@ -105,41 +110,42 @@
 	        if (doAction == WSConstants.NO_SECURITY) {
 	            return;
 	        }
-	
+	        
             /*
              * For every action we need a username, so get this now. The
              * username defined in the deployment descriptor takes precedence.
              */
-         reqData.setUsername((String) getOption(WSHandlerConstants.USER));
-         if (reqData.getUsername() == null || reqData.getUsername().equals("")) {
-             String username = (String) getProperty(reqData.getMsgContext(), WSHandlerConstants.USER);
-             if (username != null) {
-                 reqData.setUsername(username);
-             }
-         }
+	        reqData.setUsername((String) getOption(WSHandlerConstants.USER));
+	        if (reqData.getUsername() == null || reqData.getUsername().equals("")) {
+	        	String username = (String) getProperty(reqData.getMsgContext(), WSHandlerConstants.USER);
+	        	if (username != null) {
+	        		reqData.setUsername(username);
+	        	}
+	        }
          
-         /*
-             * Now we perform some set-up for UsernameToken and Signature
-             * functions. No need to do it for encryption only. Check if
-             * username is available and then get a passowrd.
-             */
-         if ((doAction & (WSConstants.SIGN | WSConstants.UT | WSConstants.UT_SIGN)) != 0) {
-             /*
-                  * We need a username - if none throw an AxisFault. For
-                  * encryption there is a specific parameter to get a username.
-                  */
-             if (reqData.getUsername() == null || reqData.getUsername().equals("")) {
-                 throw new AxisFault(
-                         "WSDoAllSender: Empty username for specified action");
-             }
-         }
+	        /*
+			 * Now we perform some set-up for UsernameToken and Signature
+			 * functions. No need to do it for encryption only. Check if
+			 * username is available and then get a passowrd.
+			 */
+			if ((doAction & (WSConstants.SIGN | WSConstants.UT | WSConstants.UT_SIGN)) != 0) {
+				/*
+				 * We need a username - if none throw an AxisFault. For
+				 * encryption there is a specific parameter to get a username.
+				 */
+				if (reqData.getUsername() == null
+						|| reqData.getUsername().equals("")) {
+					throw new AxisFault(
+							"WSDoAllSender: Empty username for specified action");
+				}
+			}
          
          /*
-		  * Now get the SOAPEvelope from the message context and convert it into
-		  * a Document
-		  * 
-		  * Now we can perform our security operations on this request.
-		  */
+			 * Now get the SOAPEvelope from the message context and convert it
+			 * into a Document
+			 * 
+			 * Now we can perform our security operations on this request.
+			 */
 	     	
          
          Document doc = null;
@@ -158,10 +164,15 @@
 	     
 
             //Setting the class loader
-        	//Thread.currentThread().setContextClassLoader(msgContext.getServiceDescription().getClassLoader());
+            ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+            
+        	Thread.currentThread().setContextClassLoader(msgContext.getServiceDescription().getClassLoader());
         	
         	doSenderAction(doAction, doc, reqData, actions, !msgContext.isServerSide());
 
+        	//Setting the original class loader
+        	Thread.currentThread().setContextClassLoader(originalClassLoader);
+        	
             /*
                 * If required convert the resulting document into a message first.
                 * The outputDOM() method performs the necessary c14n call. After