Enterprise Java Development@TOPIC@

Chapter 114. Web Tier Access Control

114.1. Authentication
114.2. Security Constraints (web.xml)
114.3. FORM-based Login
114.4. BASIC Authentication
114.5. Summary

  • Anything accessed via specified url-pattern must have admin role-name

  • Communication must be encrypted (i.e., switch to HTTPS)


  • Obtain missing user credentials using FORM when navigating to protected urls


  • Servlet accessible via multiple URLs

Example Creates Security Hole on Purpose

The example creates a security hole on purpose to be able to demonstrate EJB security backs the WEB security. The servlet mapped above is accessible through multiple URLs -- each restricted differently but attempting to provide the same functionality. If you access the servlet through the anonymous URL you will encounter many access failures communicating with the EJB. If you access the servlet using the admin URL you will be able to access all functionality.


  • Assigning web-tier to same security-domain as EJB tier


  • form action j_security_check is a standard container action for login forms

  • j_username input field name standard for username

  • j_password input field name standard for password


  • uri-path constrained to use only HTTPS


  • EJB returning formatted string with caller role information

  • Caller authenticated at web-tier and passed to EJB

  • EJB and WAR using same security-domain


  • BASIC authentication requested for any missing credentials

  • URL selected also not enforcing confidential (i.e., HTTPS)


  • Authenticate user passed to EJB

  • EJB rejects unauthorized caller