Jun 8th, 2010, 11:52 PM
How to perform pre login tasks
I am pretty new to spring.
I have requirement of performing db existence check before redirecting the user to the login page.
use case :
1. User enters loginpage url.
2. Check if db is present.
3. if yes redirect user to login page(A).
4. if no redirect user to required page(B).
Present implementation: This check was achieved by making an ajax call in page A's Post method, to a service which is exposed by security for non authenticated users.On success redirect the user to page A else to page B.
Problem is i feel this is not the correct way to implement Pre-Login events.
I tried using pre authentication filter but am not able to achieve this case since pre-auth filter directly gives login page first and does the processing next.
I do not want the user to see the login page before the pre-conditions are met.
am i implementing this in the correct way, are there any other options on which i can relay on.
Jun 9th, 2010, 07:40 AM
How about implementing a custom filter which fires before the spring security filters?
Jun 9th, 2010, 08:30 AM
Yes, it sounds like you don't even need Spring Security for this. Just plunk a servlet filter before any security stuff in the web app configuration.
Peter Mularien | Blog
Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
SCJP 5, Oracle DBA
Any postings are my own opinion, and should not be attributed to my employer or clients.