• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Database Login Module – JBoss

Database Login Module – JBoss

Fetches login info from a 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

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 indepth understanding on JBoss click on:

 

Summary
Review Date
Reviewed Item
Database Login Module - JBoss
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Database Login Module - JBoss"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.