SEC-1289: Successful registration event #1515

Closed
spring-issuemaster opened this Issue Nov 9, 2009 · 3 comments

1 participant

@spring-issuemaster

Nickolay Mazurkin (Migrated from SEC-1289) said:

With 3.0M2 and before I used the following code to register successful registrations and save client's IPs

[code]
public class AuthenticationListener implements ApplicationListener {

@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof AuthenticationSuccessEvent) {
        onAuthenticationSuccessEvent((AuthenticationSuccessEvent) event);
    }
}

public void onAuthenticationSuccessEvent(AuthenticationSuccessEvent authenticationSuccessEvent) {
    // my code
}

}
[/code]

With 3.0RC1 there are no AuthenticationSuccessEvent events any more. I've found the following comment for org.springframework.security.authentication.DefaultAuthenticationEventPublisher

"The default strategy used by ProviderManager for publishing authentication events."

But when I looked in ProviderManager I've found that the default strategy is NullEventPublisher which is created by private field's initializer.

I thought that it's possible to inject DefaultAuthenticationEventPublisher with default XML security scheme but I've found no entry point to do this.

@spring-issuemaster

Nickolay Mazurkin said:

After some research I've changed code to

[code]
public class AuthenticationListener implements ApplicationListener {

@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof AbstractAuthenticationEvent) {
        handleAuthenticationSuccessEvent((AbstractAuthenticationEvent) event);
    }
}

public void handleAuthenticationSuccessEvent(AbstractAuthenticationEvent authenticationSuccessEvent) {
    // my code...
}

[/code]

Seems everything works fine right now

@spring-issuemaster

Nickolay Mazurkin said:

It've mistaken - use InteractiveAuthenticationSuccessEvent not AbstractAuthenticationEvent

[code]
public class AuthenticationListener implements ApplicationListener {

@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof InteractiveAuthenticationSuccessEvent ) {
        handleAuthenticationSuccessEvent((InteractiveAuthenticationSuccessEvent ) event);
    }
}

public void handleAuthenticationSuccessEvent(InteractiveAuthenticationSuccessEvent authenticationSuccessEvent) {
    // my code...
}

[/code]

@spring-issuemaster spring-issuemaster added this to the 3.0.0.RC2 milestone Feb 5, 2016
@spring-issuemaster

This issue duplicates #1522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment