Java Reference
In-Depth Information
outcome is the following login screen, which will intercept all user access to your ap-
plication and grant access to the default home page if the username and password
credentials are correct.
Creating a Database login module
The UserRoles login module is a good starting point for learning how to put togeth-
er all the pieces required for securing a web application. In real-world cases, there
are better alternatives to protect your applications, such as the Database login mod-
ule. A database security domain follows the same logic exposed in the earlier ex-
ample; it just stores the credentials within the database. In order to run this example,
we will refer to a data source defined in Chapter 5 , Combining Persistence with CDI
(bound at the JNDI name java:jboss/datasources/jbossas7development ),
which needs to be deployed on the application server:
<security-domain name="mysqldomain"
cache-type="default">
<authentication>
<login-module code="Database"
flag="required">
<module-option name="dsJndiName" value="
java:jboss/datasources/jbossas7development"/>
<module-option name="principalsQuery"
value="select passwd from USERS where login=?"/>
<module-option name="rolesQuery"
value="select role, 'Roles' from USER_ROLES
where login=?"/>
</login-module>
Search WWH ::




Custom Search