code: public void onApplicationEvent(ApplicationEvent event) {
  
          // All events we care about are subtypes of ClientSecurityEvent
          if( event instanceof ClientSecurityEvent ) {
              Authentication authentication = (Authentication) event.getSource();
  
              if( logger.isDebugEnabled() ) {
                  logger.debug( "RECEIVED ClientSecurityEvent: " + event );
                  logger.debug( "Authentication token: " + authentication );
              }
  
              // Note that we need to inspect the new authentication token and see if it is
              // NO_AUTHENTICATION. If so, then we need to use null instead. This little
              // dance is required because the source of an event can't actually be null.
  
              if( authentication == ClientSecurityEvent.NO_AUTHENTICATION ) {
                  if( logger.isDebugEnabled() ) {
                      logger.debug( "Converted NO_AUTHENTICATION to null" );
                  }
                  authentication = null;
              }
  
              // And dispatch according to the event type.
  
              if( event instanceof AuthenticationEvent ) {
                  broadcastAuthentication( authentication );
              } else if( event instanceof LoginEvent ) {
                  broadcastLogin( authentication );
              } else if( event instanceof LogoutEvent ) {
                  broadcastLogout( authentication );
              } else {
                  if( logger.isDebugEnabled() ) {
                      logger.debug( "Unsupported event not processed" );
                  }
              }
          }
      }
docs: /*
  (non-Javadoc)
  @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)