03.05.2015 Views

IBM WebSphere V5.0 Security - CGISecurity

IBM WebSphere V5.0 Security - CGISecurity

IBM WebSphere V5.0 Security - CGISecurity

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Each object that will be used as a filter should implement the Filter interface. This<br />

interface defines three methods:<br />

► public void init(FilterConfig filterConfig)<br />

A method called by Web container to initialize the FilterConfig object for the<br />

filter and to ensure that the filter is being instantiated.<br />

►<br />

►<br />

public void doFilter(final ServletRequest request, final<br />

ServletResponse response, FilterChain chain)<br />

A method called every time the request/response pair is passed through the<br />

filters.<br />

public void destroy()<br />

A method called by the container to clear the instance of the filter. This<br />

method can be used to clean up all the resources that were kept for filter<br />

processing tasks.<br />

When planning a scenario for filters, you need to take into account the way filters<br />

work.<br />

Actions performed by servlet filters maybe executed before and/or after the<br />

actual servlet, or JavaServer Page. When thinking about the login process, a<br />

servlet filter may perform some pre-login functions before sending the request to<br />

the authentication servlet. On the other hand, it may take the result of the<br />

authentication servlet and perform additional checking, for example in external<br />

databases in order to send customized response to the client’s browser.<br />

As mentioned in 4.5.1, “Form-based login” on page 59, <strong>WebSphere</strong> Application<br />

Server uses the special j_security_check servlet to perform authentication when<br />

form-based authentication is selected for the Web application.<br />

This section will present a sample filter that is assigned to the j_security_check<br />

servlet to perform additional LDAP lookup and to retrieve attributes for the user<br />

who logged in.<br />

This scenario assumes the following:<br />

1. <strong>WebSphere</strong> Application Server is configured with security enabled. The type<br />

of user registry used for that scenario does not make any difference to this<br />

implementation; any user registry can be used with the sample, but when a<br />

user registry other than LDAP is used, make sure that each user from the<br />

user registry of your choice exists in the LDAP directory for the additional<br />

lookup.<br />

2. The servlet filter will communicate with the LDAP server in order to get certain<br />

user attributes. The user description in LDAP server contains the employee<br />

type attribute that will be checked by servlet filter. The value of the<br />

Chapter 4. Securing Web components 63

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!