org.keycloak.services.managers

## Class BruteForceProtector

- java.lang.Object
- - org.keycloak.services.managers.BruteForceProtector

- All Implemented Interfaces:
    Runnable

      public class BruteForceProtector
      extends Object
      implements Runnable

  A single thread will log failures. This is so that we can avoid concurrent writes as we want an accurate failure count
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `BruteForceProtector.FailedLogin`
    `protected class` | `BruteForceProtector.LoginEvent`
    `protected class` | `BruteForceProtector.ShutdownEvent`
    `protected class` | `BruteForceProtector.SuccessfulLogin`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected KeycloakSessionFactory` | `factory`
    `protected long` | `failures`
    `protected long` | `lastFailure`
    `protected static org.jboss.logging.Logger` | `logger`
    `protected int` | `maxDeltaTimeSeconds`
    `protected LinkedBlockingQueue<BruteForceProtector.LoginEvent>` | `queue`
    `protected boolean` | `run`
    `protected CountDownLatch` | `shutdownLatch`
    `protected long` | `totalTime`
    `static int` | `TRANSACTION_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BruteForceProtector(KeycloakSessionFactory factory)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `failedLogin(RealmModel realm, String username, ClientConnection clientConnection)`
    `void` | `failure(KeycloakSession session, BruteForceProtector.LoginEvent event)`
    `long` | `getFailures()`
    `long` | `getLastFailure()`
    `protected RealmModel` | `getRealmModel(KeycloakSession session, BruteForceProtector.LoginEvent event)`
    `protected UsernameLoginFailureModel` | `getUserModel(KeycloakSession session, BruteForceProtector.LoginEvent event)`
    `void` | `invalidUser(RealmModel realm, String username, ClientConnection clientConnection)`
    `boolean` | `isTemporarilyDisabled(KeycloakSession session, RealmModel realm, String username)`
    `protected void` | `logFailure(BruteForceProtector.LoginEvent event)`
    `protected void` | `logSuccess(BruteForceProtector.LoginEvent event)`
    `void` | `run()`
    `void` | `shutdown()`
    `void` | `start()`
    `void` | `successfulLogin(RealmModel realm, String username, ClientConnection clientConnection)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected static org.jboss.logging.Logger logger

    - #### run

          protected volatile boolean run

    - #### maxDeltaTimeSeconds

          protected int maxDeltaTimeSeconds

    - #### factory

          protected KeycloakSessionFactory factory

    - #### shutdownLatch

          protected CountDownLatch shutdownLatch

    - #### failures

          protected volatile long failures

    - #### lastFailure

          protected volatile long lastFailure

    - #### totalTime

          protected volatile long totalTime

    - #### queue

          protected LinkedBlockingQueue<BruteForceProtector.LoginEvent> queue

    - #### TRANSACTION_SIZE

          public static final int TRANSACTION_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BruteForceProtector

          public BruteForceProtector(KeycloakSessionFactory factory)

  - ### Method Detail

    - #### failure

          public void failure(KeycloakSession session,
                     BruteForceProtector.LoginEvent event)

    - #### getUserModel

          protected UsernameLoginFailureModel getUserModel(KeycloakSession session,
                                               BruteForceProtector.LoginEvent event)

    - #### getRealmModel

          protected RealmModel getRealmModel(KeycloakSession session,
                                 BruteForceProtector.LoginEvent event)

    - #### start

          public void start()

    - #### shutdown

          public void shutdown()

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`

    - #### logSuccess

          protected void logSuccess(BruteForceProtector.LoginEvent event)

    - #### logFailure

          protected void logFailure(BruteForceProtector.LoginEvent event)

    - #### successfulLogin

          public void successfulLogin(RealmModel realm,
                             String username,
                             ClientConnection clientConnection)

    - #### invalidUser

          public void invalidUser(RealmModel realm,
                         String username,
                         ClientConnection clientConnection)

    - #### failedLogin

          public void failedLogin(RealmModel realm,
                         String username,
                         ClientConnection clientConnection)

    - #### isTemporarilyDisabled

          public boolean isTemporarilyDisabled(KeycloakSession session,
                                      RealmModel realm,
                                      String username)

    - #### getFailures

          public long getFailures()

    - #### getLastFailure

          public long getLastFailure()

Copyright © 2015. All Rights Reserved.