juliocamarero/liferay-portal — pull request #748 by matethurzo (2012-11-15 17:59:10+00:00)
Title: LPS-30678 AutoLogin exception handling changes

Hey Julio,

This fix initially was about the SiteMinderAutoLogin. Later it became more of a how to handle the exceptions and logging in the auto logins.

There was a discussion about this between Sergio and me, about the concept, and here is the result.

I've changed the return credential; calls in the auto logins to return null; statements where the purpose of returning with an empty credential array so the processing can continue upon an unsuccessful login.

The other more complex thing I've changed is the exception handling. I've noticed that some of the auto logins are throwing exceptions and some not. I've checked how the AutoLoginFilter calls the auto logins and I realized that if we set the AUTO_LOGIN_REDIRECT attribute we should always return with a null, so the filter will be able to process that, and redirect the request even if we don't have an authenticated user. The CASAutoLogin works this way. The other case is when we don't set the AUTO_LOGIN_REDIRECT attribute, we can safely throw an exception which will be processed and logged, then we will move on to the next auto login. Some aut logins worked the way to throw a new exception and some of them returns a null value.

As we discussed with Sergio there is now a handleException method which will look for this attribute in the request and if present it will return with null making sure that the request will be redirected. If the attribute is not set, we are safe to throw an exception.

There is an option also for a custom exception handling method in each auto login, the base logic is coded in the BaseAutoLogin.

By introducing this we could get rid of some unnecessary try catch blocks (there are some which are still needed, depends on the aut login logic), and we avoid some duplicate error handling (possible duplicate logging) what happens in the current code.

Besides that, I've applied minor source formatting changes like in the FacebookAutoLogin.

Thanks,

Máté