I invite you to read JavaEE 6 Tutorial chapter "Getting Started Securing Web Applications" and in particular provided examples.
Your application has to declare the two security roles user
and approver
and the web.xml
has to protect servlet path thanks to security-constraints
.
Here is such a setup as a starting point:
<security-constraint>
<display-name>Raise Request</display-name>
<web-resource-collection>
<web-resource-name>raiserequestservlet</web-resource-name>
<description/>
<url-pattern>/raiserequest</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>Approve Request</display-name>
<web-resource-collection>
<web-resource-name>approverequestservlet</web-resource-name>
<description/>
<url-pattern>/approverequest</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>approver</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>WebSphere</realm-name>
</login-config>
<security-role>
<description>Security Role required to raise a request</description>
<role-name>user</role-name>
</security-role>
<security-role>
<description>Security Role required to approve a request</description>
<role-name>approver</role-name>
</security-role>
For first tests, I have chosen basic authentication but there are other options.
Then, when deploying the WAR package into WebSphere, the wizard will allow you to map the two application roles to LDAP groups as far as you use LDAP as backend for authentication and permissions, what is highly recommended.
The server instance which runs the application is configured to use the Global security by default, but you can create a dedicated Security domain for your server/application couple to use a dedicated backend. Here is the network deployment reference documentation security section to guide you for that aspects.