If you need a quick solution, why not use standard JSP/Servlet security. This is easy to implement and you do not need to install extra software.
Just add some lines to your web.xml:
Code:
<security-constraint>
<web-resource-collection>
<web-resource-name>MyApp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>MyApp</realm-name>
</login-config>
<security-role>
<role-name>user</role-name>
</security-role>
Next you need to define the users. In Tomcat you add them by editing the tomcat-users.xml file.
Code:
<tomcat-users>
<user name="tomcat" password="tomcat" roles="tomcat" />
<user name="role1" password="tomcat" roles="role1" />
<user name="both" password="tomcat" roles="tomcat,role1" />
<!-- User of MyApp -->
<user name="johndoe" password="johndoe" roles= "user" />
</tomcat-users>
Greetz,
Arjan