Database Login Module - JBoss

Ratings:
(4)
Views:0
Banner-Img
  • Share this blog:

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).

To enrich your career and become a JBoss professional, visit Tekslate, the global online training platform:" JBoss Training". This course will help you achieve excellence in this field.

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 an auth-specific read-only database user, but we create one because it is a good practice.

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 Create deploy/authority-ds.xml:

<datasources>
<local-tx-datasource>
<jndi-name>AuthorityDB</jndi-name>
<connection-url>
jdbc:mysql://localhost:3306/Authority?
autoReconnect=true
</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>authority</user-name>
<password>authsecret</password>
...
</local-tx-datasource>
</datasources>

Define a database connection pool (resource) that will provide connectivity to the Authority database.

For an in-depth understanding on JBoss click on:

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox