2 Replies Latest reply on Oct 20, 2004 3:36 AM by Ralf Siedow

    Porting a WAR using JAAS to the JBoss 4 Tomcat

    Ralf Siedow Newbie

      Hello guys,

      I've got a web application as a war which deploys fine on tc 5 using a custom jaas.config and a custom login module. When I deploy the same war the authentication doesn't work anymore as the LoginContext contains the JBoss provided login modules. I'd like to use my own. How can I specify within a configuration file included in the war to add my login module to the login context? I don't want to modify any JBoss files like login-config.xml.

      I tried:
      http://www.jboss.org/wiki/Wiki.jsp?page=DynamicLoginConfig
      but when I deploy the -service.xml it complains that several login modules (the jboss provided modules) are already existing.

      <server>
       <mbean code="org.jboss.security.auth.login.DynamicLoginConfig" name="jboss.security:service=SwitchPortalLogin">
      
       <attribute name="AuthConfig">login-config.xml</attribute>
      
       <depends optional-attribute-name="LoginConfigService">
       jboss.security:service=XMLLoginConfig
       </depends>
      
       <depends optional-attribute-name="SecurityManagerService">
       jboss.security:service=JaasSecurityManager
       </depends>
      
       </mbean>
      </server>
      
      
      


      My META-INF/jboss-web.xml looks like:
      <jboss-web>
       <security-domain>java:/jaas/DBLogin</security-domain>
      </jboss-web>
      


      META-INF/login-config.xml:
      <application-policy name="DBLogin">
       <authentication>
       <login-module code="de.vpe.login.DBLogin" flag="required" />
       </authentication>
      </application-policy>
      


      My authentication code:
      lc = new LoginContext("DBLogin", new MyCallbackHandler(user, password));
      lc.login();
      


      Before moving to JBoss Tomcat deployment I loaded the jaas.config with the following code:
      System.setProperty("java.security.auth.login.config", jaasConfig);
      

      but the login modules specified here where not available to the LoginContext.

        • 1. Re: Porting a WAR using JAAS to the JBoss 4 Tomcat
          Scott Stark Master

          Show the errors your seeing and describe where the login module is located in the deployment.

          • 2. Re: Porting a WAR using JAAS to the JBoss 4 Tomcat
            Ralf Siedow Newbie

            When I deploy my -service.xml this is what JBoss writes to the log:

            09:25:47,066 WARN [XMLLoginConfigImpl] Failed to parse config for entry:client-login
            java.security.KeyException: Config name: client-loginalready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadConfig(XMLLoginConfigImpl.java:284)
             at org.jboss.security.auth.login.XMLLoginConfig.loadConfig(XMLLoginConfig.java:103)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
             at org.jboss.security.auth.login.DynamicLoginConfig.startService(DynamicLoginConfig.java:145)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
             at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
             at $Proxy0.start(Unknown Source)
             at org.jboss.system.ServiceController.start(ServiceController.java:416)
             at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
             at $Proxy4.start(Unknown Source)
             at org.jboss.deployment.SARDeployer.start(SARDeployer.java:261)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:935)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:746)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
             at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:119)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
             at $Proxy8.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:481)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,072 WARN [XMLLoginConfigImpl] Failed to parse config for entry:jbossmq
            java.security.KeyException: Config name: jbossmqalready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadConfig(XMLLoginConfigImpl.java:284)
             at org.jboss.security.auth.login.XMLLoginConfig.loadConfig(XMLLoginConfig.java:103)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,162 WARN [XMLLoginConfigImpl] Failed to parse config for entry:HsqlDbRealm
            java.security.KeyException: Config name: HsqlDbRealmalready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadConfig(XMLLoginConfigImpl.java:284)
             at org.jboss.security.auth.login.XMLLoginConfig.loadConfig(XMLLoginConfig.java:103)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,331 WARN [XMLLoginConfigImpl] Failed to parse config for entry:FirebirdDBRealm
            java.security.KeyException: Config name: FirebirdDBRealmalready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,341 WARN [XMLLoginConfigImpl] Failed to parse config for entry:JmsXARealm
            java.security.KeyException: Config name: JmsXARealmalready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,373 WARN [XMLLoginConfigImpl] Failed to parse config for entry:jmx-console
            java.security.KeyException: Config name: jmx-consolealready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,381 WARN [XMLLoginConfigImpl] Failed to parse config for entry:web-console
            java.security.KeyException: Config name: web-consolealready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,391 WARN [XMLLoginConfigImpl] Failed to parse config for entry:jboss.net
            java.security.KeyException: Config name: jboss.netalready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,396 WARN [XMLLoginConfigImpl] Failed to parse config for entry:jboss.net-uddi
            java.security.KeyException: Config name: jboss.net-uddialready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,400 WARN [XMLLoginConfigImpl] Failed to parse config for entry:other
            java.security.KeyException: Config name: otheralready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
            09:25:47,416 WARN [XMLLoginConfigImpl] Failed to parse config for entry:DBLogin
            java.security.KeyException: Config name: DBLoginalready exists
             at org.jboss.security.auth.login.XMLLoginConfigImpl.loadXMLConfig(XMLLoginConfigImpl.java:328)
            [schnip]
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)