Database Login Module – JBoss
Fetches login info from an RDBMS
Works with existing DB schemas
Uses pooled database connections
Scales well as the user population grows
Does not require server or application restarts on info change 14.6.1. MySQL Schema/DB Setup
Database Login Module depends on our ability to set up (and link to) a JBoss-managed DataSource (database connection pool).
term#> mysql/bin/mysql -u root -p
mysql> CREATE DATABASE Authority;
mysql> USE Authority;
mysql> CREATE TABLE Users (Username VARCHAR(32) NOT NULL PRIMARY KEY,Password VARCHAR(32) NOT NULL);
mysql> CREATE TABLE Roles (Username VARCHAR(32) NOT NULL,Rolename VARCHAR(32) NOT NULL,PRIMARY KEY (Username, Rolename));
mysql> GRANT SELECT ON Authority.* TO authority@localhost IDENTIFIED BY “authsecret”;
It is important that the password field be at least 32 characters in order to accommodate MD5-digest-based passwords (more on this later).
You do not have to create a separate database, nor do you need separate tables, but we assume that we are starting from scratch. The default JBoss AS schema for User/Role information is as follows:
Table Principals(PrincipalID text, Password text)
Table Roles(PrincipalID text, Role text, RoleGroup text) Populate the database. For example:
You also do not need a auth-specific read-only database user, but we create one because it is a good practice.
Interested in mastering JBOSS? Learn more about JBOSS Tutorial in this blog post.
INSERT INTO Users VALUES (“john”, “secret”);
INSERT INTO Roles VALUES (“john”, “MyRole”);
INSERT INTO Users VALUES (“bob”, “abc123”);
INSERT INTO Roles VALUES (“bob”, “MyRole”);
INSERT INTO Roles VALUES (“bob”, “Manager”);
INSERT INTO Users VALUES (“mike”, “passwd”);
INSERT INTO Roles VALUES (“mike”, “Manager”);
INSERT INTO Roles VALUES (“mike”, “Admin”);
Authority Database Resource
Define a database connection pool (resource) that will provide connectivity to the Authority database.
For indepth understanding on JBoss click on: