Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
You will build and deploy a very simple web application that contains two JSF forms.
You will create user and userrole tables in the MySQL database. These tables contains the users
username and password required to login. You must configure JBoss AS to use form based login to
authenticate a user. If the user supplies a valid username and password create a session scoped
UserContext object which contains the users username, email and their roles. Use this object to provide
information to an audit inceptor that is used to log the user that inserts a hobby object in the database.
Using MySQL Implement three tables. The SQL script is provided below.
create table user (
user_id bigint auto_increment,
email varchar(40),
username varchar(12),
password varchar(20)
);
primary key(user_id);
create table userrole (
role_id bigint auto_increment,
user_id bigint not null,
rolename varchar(20) not null,
);
primary key (role_id);
foreign key (user_id) references user (user_id);
create table userhobby (
id bigint auto_increment,
name varchar(10) not null,
hobby varchar(20) not null,
createdBy varchar(40) not null,
createdOn DateTime not null,
);
primary key (id);
Create sample data for the user and userrole tables and insert it into the database.
Configure the JBoss application server to implement a security realm using the user and userrole
database tables.
Configure the JBoss application server to implement form based login.
Create the login.xhtml and userhobby.xhtml forms and the server side components that will be
required to process them.
Deploy the web application to the application server.
Launch the login form, collect the username and password and submit the form. When a user
successfully logins by providing a valid username and password, create a session scoped
UserContext EJB that contains the users username, email and list of roles. This information must
be obtained from the database user and userroles tables.
Launch the hobby form, collect and submit the form which saves this data in the database.
During the process of saving the hobby object implement a simple audit Inceptor that examines
the UserContext and populates the createdBy and createdOn columns of the hobby table.