Holy cow, gmail has a shortcut key for to send with. Apparently I hit
it on accident...

OK let's try again, sorry lol

In the past Ben has said that he doesn't like the way the
AbstractProcessingFilter handles exceptions. Right now, for every new
exception we want to handle in the abstractProcessingFilter it
requires a new setSomethingUrl and a new block in the
"unsuccessfulAuthentication()" method's if statement.

I'd like to propose something a little different...
A private Properties field called exceptionMappings. With a getter/setter...

private Properties exceptionMappings = new Properties();

public Properties getExceptionMappings() {
    return exceptionMappings;
}

public void setExceptionMappings(Properties exceptionMappings) {
    this.exceptionMappings = exceptionMappings;
}

Now the mapping for the AuthenticationProcessingFilter changes a bit.
With a setter for the exceptionMappings...

For example...
<property name="exceptionMappings">
    <props>
        <prop 
key="net.sf.acegisecurity.BadCredentialsException">/badCredentials.jsp</prop>
    </props>
</property>


Now, the big bulky if statement in unsuccessfulAuthentication() can be
replaced with one line...

Failed being the AuthenticationException from the method signature,
and the 'authenticationFailureUrl' is the default location.

String failureUrl = exceptionMappings.getProperty(failed.getClass().getName(),
        authenticationFailureUrl);

The redirect happens just like it did before...

response.sendRedirect(response.encodeRedirectURL(request.getContextPath()
        + failureUrl));

This gives the AbstractProcessingFilter the ability to handle custom
exceptions created by users as well.

I'd be happy to continue this work if everyone thinks it's worthwhile.

-Ray Krueger


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Home: http://acegisecurity.sourceforge.net
Acegisecurity-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer

Reply via email to