6 Replies Latest reply on Dec 16, 2004 9:01 AM by karink

    Configuration DynamicLoginConfig

    karink

      Hi all,
      I have seen several posts regarding the DynamicLoginConfig, and started
      today to play around with it.

      I would like to exchange the login configuration just for a single web
      application and I'm just wondering where I have to supply my custom
      login config file in order to make it available to be loaded by the
      DynamicLoginConfig

      I deploy the web application by means of a service.xml file that looks like this:

      <server>
      
       <mbean code="org.jboss.security.auth.login.DynamicLoginConfig"
       name="jboss.security:applicational=SecurityConfig">
       <attribute name="AuthConfig">myloginconfig.xml</attribute>
       <depends optional-attribute-name="LoginConfigService">
       jboss.security:service=XMLLoginConfig
       </depends>
       <depends optional-attribute-name="SecurityManagerService">
       jboss.security:service=JaasSecurityManager
       </depends>
       </mbean>
       <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
       name="jboss.deployment.tcsample:type=DeploymentScanner,flavor=URL">
      
       <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>
      
       <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>
       <attribute name="Filter">org.jboss.deployment.scanner.DeploymentFilter</attribute>
       <attribute name="ScanPeriod">5</attribute>
       <attribute name="URLs">
       file:///C:/mydeploydirectory/
       </attribute>
      
      
       <attribute name="RecursiveSearch">True</attribute>
      
       </mbean>
      </server>


      I only managed to load the myloginconfig.xml file if it is located in the conf directory of the server. This is not the way I like to do it. Originally
      I liked to deploy it together with the web application (inside the exploded
      WAR file). Is this possible. I also tried it by means of using an absolute file url. But it did not work.

      Any help is appreciated.
      Regards
      Karin


        • 1. Re: Configuration DynamicLoginConfig
          starksm64

          It has to be a resource on the deployment classpath. For the given configuration this would need to be placed into the WEB-INF/classes directory of the war.

          • 2. Re: Configuration DynamicLoginConfig
            karink

            Hi Scott,
            thanx for your answer.

            If I put the file myloginconfig.xml in the WEB-INF/classes directory,
            it cannot be found when I start JBoss the first time.
            Then I redeployed the service.xml and the file myloginconfig.xml is found.
            So I does not work properly. Is this a bug?

            It would be also cool, to get the login config from somewhere on the
            filesystem (not as part of the web application).

            I tried to do it with the following configuration.

            <server>
            
             <classpath codebase="file:///C:/somedir/etc"/>
            
             <mbean code="org.jboss.security.auth.login.DynamicLoginConfig"
             name="jboss.security:applicational=SecurityConfig">
             <attribute name="AuthConfig">myloginconfig.xml</attribute>
             <depends optional-attribute-name="LoginConfigService">
             jboss.security:service=XMLLoginConfig
             </depends>
             <depends optional-attribute-name="SecurityManagerService">
             jboss.security:service=JaasSecurityManager
             </depends>
             </mbean>
            
             <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
            name="jboss.deployment.tcsample:type=DeploymentScanner,flavor=URL">
            
             <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>
            
            
             <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>
            
            
            
             <attribute name="Filter">org.jboss.deployment.scanner.DeploymentFilter</attribute>
            
             <attribute name="ScanPeriod">5</attribute>
            
            
             <attribute name="URLs">
             file:///C:/jboss-4.0/TomcatSampleServlets_jboss/deploy/
             </attribute>
            
             <attribute name="RecursiveSearch">True</attribute>
            
             </mbean>
            </server>
            


            The file myloginconfig.xml is located inside the directory specified in the codebase (C:/somedir/etc). Jboss was not able to locate the file (not even during redeployment). Does anybody know how the configuration must look.

            By the way I use JBoss [Zion] 4.0.0 on Win (jdk 1.4.2).
            Regards Karin

            • 3. Re: Configuration DynamicLoginConfig
              starksm64

              Its not a bug. You cannot deploy a service from the conf/jboss-service.xml file and have that see classes or resources from anything but the server/lib directory and server/conf directory. The web app needs to be deployed as a war that includes a seperate service configuration for the DynamicLoginConfig service.

              • 4. Re: Configuration DynamicLoginConfig
                karink

                Hi Scott,
                you misunderstood me. I do not use the conf/jboss-service.xml file
                to configure this. I have a file called TomcatSample-service.xml file, which
                is located in the deploy directory of JBoss. This file references
                a directory C:/jboss-4.0/TomcatSampleServlets_jboss/deploy/
                where my exploded WAR-file is located.

                But anyway. I do not know where I can define such things as a DynamicLoginConfig service inside a WAR file. Is this really
                such a great idea. I mean normally a WAR
                file should correspond to the J2EE standard and it should
                not matter in which container it is running. I think, container dependent
                things should be defined somewhere else.

                Regards
                Karin

                • 5. Re: Configuration DynamicLoginConfig
                  starksm64

                  A war file cannot contain anything but servlets. You need to use an ear to bundle a war with other deployment types like services and ejbs.

                  In terms of your example, your simply missing the trailing '/' in the TomcatSample-service.xml classpath. The following works fine for me:

                  <server>
                   <classpath codebase="file:///C:/tmp/etc/"/>
                  
                   <mbean code="org.jboss.security.auth.login.DynamicLoginConfig"
                   name="jboss.security:applicational=SecurityConfig">
                   <attribute name="AuthConfig">myloginconfig.xml</attribute>
                   <depends optional-attribute-name="LoginConfigService">
                   jboss.security:service=XMLLoginConfig
                   </depends>
                   <depends optional-attribute-name="SecurityManagerService">
                   jboss.security:service=JaasSecurityManager
                   </depends>
                   </mbean>
                  
                   <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
                   name="jboss.deployment.tcsample:type=DeploymentScanner,flavor=URL">
                   <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>
                   <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>
                   <attribute name="Filter">org.jboss.deployment.scanner.DeploymentFilter</attribute>
                   <attribute name="ScanPeriod">5</attribute>
                   <attribute name="URLs">
                   file:///C:/tmp/TomcatSampleServlets_jboss/deploy/
                   </attribute>
                   <attribute name="RecursiveSearch">True</attribute>
                   </mbean>
                  </server>
                  


                  Note that we have not tested multiple deployments of the URLDeploymentScanner so there may be some multi-threaded issue with your war deployments. The URLs property accepts a comma seperated list so the second deploy directory can be specified in the conf/jboss-service.xml like:

                   <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
                  name="jboss.deployment:type=DeploymentScanner,flavor=URL">
                  ...
                   <attribute name="URLs">
                   deploy/,file:///C:/tmp/TomcatSampleServlets_jboss/deploy/
                   </attribute>
                  ...
                  



                  • 6. Re: Configuration DynamicLoginConfig
                    karink

                    Hi Scott,
                    thanks for your answer.
                    Now it works fine. Also thanks for the hint regarding deploying the
                    UrlDeploymentScanner multiple times. We will not
                    use this in a production (possibly only during development).
                    Regards Karin