Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop security > Develop extensions to the WebSphere security infrastructure > Customize web application login > Develop servlet filters for form login processing
Configure servlet filters for form login processing
IBM Rational Application Developer or an assembly tool can configure the servlet filters. Two steps are involved in configuring a servlet filter.
Procedure
- Name the servlet filter and assign the corresponding implementation class to the servlet filter.
Optionally, assign initialization parameters that get passed to the init method of the servlet filter. After configuring the servlet filter, the web.xml application deployment descriptor contains a servlet filter configuration similar to the following example:
<filter id="Filter_1"> <filter-name>LoginFilter </filter-name> <filter-class>LoginFilter </filter-class> <description>Performs pre-login and post-login operation </description> <init-param>// optional <param-name>ParameterName </param-name> <param-value>ParameterName </param-value> </init-param> </filter>- Map the servlet filter to a URL or a servlet.
After mapping the servlet filter to a URL or a servlet, the web.xml application deployment descriptor contains servlet mapping similar to the following example:
<filter-mapping> <filter-name>LoginFilter </filter-name> <url-pattern>/j_security_check </url-pattern> // can be servlet <servlet>servletName </servlet> </filter-mapping>
Example
We can use servlet filters to replace the CustomLoginServlet servlet, and to perform additional authentication, auditing, and logging.
The WAS Samples provide a form login sample that demonstrates how to use the WAS login facilities to implement and configure form login procedures. The sample integrates the following technologies to demonstrate the WAS and Java EE login functionality:
- Java EE form-based login
- Java EE servlet filter with login
- IBM extension: form-based login
The form login sample is part of the Technology Samples package.
Samples documentation
Migrate from the CustomLoginServlet class to servlet filters
Develop servlet filters for form login processing
Secure web applications using an assembly tool