Engineering Full Stack Apps with Java and JavaScript
FORM Based Authentication - Without Container Template
Create a Dynamic Web Project with a web.xml file; name it as ServletSecurity.
Create a servlet RestrictedServlet with url pattern “/RestrictedServlet” that print “Restricted Servlet” to client.
Create a servlet LoginServlet with url pattern “/LoginServlet” that gets the username and password from client and validate it against a dummy hashmap of username and password.
Create a form in JSP/html file for authenticating users with FORM based authentication using custom fields for username and password and submit the form to LoginServlet.
Create a JSP/html file to display in case of a login failure
Declare the type of authentication as FORM and specify the login form and error page in the web.xml.
Define roles, users and create mapping between them
Make entries in web.xml so that this security constraint is applied to any requests that come to the applicaiton, including to the servlet RestrictedServlet
Map roles with security constraints
Test login success and login failure scenarios
See the actual requests and responses between client and server using a protocol analyzer such as tcpmon or wireshark.
FORM Based Authentication - With Container Template
Create a Dynamic Web Project with a web.xml file; name it as ServletSecurity.
Create a servlet RestrictedServlet with url pattern “/RestrictedServlet” that print “Restricted Servlet” to client.
Create a form in JSP/html file for authenticating users with FORM based authentication using the default template provided by container.
Create a JSP/html file to display in case of a login failure
Declare the type of authentication as FORM and specify the login form and error page in the web.xml.
Define roles, users and create mapping between them
Make entries in web.xml so that this security constraint is applied to any requests that come to the applicaiton, including to the servlet RestrictedServlet
Map roles with security constraints
Test login success and login failure scenarios
See the actual requests and responses between client and server using a protocol analyzer such as tcpmon or wireshark.