Home

This Chapter
-Chapter 13: Securing Struts Applications
-Principals and Roles
-Writing Security Policy
-Authentication Methods
-Hiding Resources
-Struts Security Configuration
-Programmatic Security
-Summary

Table of Contents
-Introduction
-Chapter 1: Model 2 and Struts
-Chapter 2: Input Validation with Action Forms
-Chapter 3: The HTML Tag Library
-Chapter 4: Input Validation and Data Conversion
-Chapter 5: The Validator Plugin
-Chapter 6: The Expression Language
-Chapter 7: JSTL
-Chapter 8: The Bean Tag Library
-Chapter 9: The Logic Tag Library
-Chapter 10: Struts-EL, Nested, selectLabel
-Chapter 11: Message Handling and Internationalization
-Chapter 12: The Tiles Framework
-Chapter 13: Securing Struts Applications
-Chapter 14: The Config Object
-Chapter 15: The Persistence Layer
-Chapter 16: Object Caching
-Chapter 17: File Upload and File Download
-Chapter 18: Paging and Sorting
-Chapter 19: Preventing Double Submits
-Chapter 20: Early HttpSession Invalidation
-Chapter 21: Decorating Request Objects
-Chapter 22: How Struts Works

Previous
Next

 

Principals and Roles

A principal is an entity which can be either an individual or an organization. A role is an abstract grouping of users. Regard a role as a position. Vera, Chuck and Dave are users. Administrator, Director, Manager, Programmer are roles. Any user can be in no role or in many roles. For example, Vera can be in the Manager and Programmer roles, Chuck can be in the Administrator role, and so on.

Every servlet container provides you with a different mechanism of managing users and roles. You should consult the documentation that accompanies the servlet container on this.

In Tomcat, for example, you do this by editing the tomcat-users.xml file under the conf directory of the deployment directory. For example, here is an example of the tomcat-users-xml file.

<tomcat-users>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="vera" password="arev" roles="manager"/>
  <user username="chuck" password="chuck" roles="admin"/>
  <user username="dave" password="secret" roles="manager,admin"/>
</tomcat-users>

The file says that there are two roles (admin and manager) and three users (vera, chuck, and dave). You can add as many roles and users as you want to the tomcat-users.xml file.

Previous
Next