1 Reply Latest reply on Dec 1, 2004 3:15 PM by hillel

    help mysql with JAAS Howto

    hillel

      Hi,

      I does anyone know how to get mysql to work with JAAS?
      I'm testing with the Howto and it does not work? Any help appreciated

      1) I added the details to the database - this worked and I can see the details in the mysql database.
      <!-- Build the DatabaseServerLoginModule tables -->



      <![CDATA[

      DROP TABLE Principals;
      DROP TABLE Roles;
      CREATE TABLE Principals (PrincipalID VARCHAR(64) PRIMARY KEY, Password VARCHAR(64) );
      CREATE TABLE Roles (PrincipalID VARCHAR(64), Role VARCHAR(64), RoleGroup VARCHAR(64) );
      INSERT INTO Principals VALUES ('java', 'echoman');
      INSERT INTO Principals VALUES ('duke', 'javaman');
      INSERT INTO Roles VALUES ('java', 'Echo', 'Roles');
      INSERT INTO Roles VALUES ('duke', 'Java', 'Roles');
      INSERT INTO Roles VALUES ('duke', 'Coder', 'Roles');
      ]]>



      2) I added into the mysql-ds.xml in /usr/local/jboss-3.2.6/server/default/deploy
      <local-tx-datasource>
      <jndi-name>TestDefaultDS</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/test
      </connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>user</user-name>
      pass
      <security-domain>MysqlDbRealm</security-domain>
      </local-tx-datasource>

      3)I added to login-config.xml in /usr/local/jboss-3.2.6/server/default/conf

      <application-policy name="example2">

      <!-- A JDBC based LoginModule
      LoginModule options:
      dsJndiName: The name of the DataSource of the database containing the Principals, Roles tables
      principalsQuery: The prepared statement query equivalent to:
      "select Password from Principals where PrincipalID=?"
      rolesQuery: The prepared statement query equivalent to:
      "select Role, RoleGroup from Roles where PrincipalID=?"
      unauthenticatedIdentity: the principal assigned to callers without any authentication info
      -->
      <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
      flag="required">
      <module-option name="dsJndiName">java:/TestDefaultDS</module-option>
      <module-option name="principalsQuery">select Password from Principals where PrincipalID=?</module-option>
      <module-option name="rolesQuery">select Role, RoleGroup from Roles where PrincipalID=?</module-option>
      </login-module>

      </application-policy>

      <application-policy name = "MySqlDbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
      flag = "required">
      <module-option name = "principal">sa</module-option>
      <module-option name = "userName">user</module-option>
      <module-option name = "password">pass</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=TestDefaultDS</module-option>
      </login-module>

      </application-policy>