commit
2b525c6016
3 changed files with 171 additions and 167 deletions
0
core/src/main/java/org/keycloak/Config.java
Normal file → Executable file
0
core/src/main/java/org/keycloak/Config.java
Normal file → Executable file
|
@ -143,7 +143,7 @@ public class BruteForceProtector implements Runnable {
|
|||
run = false;
|
||||
try {
|
||||
queue.offer(new ShutdownEvent());
|
||||
shutdownLatch.await(5, TimeUnit.SECONDS);
|
||||
shutdownLatch.await(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ public class BruteForceProtector implements Runnable {
|
|||
|
||||
public void run() {
|
||||
final ArrayList<LoginEvent> events = new ArrayList<LoginEvent>(TRANSACTION_SIZE + 1);
|
||||
try {
|
||||
while (run) {
|
||||
try {
|
||||
LoginEvent take = queue.poll(2, TimeUnit.SECONDS);
|
||||
|
@ -169,6 +170,8 @@ public class BruteForceProtector implements Runnable {
|
|||
for (LoginEvent event : events) {
|
||||
if (event instanceof FailedLogin) {
|
||||
failure(session, event);
|
||||
} else if (event instanceof ShutdownEvent) {
|
||||
run = false;
|
||||
}
|
||||
}
|
||||
session.getTransaction().commit();
|
||||
|
@ -189,11 +192,12 @@ public class BruteForceProtector implements Runnable {
|
|||
}
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
shutdownLatch.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void logSuccess(LoginEvent event) {
|
||||
logger.warn("login success for user " + event.username + " from ip " + event.ip);
|
||||
|
|
|
@ -133,7 +133,7 @@ public class KeycloakApplication extends Application {
|
|||
}
|
||||
|
||||
public static void setupScheduledTasks(final ProviderSessionFactory providerSessionFactory) {
|
||||
long interval = Config.scope("scheduled").getLong("interval") * 1000;
|
||||
long interval = Config.scope("scheduled").getLong("interval", 60L) * 1000;
|
||||
|
||||
TimerProvider timer = providerSessionFactory.createSession().getProvider(TimerProvider.class);
|
||||
timer.schedule(new ScheduledTaskRunner(providerSessionFactory, new ClearExpiredAuditEvents()), interval);
|
||||
|
|
Loading…
Reference in a new issue