SF.net SVN: mx4j:[2283] trunk/mx4j/tools/src/main/java/mx4j/tools/remote/ soap

[email protected] Wed, 30 Dec 2009 07:19:08 +0000
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Revision: 2283
          http://mx4j.svn.sourceforge.net/mx4j/?rev=2283&view=rev
Author:   altheengineer
Date:     2009-12-30 07:19:08 +0000 (Wed, 30 Dec 2009)

Log Message:
-----------
Corrected types for credentials in SOAP calls - bug found by failures with SOAPConnectorInvocationTest (and, in particular JMXConnectorInvocationTestCase).

Modified Paths:
--------------
    trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/SOAPClientInvoker.java
    trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/axis/ser/SubjectDeser.java

Modified: trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/SOAPClientInvoker.java
===================================================================
--- trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/SOAPClientInvoker.java	2009-12-30 06:19:39 UTC (rev 2282)
+++ trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/SOAPClientInvoker.java	2009-12-30 07:19:08 UTC (rev 2283)
@@ -60,7 +60,7 @@
       Call call = createCall();
 
       call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "connect"));
-      call.addParameter("credentials", XMLType.XSD_ANY, ParameterMode.IN);
+      call.addParameter("credentials", XMLType.XSD_STRING, ParameterMode.IN);
       call.setReturnType(XMLType.XSD_STRING);
 //      call.addFault(new QName(SOAPConstants.NAMESPACE_URI, "SecurityException"), SecurityException.class, XMLType.XSD_ANY, true);
 

Modified: trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/axis/ser/SubjectDeser.java
===================================================================
--- trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/axis/ser/SubjectDeser.java	2009-12-30 06:19:39 UTC (rev 2282)
+++ trunk/mx4j/tools/src/main/java/mx4j/tools/remote/soap/axis/ser/SubjectDeser.java	2009-12-30 07:19:08 UTC (rev 2283)
@@ -8,6 +8,7 @@
 
 package mx4j.tools.remote.soap.axis.ser;
 
+import java.util.HashSet;
 import java.util.Set;
 import javax.security.auth.Subject;
 
@@ -28,12 +29,37 @@
       if (SubjectSer.READ_ONLY.equals(hint))
          readOnly = ((Boolean)value).booleanValue();
       else if (SubjectSer.PRINCIPALS.equals(hint))
-         principals = (Set)value;
+         principals = getValueAsSet(value);
       else if (SubjectSer.PUBLIC_CREDENTIALS.equals(hint))
-         publicCredentials = (Set)value;
-      else if (SubjectSer.PRIVATE_CREDENTIALS.equals(hint)) privateCredentials = (Set)value;
+         publicCredentials = getValueAsSet(value);
+      else if (SubjectSer.PRIVATE_CREDENTIALS.equals(hint)) 
+    	 privateCredentials = getValueAsSet(value);
    }
 
+   /**
+	 * Current implementation assumes two data types: an array of some type of
+	 * Objects OR some object that implements Set
+	 * 
+	 * @param value
+	 *            the value to convert into a set
+	 * @return either the value cast as a Set OR an instance of a Set that the
+	 *         values of the array were copied into.
+	 */
+   private Set getValueAsSet(Object value) 
+   {
+	   Set result = null;
+	   if (value != null && value.getClass().isArray()) {
+		   final Object[] valueArr = (Object[])value;
+		   result = new HashSet(valueArr.length);
+		   for (int i=0; i<valueArr.length; i++) {
+			   result.add(valueArr[i]);
+		   }
+	   } else {
+		   result = (Set)value;
+	   }
+	   return result;
+   }
+   
    protected Object createObject() throws SAXException
    {
       return new Subject(readOnly, principals, publicCredentials, privateCredentials);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev