Skip to main content

Acegi onSuccessfulAuthentication

Some time back, I raised a jira in Acegi, which was turned down. There was no adequate response from spring team. Here I am writing about it, so other spring users (read gurus) may pitch in.
//Edited to short and precise
protected void successfulAuthentication(HttpServletRequest request,
    HttpServletResponse response, Authentication authResult)
    throws IOException {


    String targetUrl = (String) request.getSession()

    if (alwaysUseDefaultTargetUrl == true) {
        targetUrl = null;

    if (targetUrl == null) {
        targetUrl = request.getContextPath() + defaultTargetUrl;

    // user call back hook
    onSuccessfulAuthentication(request, response, authResult);
The Acegi framework's AbstractProcessingFilter provides a callback method onSuccessfulAuthentication for calling user logic after a successful login - generally used for building user login context specific to application. The landing page is *pre-determined* before this call so NO matter what happens in this method, it is redirected to land on the said page. So,  if there is a data or application error while doing it, it is still going to the same page redirected to. The only way to control the flow is by throwing an exception and handling it either by Acegi Exception Handlers or catching that exception in web.xml

My Request was to be able to use a different flow, and send to a different page. In my case, If there was a user that was in our Transaction DB but not in legacy DB, We just come out throw the user an error splash screen. It dint matter much to me. However If you had a business scenario - go to a different controller, build a session different way and send to a different page - How do you do? Have you had this situation? How would you resolve it?

Popular posts from this blog

Add jquery in Chrome console

Many a time, a page you are debugging doesnot have jquery. This simple js will add(or prompt you to overwrite) jquery to any page from chrome console.


Javascript: Convert Strings to Binary (and representing in a nerdy way!)

I follow those GoogleDevelopers Videos. Sometime back, in one of the presentations on GoogleIO, there was this interesting string of dots at the bottom of each page of the presentation. They looked like random big and small dots. A similar bunch of dots were also on the T-shirt of a presenter was wearing in another presentation. While it seemed something in the pattern, I could not find what it was. Finally, another presenter cleared the matter that those dots are just binary representation of "GOOGLEIO" (So much for advertizing Google IO, Impressive!).

So I wanna do it. Takes me back to days of those DSP classes at school. Nerdy me had to churn some old brain cells. I remember those first programming language classes in Pascal and C when you were asked to do fibonacci series and converting a binary string to ascii codes. That *experience* came handy here: Check it out!

Text to Binarize:
For those who came to copy the javascript code to convert string to binary, Here it is…

The easiest way to install docker on Ubuntu

Docker releases come out faster than ubuntu updating thier repositories. Docker mainitains a ppa. One can add the ppa key, and then add to sources.list.d and then update sources and then install lxc-docker. OR..
curl -sSL | sudo sh