JavaEE6チュートリアルの章「Webアプリケーションの保護の開始」と特に提供されている例をお読みください。
アプリケーションは2つのセキュリティロールを宣言する必要がuser
ありapprover
、のweb.xml
おかげでサーブレットパスを保護する必要がありますsecurity-constraints
。
出発点としての設定は次のとおりです。
<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.