[jbossws-commits] JBossWS SVN: r3563 - in branches/jbossws-2.0: build/ant-import and 2 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Jun 13 08:52:28 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-06-13 08:52:28 -0400 (Wed, 13 Jun 2007)
New Revision: 3563

Modified:
   branches/jbossws-2.0/build/ant-import/build-testsuite.xml
   branches/jbossws-2.0/build/ant.properties.example
   branches/jbossws-2.0/build/dist/ant.properties.example
   branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/test/TestDeployerJBoss.java
Log:
[JBWS-1624] JBossWS samples don't work with JMX authentication

Modified: branches/jbossws-2.0/build/ant-import/build-testsuite.xml
===================================================================
--- branches/jbossws-2.0/build/ant-import/build-testsuite.xml	2007-06-13 12:50:00 UTC (rev 3562)
+++ branches/jbossws-2.0/build/ant-import/build-testsuite.xml	2007-06-13 12:52:28 UTC (rev 3563)
@@ -324,6 +324,8 @@
       <sysproperty key="jboss.home" value="${jboss.home}"/>
       <sysproperty key="jboss.bind.address" value="${node0}"/>
       <sysproperty key="jbossws.integration.target" value="${jbossws.integration.target}"/>
+      <sysproperty key="jmx.authentication.username" value="${jmx.authentication.username}"/>
+      <sysproperty key="jmx.authentication.password" value="${jmx.authentication.password}"/>
       <sysproperty key="org.jboss.ws.wsse.keyStore" value="${tests.output.dir}/resources/jaxrpc/samples/wssecurity/wsse.keystore"/>
       <sysproperty key="org.jboss.ws.wsse.trustStore" value="${tests.output.dir}/resources/jaxrpc/samples/wssecurity/wsse.truststore"/>
       <sysproperty key="org.jboss.ws.wsse.keyStorePassword" value="jbossws"/>
@@ -360,6 +362,8 @@
       <sysproperty key="jboss.home" value="${jboss.home}"/>
       <sysproperty key="jboss.bind.address" value="${node0}"/>
       <sysproperty key="jbossws.integration.target" value="${jbossws.integration.target}"/>
+      <sysproperty key="jmx.authentication.username" value="${jmx.authentication.username}"/>
+      <sysproperty key="jmx.authentication.password" value="${jmx.authentication.password}"/>
       <!--
       http://jira.jboss.com/jira/browse/JBWS-917
       <sysproperty key="javax.net.ssl.keyStore" value="${tests.output.dir}/resources/jaxrpc/samples/wssecurity/wsse.keystore"/>

Modified: branches/jbossws-2.0/build/ant.properties.example
===================================================================
--- branches/jbossws-2.0/build/ant.properties.example	2007-06-13 12:50:00 UTC (rev 3562)
+++ branches/jbossws-2.0/build/ant.properties.example	2007-06-13 12:52:28 UTC (rev 3563)
@@ -15,6 +15,10 @@
 jboss.server.instance=default
 jboss.bind.address=localhost
 
+# JBoss JMX invoker authentication
+#jmx.authentication.username=admin
+#jmx.authentication.password=admin
+
 # JBoss Repository
 #jboss.repository=file:/home/tdiesler/svn/jboss.local.repository
 jboss.repository=http://repository.jboss.org

Modified: branches/jbossws-2.0/build/dist/ant.properties.example
===================================================================
--- branches/jbossws-2.0/build/dist/ant.properties.example	2007-06-13 12:50:00 UTC (rev 3562)
+++ branches/jbossws-2.0/build/dist/ant.properties.example	2007-06-13 12:52:28 UTC (rev 3563)
@@ -19,6 +19,10 @@
 #jboss.repository=file:/home/tdiesler/svn/jboss.local.repository
 jboss.repository=http://repository.jboss.org
 
+# JBoss JMX invoker authentication
+#jmx.authentication.username=admin
+#jmx.authentication.password=admin
+
 # Java Compiler options
 javac.debug=yes
 javac.deprecation=no

Modified: branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/test/TestDeployerJBoss.java
===================================================================
--- branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/test/TestDeployerJBoss.java	2007-06-13 12:50:00 UTC (rev 3562)
+++ branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/test/TestDeployerJBoss.java	2007-06-13 12:52:28 UTC (rev 3563)
@@ -21,11 +21,21 @@
  */
 package org.jboss.wsf.spi.test;
 
+import java.io.IOException;
+import java.io.Serializable;
 import java.net.URL;
+import java.security.Principal;
 
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
 import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
+import javax.management.ReflectionException;
 
+import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
+
 /**
  * A JBossWS test helper that deals with test deployment/undeployment, etc.
  *
@@ -37,19 +47,72 @@
    private static final String MAIN_DEPLOYER = "jboss.system:service=MainDeployer";
    
    private MBeanServerConnection server;
+   private String username;
+   private String password;
 
    public TestDeployerJBoss(MBeanServerConnection server)
    {
       this.server = server;
+      
+      username = System.getProperty("jmx.authentication.username");
+      if ("${jmx.authentication.username}".equals(username))
+         username = null;
+      
+      password = System.getProperty("jmx.authentication.password");
+      if ("${jmx.authentication.password}".equals(password))
+         password = null;
    }
 
    public void deploy(URL url) throws Exception
    {
-      server.invoke(new ObjectName(MAIN_DEPLOYER), "deploy", new Object[] { url }, new String[] { "java.net.URL" });
+      invokeMainDeployer("deploy", url);
    }
 
    public void undeploy(URL url) throws Exception
    {
-      server.invoke(new ObjectName(MAIN_DEPLOYER), "undeploy", new Object[] { url }, new String[] { "java.net.URL" });
+      invokeMainDeployer("undeploy", url);
    }
+
+   private void invokeMainDeployer(String methodName, URL url) throws Exception
+   {
+      Principal prevUsername = null;
+      Object prevPassword = null;
+      
+      SecurityAdaptor securityAdaptor = SecurityAdaptorFactory.getSecurityAdaptor();
+      if (username != null || password != null)
+      {
+         prevUsername = securityAdaptor.getPrincipal();
+         prevPassword = securityAdaptor.getCredential();
+         securityAdaptor.setPrincipal(new SimplePrincipal(username));
+         securityAdaptor.setCredential(password);
+      }
+      
+      try
+      {
+         server.invoke(new ObjectName(MAIN_DEPLOYER), methodName, new Object[] { url }, new String[] { "java.net.URL" });
+      }
+      finally
+      {
+         if (username != null || password != null)
+         {
+            securityAdaptor.setPrincipal(prevUsername);
+            securityAdaptor.setCredential(prevPassword);
+         }
+      }
+   }
+
+   public static class SimplePrincipal implements Principal, Serializable
+   {
+      private String name;
+      
+      public SimplePrincipal(String name)
+      {
+         this.name = name;
+      }
+
+      public String getName()
+      {
+         return name;
+      }
+   }
 }




More information about the jbossws-commits mailing list