11 Replies Latest reply on Nov 26, 2008 12:46 PM by starksm64

    ProfileService Guidance

    anil.saldhana

      I am trying to apply the management annotations on the security beans.

      As an example, I have a bean

      @ManagementObject(
       componentType = @ManagementComponent(type = "MCBean", subtype = "*"),
       properties = ManagementProperties.EXPLICIT)
      @ManagementObjectID(name="JBossSecuritySubjectFactory")
      public class JBossSecuritySubjectFactory implements SubjectFactory, Serializable
      {
       private static final long serialVersionUID = 1L;
      


      Now in the following test code:
      public void testSecurityBeans() throws Exception
       {
       ManagementView managementView = this.getManagementView();
       assertNotNull(managementView);
       ComponentType type = new ComponentType("MCBean", "*");
      
       Set<ManagedComponent> managedSet = managementView.getComponentsForType(type);
       ManagedComponent component = managementView.getComponent("JBossSecuritySubjectFactory", type);
      
       }
      

      both managedSet and component are null.

      I do not know what else is needed.

        • 1. Re: ProfileService Guidance
          starksm64

          That should be all. I'll take a look at what the mcbean deployer managed object factory is doing.

          • 2. Re: ProfileService Guidance
            starksm64

            Its related to JBMICROCONT-362.

            • 3. Re: ProfileService Guidance
              starksm64

              I'll have this working tomorrow with the 2.0.0.CR3 release of jboss-managed/jboss-metatype. I'll commit a SecurityManagedObjectsTestCase for the managed objects that should be validated as part of the profileservice unit tests. We'll have to do some work on the security beans as they are still too mbean-ish with xml parsing embedded.

              • 4. Re: ProfileService Guidance
                anil.saldhana

                Scott, we still support the legacy parsing methods. But we recommend stefan's work on BeanMetaDataFactory
                http://anonsvn.jboss.org/repos/jbossas/projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/

                An example of the latest config would be:

                http://anonsvn.jboss.org/repos/jbossas/trunk/testsuite/src/resources/security/jaspi/jaspi-webbasic-jboss-beans.xml

                Imagine

                <authentication> <authorization> <audit> blocks
                


                • 5. Re: ProfileService Guidance
                  starksm64

                  If we are going to keep the old security objects they really should have a similar management interface to the new beans where it make sense. Beans annotated at the bean class level with @ManagementObject are now showing up and the SecurityManagedObjectsTestCase shows obtaining the SecurityConfig whose component type is "MCBean","Security". There is an annotation on the JNDIBasedSecurityRegistration deployment:

                   <bean name="JNDIBasedSecurityRegistration"
                   class="org.jboss.security.integration.JNDIBasedSecurityRegistration">
                   <!-- This has to be on one line, see JBMDR-49 -->
                   <annotation>@org.jboss.managed.api.annotation.ManagementObject(name="JNDIBasedSecurityRegistration",componentType=@org.jboss.managed.api.annotation.ManagementComponent(type="MCBean", subtype="Security"))</annotation>
                   <property name="policyRegistration"><inject bean="JBossSecurityPolicyRegistration" /></property>
                   <property name="securityManagement"><inject bean="JNDIBasedSecurityManagement" /></property>
                   </bean>
                  


                  which should also be showing up, but currently is not as the metadata level annotation is not propagated to the management object factory. I'm looking into what to do about that.


                  • 6. Re: ProfileService Guidance
                    sguilhen

                    Scott,

                    the SecurityManagedObjectsTestCase includes a test for a security bean annotated with @ManagedObject in the security-jboss-beans.xml deployment, and this test started failing since build #1080. You mentioned problems with this specific test before (metadata level annotation not being propagated to the management object factory). Do you think we have the same issue again or is it possible that something else is preventing this bean from showing up through in ManagementView.getComponent?

                    • 7. Re: ProfileService Guidance
                      starksm64

                      Its passing locally for me with the changes I have for a few different profile service issues. I'll check the changes in once a couple other regressions are fixed.

                      • 8. Re: ProfileService Guidance
                        starksm64

                        This should be working in trunk for you now.

                        • 9. Re: ProfileService Guidance
                          sguilhen

                          Yes, it is working again in trunk. Thanks, Scott.

                          • 10. Re: ProfileService Guidance
                            sguilhen

                            I am developing a test case for managed security domains, and as part of this test I deploy a sample testdomains-jboss-beans.xml that contains some JaasSecurityDomain bean declarations:

                            <?xml version="1.0" encoding="UTF-8"?>
                            
                            <!-- sample security domain beans used in the profile service tests -->
                            <deployment xmlns="urn:jboss:bean-deployer:2.0">
                            
                             <annotation>@org.jboss.managed.api.annotation.ManagementDeployment(description="JBoss SecurityDomain Beans")</annotation>
                            
                             <bean name="TestDomain1" class="org.jboss.security.plugins.JaasSecurityDomain">
                             <constructor>
                             <parameter>TestDomain1</parameter>
                             </constructor>
                             <property name="keyStorePass">somepass1</property>
                             <property name="salt">abcdefgh</property>
                             <property name="iterationCount">13</property>
                             </bean>
                            
                             <bean name="TestDomain2" class="org.jboss.security.plugins.JaasSecurityDomain">
                             <constructor>
                             <parameter>TestDomain2</parameter>
                             </constructor>
                             <property name="keyStorePass">somepass2</property>
                             <property name="salt">abcdefgh</property>
                             <property name="iterationCount">17</property>
                             </bean>
                            
                            </deployment>
                            


                            However, I noticed that the JaasSecurityDomain beans are only processed by the Management view if the testdomains-jboss-beans.xml file is deployed before starting the profileservice partition. If I deploy this file after the server has been started, it is not processed by the management layer and thus the JaasSecurityDomain managed objects cannot be found when calling ManagementView.getComponent().

                            In the test method, I am doing something along the lines of

                             String resource = getResource("profileservice/security/testdomains-jboss-beans.xml");
                             super.deploy(resource);
                            
                             ManagementView managementView = getManagementView();
                             managementView.reloadProfile();
                             ComponentType type = new ComponentType("MCBean", "Security");
                             ManagedComponent mc = managementView.getComponent("TestDomain1", type);
                             assertNotNull(mc);
                            
                             super.undeploy(resource);
                            


                            The code above returns a null ManagedComponent, unless I deploy the testdomains-jboss-beans.xml before starting the AS. So, my question is what do I need to do to properly register the managed components at runtime? I'm guessing that only deploying the -jboss-beans.xml is not enough and that I need somehow to notify the management components to process the newly created beans.

                            • 11. Re: ProfileService Guidance
                              starksm64

                              The test would need to use the profileservice DeploymentManager api rather than the old MainDeployer as this bypasses registration of the deployment with the profileservice and it won't be visible in the profile. See the org.jboss.test.profileservice.test.DeployUnitTestCase.