[jboss-cvs] JBossAS SVN: r81517 - in trunk: security/src/main/org/jboss/security/auth/login and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 24 17:38:11 EST 2008


Author: sguilhen at redhat.com
Date: 2008-11-24 17:38:11 -0500 (Mon, 24 Nov 2008)
New Revision: 81517

Modified:
   trunk/security/src/etc/deploy/security-jboss-beans.xml
   trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java
   trunk/security/src/main/org/jboss/security/integration/JBossSecuritySubjectFactory.java
   trunk/security/src/main/org/jboss/security/integration/JNDIContextEstablishment.java
   trunk/security/src/main/org/jboss/security/integration/SecurityDomainObjectFactory.java
   trunk/security/src/main/org/jboss/security/plugins/SecurityConfig.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java
Log:
JBAS-5989: added management annotation to part of the security beans. Updated SecurityManagedObjectTestCase to reflect the changes.



Modified: trunk/security/src/etc/deploy/security-jboss-beans.xml
===================================================================
--- trunk/security/src/etc/deploy/security-jboss-beans.xml	2008-11-24 21:57:34 UTC (rev 81516)
+++ trunk/security/src/etc/deploy/security-jboss-beans.xml	2008-11-24 22:38:11 UTC (rev 81517)
@@ -16,10 +16,6 @@
       <property name="defaultLoginConfig"><inject bean="XMLLoginConfig"/></property>
    </bean>
  
-   <!-- JNDI Object Factory to establish SecurityDomainContext objects -->
-   <bean name="SecurityDomainObjectFactory"
-      class="org.jboss.security.integration.SecurityDomainObjectFactory"/> 
- 
    <!-- JNDI Context legacy establishment of java:/jaas/securityDomain -->
    <bean name="JBossSecurityJNDIContextEstablishment"
       class="org.jboss.security.integration.JNDIContextEstablishment"/> 
@@ -43,4 +39,4 @@
       <property name="policyRegistration"><inject bean="JBossSecurityPolicyRegistration" /></property>
       <property name="securityManagement"><inject bean="JNDIBasedSecurityManagement" /></property>
    </bean>
- </deployment>
\ No newline at end of file
+ </deployment>

Modified: trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java
===================================================================
--- trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java	2008-11-24 21:57:34 UTC (rev 81516)
+++ trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java	2008-11-24 22:38:11 UTC (rev 81517)
@@ -20,7 +20,7 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.security.auth.login;
- 
+
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -30,146 +30,172 @@
 import javax.security.auth.login.AppConfigurationEntry;
 
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.security.config.ApplicationPolicy; 
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.security.config.ApplicationPolicy;
 import org.jboss.system.ServiceMBeanSupport;
 
-/** An MBean for managing a XMLLoginConfigImpl instance.
-
- @author Scott.Stark at jboss.org
- @author Anil.Saldhana at jboss.org
- @version $Revision: 56406 $
+/**
+ * An MBean for managing a XMLLoginConfigImpl instance.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author Anil.Saldhana at jboss.org
+ * @version $Revision: 56406 $
  */
- at JMX(name="jboss.security:service=XMLLoginConfig", exposedInterface=XMLLoginConfigMBean.class)
-public class XMLLoginConfig extends ServiceMBeanSupport
-      implements XMLLoginConfigMBean
+ at JMX(name = "jboss.security:service=XMLLoginConfig", exposedInterface = XMLLoginConfigMBean.class)
+ at ManagementObject(name = "XMLLoginConfig", componentType = @ManagementComponent(type = "MCBean", subtype = "Security"),
+      properties = ManagementProperties.EXPLICIT)
+public class XMLLoginConfig extends ServiceMBeanSupport implements XMLLoginConfigMBean
 {
-   XMLLoginConfigImpl config; 
+   XMLLoginConfigImpl config;
 
    public XMLLoginConfig()
    {
-      config = XMLLoginConfigImpl.getInstance();
+      this.config = XMLLoginConfigImpl.getInstance();
    }
 
-// --- Begin XMLLoginConfigMBean interface methods
+   // --- Begin XMLLoginConfigMBean interface methods
 
-   /** Set the URL of the XML login configuration file that should
-    be loaded by this mbean on startup.
+   /**
+    * Set the URL of the XML login configuration file that should be loaded by this mbean on startup.
     */
+   @ManagementProperty(use = {ViewUse.CONFIGURATION}, description = "The URL of the login configuration file")
    public URL getConfigURL()
    {
-      return config.getConfigURL();
+      return this.config.getConfigURL();
    }
-   /** Set the URL of the XML login configuration file that should
-    be loaded by this mbean on startup.
+
+   /**
+    * Set the URL of the XML login configuration file that should be loaded by this mbean on startup.
     */
    public void setConfigURL(URL configURL)
    {
-      config.setConfigURL(configURL);
+      this.config.setConfigURL(configURL);
    }
 
-   /** Set the resource name of the XML login configuration file that should
-    be loaded by this mbean on startup.
+   /**
+    * Get whether the login config xml document is validated againsts its DTD
     */
-   public void setConfigResource(String resourceName)
-      throws IOException
+   @ManagementProperty(use = {ViewUse.CONFIGURATION}, description = "Validate or not the login configuration file")
+   public boolean getValidateDTD()
    {
-      config.setConfigResource(resourceName);
+      return this.config.getValidateDTD();
    }
 
-   /** Get whether the login config xml document is validated againsts its DTD
+   /**
+    * Set whether the login config xml document is validated againsts its DTD
     */
-   public boolean getValidateDTD()
+   public void setValidateDTD(boolean flag)
    {
-      return config.getValidateDTD();
+      this.config.setValidateDTD(flag);
    }
-   /** Set whether the login config xml document is validated againsts its DTD
+
+   /**
+    * Set the resource name of the XML login configuration file that should be loaded by this mbean on startup.
     */
-   public void setValidateDTD(boolean flag)
+   @ManagementOperation(description = "Set the resource name of the login config file", impact = Impact.WriteOnly)
+   public void setConfigResource(String resourceName) throws IOException
    {
-      config.setValidateDTD(flag);
+      this.config.setConfigResource(resourceName);
    }
 
    /**
     * Add an application policy given a security domain name
     */
+   @ManagementOperation(description = "Add an application policy for the specified domain", impact = Impact.WriteOnly)
    public void addApplicationPolicy(String appName, ApplicationPolicy aPolicy)
    {
-      config.addApplicationPolicy(appName,aPolicy); 
+      this.config.addApplicationPolicy(appName, aPolicy);
    }
-   
-   /** Add an application login configuration. Any existing configuration for
-    the given appName will be replaced.
-    @deprecated
+
+   /**
+    * Add an application login configuration. Any existing configuration for the given appName will be replaced.
+    * 
+    * @deprecated
     */
    public void addAppConfig(String appName, AppConfigurationEntry[] entries)
    {
-      config.addAppConfig(appName, entries);
+      this.config.addAppConfig(appName, entries);
    }
-   
-   /** Remove an application login configuration.
+
+   /**
+    * Remove an application login configuration.
     */
    public void removeAppConfig(String appName)
    {
-      config.removeAppConfig(appName);
+      this.config.removeAppConfig(appName);
    }
 
    /**
     * @see XMLLoginConfigMBean#getApplicationPolicy(String)
     */
+   @ManagementOperation(description = "Get the application policy for the specified domain", impact = Impact.ReadOnly)
    public ApplicationPolicy getApplicationPolicy(String domainName)
    {
-      return (ApplicationPolicy)config.getApplicationPolicy(domainName); 
+      return (ApplicationPolicy) this.config.getApplicationPolicy(domainName);
    }
-   
-   /** Get the XML based configuration given the Configuration it should
-    delegate to when an application cannot be found.
+
+   /**
+    * Get the XML based configuration given the Configuration it should delegate to when an application cannot be found.
     */
+   @ManagementOperation(description = "Get the javax.security.auth.login.Configuration instance", impact = Impact.ReadOnly)
    public Configuration getConfiguration(Configuration prevConfig)
    {
-      config.setParentConfig(prevConfig);
-      return config;
+      this.config.setParentConfig(prevConfig);
+      return this.config;
    }
 
-   /** Load the login configuration information from the given config URL.
+   /**
+    * Load the login configuration information from the given config URL.
+    * 
     * @param configURL A URL to an XML or Sun login config file.
     * @throws Exception on failure to load the configuration
-    */ 
+    */
+   @ManagementOperation(description = "Load (parse) the login config file", impact = Impact.ReadWrite)
    public String[] loadConfig(URL configURL) throws Exception
    {
-      return config.loadConfig(configURL);
+      return this.config.loadConfig(configURL);
    }
 
+   @ManagementOperation(description = "Remove the configuration of the specified domains", impact = Impact.WriteOnly)
    public void removeConfigs(String[] appNames)
    {
       int count = appNames == null ? 0 : appNames.length;
-      for(int a = 0; a < count; a ++)
+      for (int a = 0; a < count; a++)
          removeAppConfig(appNames[a]);
    }
 
-   /** Display the login configuration for the given application.
+   /**
+    * Display the login configuration for the given application.
     */
+   @ManagementOperation(description = "Display the configuration for the specified domain", impact = Impact.ReadOnly)
    public String displayAppConfig(String appName)
    {
-      StringBuffer buffer = new StringBuffer("<h2>"+appName+" LoginConfiguration</h2>\n");
-      AppConfigurationEntry[] appEntry = config.getAppConfigurationEntry(appName);
-      if( appEntry == null )
+      StringBuffer buffer = new StringBuffer("<h2>" + appName + " LoginConfiguration</h2>\n");
+      AppConfigurationEntry[] appEntry = this.config.getAppConfigurationEntry(appName);
+      if (appEntry == null)
          buffer.append("No Entry\n");
       else
       {
-         for(int c = 0; c < appEntry.length; c ++)
+         for (int c = 0; c < appEntry.length; c++)
          {
             AppConfigurationEntry entry = appEntry[c];
-            buffer.append("LoginModule Class: "+entry.getLoginModuleName());
-            buffer.append("\n<br>ControlFlag: "+entry.getControlFlag());
+            buffer.append("LoginModule Class: " + entry.getLoginModuleName());
+            buffer.append("\n<br>ControlFlag: " + entry.getControlFlag());
             buffer.append("\n<br>Options:<ul>");
             Map options = entry.getOptions();
             Iterator iter = options.entrySet().iterator();
-            while( iter.hasNext() )
+            while (iter.hasNext())
             {
                Entry e = (Entry) iter.next();
                buffer.append("<li>");
-               buffer.append("name="+e.getKey());
-               buffer.append(", value="+e.getValue());
+               buffer.append("name=" + e.getKey());
+               buffer.append(", value=" + e.getValue());
                buffer.append("</li>\n");
             }
             buffer.append("</ul>\n");
@@ -177,24 +203,31 @@
       }
       return buffer.toString();
    }
-// --- End XMLLoginConfigMBean interface methods
 
-// --- Begin ServiceMBeanSupport overriden methods
+   // --- End XMLLoginConfigMBean interface methods
 
-   /** Load the configuration
+   // --- Begin ServiceMBeanSupport overriden methods
+
+   /**
+    * Load the configuration
     */
+   @Override
+   @ManagementOperation(description = "Service lifecycle operation", impact = Impact.WriteOnly)
    protected void startService() throws Exception
    {
-      config.loadConfig();
+      this.config.loadConfig();
    }
 
-   /** Clear all configuration entries
+   /**
+    * Clear all configuration entries
     */
+   @Override
+   @ManagementOperation(description = "Service lifecycle operation", impact = Impact.WriteOnly)
    protected void destroyService()
    {
-      config.clear();
+      this.config.clear();
    }
 
-// --- End ServiceMBeanSupport overriden methods
+   // --- End ServiceMBeanSupport overriden methods
 
 }

Modified: trunk/security/src/main/org/jboss/security/integration/JBossSecuritySubjectFactory.java
===================================================================
--- trunk/security/src/main/org/jboss/security/integration/JBossSecuritySubjectFactory.java	2008-11-24 21:57:34 UTC (rev 81516)
+++ trunk/security/src/main/org/jboss/security/integration/JBossSecuritySubjectFactory.java	2008-11-24 22:38:11 UTC (rev 81517)
@@ -26,6 +26,11 @@
 import javax.security.auth.Subject;
 
 import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
 import org.jboss.security.AuthenticationManager;
 import org.jboss.security.ISecurityManagement;
 import org.jboss.security.SecurityConstants;
@@ -39,6 +44,8 @@
  *  @since  May 19, 2008 
  *  @version $Revision$
  */
+ at ManagementObject(name = "JBossSecuritySubjectFactory", componentType = @ManagementComponent(
+                  type = "MCBean", subtype = "Security"))
 public class JBossSecuritySubjectFactory implements SubjectFactory
 { 
    protected static Logger log = Logger.getLogger(JBossSecuritySubjectFactory.class);
@@ -48,6 +55,8 @@
    /**
     * @see SubjectFactory#createSubject()
     */
+   @ManagementOperation(description="Create a subject using the modules specified in the 'other' security domain",
+         impact=ManagedOperation.Impact.ReadOnly)
    public Subject createSubject()
    { 
       return createSubject(SecurityConstants.DEFAULT_APPLICATION_POLICY);
@@ -56,6 +65,9 @@
    /**
     * @see SubjectFactory#createSubject(String)
     */
+   @ManagementOperation(description="Create a subject using the modules configured in the specified security domain",
+         params={@ManagementParameter(name="securityDomainName", description="The security domain name")},
+         impact=ManagedOperation.Impact.ReadOnly)
    public Subject createSubject(String securityDomainName)
    {
       if(this.securityManagement == null)

Modified: trunk/security/src/main/org/jboss/security/integration/JNDIContextEstablishment.java
===================================================================
--- trunk/security/src/main/org/jboss/security/integration/JNDIContextEstablishment.java	2008-11-24 21:57:34 UTC (rev 81516)
+++ trunk/security/src/main/org/jboss/security/integration/JNDIContextEstablishment.java	2008-11-24 22:38:11 UTC (rev 81517)
@@ -28,6 +28,8 @@
 import javax.naming.StringRefAddr;
 
 import org.jboss.logging.Logger;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.security.SecurityConstants;
 
 /**
@@ -38,11 +40,13 @@
  *  @since  Sep 10, 2007 
  *  @version $Revision$
  */
+ at ManagementObject(name = "JNDIContextEstablishment", componentType = @ManagementComponent(
+                  type = "MCBean", subtype = "Security"))
 public class JNDIContextEstablishment
 {
    private Logger log = Logger.getLogger(JNDIContextEstablishment.class);
    
-   protected String BASE_CTX = SecurityConstants.JAAS_CONTEXT_ROOT;
+   protected String baseContext = SecurityConstants.JAAS_CONTEXT_ROOT;
     
    private String factoryName = SecurityDomainObjectFactory.class.getName();
    
@@ -62,7 +66,7 @@
    {
       if(ctx == null)
          throw new IllegalArgumentException("ctx is null");
-      this.BASE_CTX = ctx;
+      this.baseContext = ctx;
       initialize();
    }
     
@@ -89,6 +93,6 @@
       */
      RefAddr refAddr = new StringRefAddr("nns", "JSM");
      Reference ref = new Reference("javax.naming.Context", refAddr, factoryName, null);
-     ctx.rebind(this.BASE_CTX, ref); 
+     ctx.rebind(this.baseContext, ref); 
    } 
 }

Modified: trunk/security/src/main/org/jboss/security/integration/SecurityDomainObjectFactory.java
===================================================================
--- trunk/security/src/main/org/jboss/security/integration/SecurityDomainObjectFactory.java	2008-11-24 21:57:34 UTC (rev 81516)
+++ trunk/security/src/main/org/jboss/security/integration/SecurityDomainObjectFactory.java	2008-11-24 22:38:11 UTC (rev 81517)
@@ -49,8 +49,7 @@
  *  @since  Sep 10, 2007 
  *  @version $Revision$
  */
-public class SecurityDomainObjectFactory
-implements InvocationHandler, ObjectFactory
+public class SecurityDomainObjectFactory implements InvocationHandler, ObjectFactory
 {
    private JNDIBasedSecurityManagement securityManagement = new JNDIBasedSecurityManagement();
    

Modified: trunk/security/src/main/org/jboss/security/plugins/SecurityConfig.java
===================================================================
--- trunk/security/src/main/org/jboss/security/plugins/SecurityConfig.java	2008-11-24 21:57:34 UTC (rev 81516)
+++ trunk/security/src/main/org/jboss/security/plugins/SecurityConfig.java	2008-11-24 22:38:11 UTC (rev 81517)
@@ -30,8 +30,14 @@
 import javax.security.auth.login.Configuration;
 
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.managed.api.ManagedOperation.Impact;
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
 import org.jboss.security.auth.login.XMLLoginConfig;
 import org.jboss.system.ServiceMBeanSupport;
 
@@ -44,7 +50,8 @@
  * @version $Revision: 58710 $
  */
 @JMX(name = "jboss.security:service=SecurityConfig", exposedInterface = SecurityConfigMBean.class)
- at ManagementObject(name="SecurityConfig", componentType=@ManagementComponent(type="MCBean", subtype="Security"))
+ at ManagementObject(name = "SecurityConfig", componentType = @ManagementComponent(type = "MCBean", subtype = "Security"), 
+                  properties = ManagementProperties.EXPLICIT)
 public class SecurityConfig extends ServiceMBeanSupport implements SecurityConfigMBean
 {
    /** The default Configuration mbean name */
@@ -62,6 +69,7 @@
    /**
     * Get the name of the mbean that provides the default JAAS login configuration
     */
+   @ManagementProperty(use = {ViewUse.CONFIGURATION}, description = "The default Configuration bean name")
    public String getLoginConfig()
    {
       return loginConfigName;
@@ -82,6 +90,7 @@
     * 
     * @return the {@code MBeanServer} that has been injected into this class.
     */
+   @ManagementProperty(use = {ViewUse.CONFIGURATION}, description = "The MBean server")
    public MBeanServer getMbeanServer()
    {
       if (this.mbeanServer == null)
@@ -108,6 +117,7 @@
     * 
     * @return a reference to the default login configuration bean.
     */
+   @ManagementProperty(use = {ViewUse.CONFIGURATION}, description = "The default login config bean")
    public XMLLoginConfig getDefaultLoginConfig()
    {
       return defaultLoginConfig;
@@ -129,6 +139,7 @@
     * Start the configuration service by pushing the mbean given by the LoginConfig onto the configuration stack.
     */
    @Override
+   @ManagementOperation(description = "Service lifecycle operation", impact = Impact.WriteOnly)
    public void startService() throws Exception
    {
       if (this.defaultLoginConfig != null)
@@ -141,6 +152,7 @@
     * Stop the configuration service by poping the top of the configuration stack.
     */
    @Override
+   @ManagementOperation(description = "Service lifecycle operation", impact = Impact.WriteOnly)
    public void stopService() throws Exception
    {
       if (this.loginConfigStack.empty() == false)
@@ -170,6 +182,9 @@
     * 
     * @see javax.security.auth.login.Configuration
     */
+   @ManagementOperation(description = "Install the Configuration from the MBean identified by objectName",
+         params={@ManagementParameter(name="objectName", description="The identifier of the MBean that contains the Configuration")},
+         impact = Impact.WriteOnly)
    public synchronized void pushLoginConfig(String objectName) throws JMException, MalformedObjectNameException
    {
       ObjectName name = new ObjectName(objectName);
@@ -186,6 +201,7 @@
     * 
     * @see javax.security.auth.login.Configuration
     */
+   @ManagementOperation(description = "Uninstall the current Configuration", impact = Impact.WriteOnly)
    public synchronized void popLoginConfig() throws JMException
    {
       // remove the current configuration from the stack.

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java	2008-11-24 21:57:34 UTC (rev 81516)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java	2008-11-24 22:38:11 UTC (rev 81517)
@@ -21,24 +21,37 @@
  */
 package org.jboss.test.profileservice.test;
 
+import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
 
 /**
- * TODO: validate the expected management interfaces
+ * <p>
+ * Profile service security tests.
+ * </p>
  * 
  * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
  * @version $Revision:$
  */
-public class SecurityManagedObjectsTestCase
-   extends AbstractProfileServiceTest
+public class SecurityManagedObjectsTestCase extends AbstractProfileServiceTest
 {
    protected ManagementView activeView;
 
+   /**
+    * <p>
+    * Creates an instance of {@code SecurityManagedObjectsTestCase} with the specified name.
+    * </p>
+    * 
+    * @param name a {@code String} representing the name of this {@code TestCase}.
+    */
    public SecurityManagedObjectsTestCase(String name)
    {
       super(name);
@@ -46,54 +59,182 @@
 
    /**
     * Looks for ComponentType("MCBean", "Security") type and logs them.
+    * 
     * @exception thrown if there are no matching components
     */
-   public void testSecurityMCBeans()
-      throws Exception
+   public void testSecurityMCBeans() throws Exception
    {
       ManagementView mgtMview = getManagementView();
       mgtMview.reloadProfile();
       ComponentType type = new ComponentType("MCBean", "Security");
       Set<ManagedComponent> mcs = mgtMview.getComponentsForType(type);
       assertTrue("There are MCBean,Security components", mcs.size() > 0);
-      getLog().debug("MCBeans: "+mcs);
+      getLog().debug("MCBeans: " + mcs);
    }
+
    /**
-    * Look at the SecurityConfig ManagedComponent
-    * @throws Exception
+    * <p>
+    * Validates at the {@code SecurityConfig} managed component.
+    * </p>
+    * 
+    * @throws Exception if an error occurs while running the test.
     */
-   public void testSecurityConfig()
-      throws Exception
+   public void testSecurityConfig() throws Exception
    {
-      ManagementView mgtMview = getManagementView();
+      ManagementView view = getManagementView();
       ComponentType type = new ComponentType("MCBean", "Security");
-      ManagedComponent mc = mgtMview.getComponent("SecurityConfig", type);
-      assertNotNull(mc);
+      ManagedComponent component = view.getComponent("SecurityConfig", type);
+      assertNotNull(component);
+      
+      // verify that the component has the expected properties.
+      Map<String, ManagedProperty> properties = component.getProperties();
+      assertNotNull(properties);
+      assertEquals("Unexpected number of properties", 3, properties.size());
+      assertTrue("Missing expected property: loginConfig", properties.containsKey("loginConfig"));
+      assertTrue("Missing expected property: mbeanServer", properties.containsKey("mbeanServer"));
+      assertTrue("Missing expected property: defaultLoginConfig", properties.containsKey("defaultLoginConfig"));
+      
+      // verify that the component has the expected operations.
+      String[] expectedOperations = {"startService", "stopService", "pushLoginConfig", "popLoginConfig"};
+      Set<ManagedOperation> operations = component.getOperations();
+      assertEquals("Unexpected number of operations", expectedOperations.length, operations.size());
+      // copy the names of the operations to a new collection to compare them with the expected names.
+      Set<String> operationNames = new HashSet<String>();
+      for(ManagedOperation operation : operations)
+         operationNames.add(operation.getName());
+      for(String expectedOperation : expectedOperations)
+         assertTrue("Expected operation " + expectedOperation + " not found", operationNames.contains(expectedOperation));
    }
+
    /**
-    * Look at the JNDIBasedSecurityRegistration ManagedComponent
-    * @throws Exception
+    * <p>
+    * Validates the {@code XMLLoginConfig} managed component.
+    * </p>
+    * 
+    * @throws Exception if an error occurs while running the test.
     */
-   public void testJNDIBasedSecurityRegistration()
-      throws Exception
+   public void testXMLLoginConfig() throws Exception
    {
-      ManagementView mgtMview = getManagementView();
+      // get the XMLLoginConfig managed component.
+      ManagementView managementView = super.getManagementView();
       ComponentType type = new ComponentType("MCBean", "Security");
-      ManagedComponent mc = mgtMview.getComponent("JNDIBasedSecurityRegistration", type);
-      assertNotNull(mc);
+      ManagedComponent component = managementView.getComponent("XMLLoginConfig", type);
+      assertNotNull(component);
+
+      // verify that the component has the expected properties.
+      Map<String, ManagedProperty> properties = component.getProperties();
+      assertNotNull(properties);
+      assertEquals("Unexpected number of properties", 2, properties.size());
+      assertTrue("Missing expected property: configURL", properties.containsKey("configURL"));
+      assertTrue("Missing expected property: validateDTD", properties.containsKey("validateDTD"));
+      
+      // verify that the component has the expected operations.
+      String[] expectedOperations = {"loadConfig", "setConfigResource", "displayAppConfig", "addApplicationPolicy",
+            "removeConfigs", "getApplicationPolicy", "getConfiguration"};
+      Set<ManagedOperation> operations = component.getOperations();
+      assertEquals("Unexpected number of operations", expectedOperations.length, operations.size());
+      // copy the names of the operations to a new collection to compare them with the expected names.
+      Set<String> operationNames = new HashSet<String>();
+      for(ManagedOperation operation : operations)
+         operationNames.add(operation.getName());
+      for(String expectedOperation : expectedOperations)
+         assertTrue("Expected operation " + expectedOperation + " not found", operationNames.contains(expectedOperation));
    }
-   public void testAll()
-      throws Exception
+
+   /**
+    * <p>
+    * Validates the {@code JNDIContextEstablishment} managed component.
+    * </p>
+    * 
+    * @throws Exception if an error occurs while running the test.
+    */
+   public void testJNDIContextEstablishment() throws Exception
    {
-      ManagementView mgtMview = getManagementView();
-      Set<String> names = mgtMview.getDeploymentNames();
-      for(String name : names)
+      // get the XMLLoginConfig managed component.
+      ManagementView managementView = super.getManagementView();
+      ComponentType type = new ComponentType("MCBean", "Security");
+      ManagedComponent component = managementView.getComponent("JNDIContextEstablishment", type);
+      assertNotNull(component);
+
+      // verify that the component has the expected properties.
+      Map<String, ManagedProperty> properties = component.getProperties();
+      assertNotNull(properties);
+      assertEquals("Unexpected number of properties", 2, properties.size());
+      assertTrue("Missing expected property: baseContext", properties.containsKey("baseContext"));
+      assertTrue("Missing expected property: factoryName", properties.containsKey("factoryName"));
+      
+      // verify that the component has the expected operations.
+      Set<ManagedOperation> operations = component.getOperations();
+      assertEquals("Unexpected number of operations", 0, operations.size());
+   }
+   
+   /**
+    * <p>
+    * Validates the {@code JBossSecuritySubjectFactory} managed component.
+    * </p>
+    * 
+    * @throws Exception if an error occurs while running the test.
+    */
+   public void testJBossSecuritySubjectFactory() throws Exception
+   {
+      // get the XMLLoginConfig managed component.
+      ManagementView managementView = super.getManagementView();
+      ComponentType type = new ComponentType("MCBean", "Security");
+      ManagedComponent component = managementView.getComponent("JBossSecuritySubjectFactory", type);
+      assertNotNull(component);
+
+      // verify that the component has the expected properties.
+      Map<String, ManagedProperty> properties = component.getProperties();
+      assertNotNull(properties);
+      assertEquals("Unexpected number of properties", 1, properties.size());
+      assertTrue("Missing expected property: securityManagement", properties.containsKey("securityManagement"));
+      
+      // this component should have 2 createSubject operations - one with no args and one with a String arg.
+      boolean foundNoArgOperation = false;
+      boolean foundStringArgOperation = false;
+      Set<ManagedOperation> operations = component.getOperations();
+      assertEquals("Unexpected number of operations", 2, operations.size());
+      for(ManagedOperation operation : operations)
       {
-         ManagedDeployment md = mgtMview.getDeployment(name, null);
-         System.out.println(md);
+         assertEquals("Unexpected operation found", "createSubject", operation.getName());
+         ManagedParameter[] parameters = operation.getParameters();
+         if(parameters.length == 0)
+         {
+            foundNoArgOperation = true;
+         }
+         else
+         {
+            assertEquals("Unexpected number of parameters", 1, parameters.length);
+            ManagedParameter parameter = parameters[0];
+            assertEquals("Invalid parameter name", "securityDomainName", parameter.getName());
+            assertEquals("Invalid parameter type", "java.lang.String", parameter.getMetaType().getClassName());
+            foundStringArgOperation = true;
+         }
       }
+      assertTrue(foundNoArgOperation);
+      assertTrue(foundStringArgOperation);
    }
+   
+   /**
+    * <p>
+    * Validates at the {@code JNDIBasedSecurityRegistration} managed component.
+    * </p>
+    * 
+    * @throws Exception if an error occurs while running the test.
+    */
+   public void testJNDIBasedSecurityRegistration() throws Exception
+   {
+      ManagementView mgtMview = getManagementView();
+      ComponentType type = new ComponentType("MCBean", "Security");
+      ManagedComponent mc = mgtMview.getComponent("JNDIBasedSecurityRegistration", type);
+      assertNotNull(mc);
+   }
 
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.test.profileservice.test.AbstractProfileServiceTest#getProfileName()
+    */
    @Override
    protected String getProfileName()
    {




More information about the jboss-cvs-commits mailing list