# CustomBruteForceProtector onEvent function not being invoked

**URL:** <https://forum.keycloak.org/t/custombruteforceprotector-onevent-function-not-being-invoked/25907>\
**Category:** Miscellanaeous\
**Created:** [May 7, 2024, 6:39pm UTC](https://forum.keycloak.org/t/custombruteforceprotector-onevent-function-not-being-invoked/25907 "2024-05-07T18:39:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![swetha](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/swetha/32/10361_2.png) [@swetha](https://forum.keycloak.org/u/swetha)\
**Post date:** [May 7, 2024, 6:39pm UTC](https://forum.keycloak.org/t/custombruteforceprotector-onevent-function-not-being-invoked/25907/1 "2024-05-07T18:39:53Z")

</div>

CustomBruteForceProtector onEvent function not being invoked.

public class DefaultBruteForceProtector implements Runnable, BruteForceProtector, EventListenerProvider

@Override  
public void onEvent(Event event) {  
if (EventType.LOGIN\_ERROR.equals(event.getType())) {  
String username = event.getUserId();  
RealmModel realm = session.getContext().getRealm();  
UserModel user = session.users().getUserByUsername(realm, username);

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [May 7, 2024, 7:03pm UTC](https://forum.keycloak.org/t/custombruteforceprotector-onevent-function-not-being-invoked/25907/2 "2024-05-07T19:03:45Z")

</div>

This is pretty sparse. If you want us to review your code, link to the whole extension, and explain how you are setting it up and running it. Otherwise, this reads as “me Grog! code not work!”.
