Results 1 to 2 of 2

Thread: Incorrect login counter.

  1. #1

    Default Incorrect login counter.

    Hi, could anyone help me how to execute SQL query on incorrect login action? Or even better on succesfull login action to store IP address and date/time of last action.

    In my app I am using:
    securityEnforcementFilter
    -- authenticationManager
    -- -- daoAuthenticationProvider
    -- -- -- jdbcAuthenticationDao
    -- -- anonymousAuthenticationProvider
    Any help will be very appreciated.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2005
    Posts
    13

    Default

    Acegi publishs a number of events. You can tap into them as you would any Spring event.

    Simply create a class that implements ApplicationListener, as follows;

    Code:
    package app.events;
    
    import net.sf.acegisecurity.providers.dao.event.AuthenticationSuccessEvent;
    import org.springframework.context.ApplicationListener;
    import org.springframework.context.ApplicationEvent;
    
    public class SuccessfulLoginEvent implements ApplicationListener {
    
        private MonitorDao monitorDao;
    
        public MonitorDao getMonitorDao() {
            return monitorDao;
        }
    
        public void setMonitorDao(MonitorDao monitorDao) {
            this.monitorDao = monitorDao;
        }
    
        public void onApplicationEvent(ApplicationEvent event) {
               if (event instanceof AuthenticationSuccessEvent) {
                   AuthenticationSuccessEvent successEvent = (AuthenticationSuccessEvent) event;
                   monitorDao.write(successEvent.getUser());
            }
        }
    }
    In the above example I use a DAO to record the event. You would implement your DAO as a SQL.

    After that, the only other thing you need to do is register the listener in your application context.

    Code:
        <bean id="successflLoginEvent" class="app.events.SuccessfulLoginEvent">
            <property name="monitorDao">
                <ref bean="monitorDao"/>
            </property>
        </bean>
    Spring looks for anything that implements ApplicationListener when it loads up the context. It will then fire it whenever is "hears" an event

Similar Threads

  1. ERROR: Context initialization failed
    By makhlo in forum Architecture
    Replies: 8
    Last Post: Jul 11th, 2008, 01:41 AM
  2. acegi + CAS going in loop after login
    By mcecca in forum Security
    Replies: 3
    Last Post: Sep 30th, 2005, 02:56 PM
  3. Replies: 3
    Last Post: Apr 5th, 2005, 02:31 AM
  4. Acegi - Login Tapestry
    By john017 in forum Security
    Replies: 1
    Last Post: Feb 4th, 2005, 01:11 AM
  5. HessianProtocolException with incorrect login
    By general_pattonm in forum Security
    Replies: 10
    Last Post: Jan 12th, 2005, 01:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •