0 Replies Latest reply on Sep 1, 2014 6:03 AM by faith chen

    custom DatabaseServerLoginModule not work

    faith chen Newbie

      server:jboss as 6.0

       

      db schema

      CREATE TABLE IF NOT EXISTS `userroles` (  `username` varchar(64) NOT NULL,  `userRoles` varchar(64) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;

      CREATE TABLE IF NOT EXISTS `users` (`username` varchar(64) NOT NULL,`passwd` varchar(64) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;

      INSERT INTO `users` (`username`, `passwd`) VALUES ('admin', '123456');

      INSERT INTO `userroles` (`username`, `userRoles`) VALUES ('admin', 'admins');

       

      domain.xml

      <security-domain name="mysqldb" cache-type="default">

         <authentication>

            <login-module code="Database" flag="required">

            <module-option name="dsJndiName" value="java:/mysql"/>

            <module-option name="principalsQuery" value="select passwd from Users username where username=?"/>

            <module-option name="rolesQuery" value="select userRoles, 'Roles' from UserRoles where username=?"/>

            </login-module>

         </authentication>

      </security-domain>

       

      web.xml

      <security-constraint>

              <web-resource-collection>

                  <web-resource-name>HtmlAdaptor</web-resource-name>

                  <description>An example</description>

                  <url-pattern>/*</url-pattern>

              </web-resource-collection>

              <auth-constraint>

                  <role-name>*</role-name>

              </auth-constraint>

          </security-constraint>

          <login-config>

              <auth-method>BASIC</auth-method>

              <realm-name>mysqldb</realm-name>

          </login-config>

          <security-role>

              <role-name>*</role-name>

          </security-role>

       

       

       

      jboss-web.xml

      <jboss-web>

         <security-domain>java:/jaas/mysqldb</security-domain>

      </jboss-web>

       

      i try my ap

      http://localhost:8080/testdb

      input username:admin / password:123456

      just

      JBWEB000065: HTTP Status 401

       

      is config wrong???