From 25d6161ebda4c7344fb56f3e5a373fbf4ac46674 Mon Sep 17 00:00:00 2001 From: vramik Date: Thu, 9 Mar 2023 22:14:31 +0100 Subject: [PATCH] Remove `ClearExpiredUserSessions`, `ClearExpiredClientInitialAccessTokens` and `ClearExpiredEvents` from services module Closes #13835 --- ...ClearExpiredClientInitialAccessTokens.java | 32 ------------- .../scheduled/ClearExpiredEvents.java | 46 ------------------- .../scheduled/ClearExpiredUserSessions.java | 45 ------------------ 3 files changed, 123 deletions(-) delete mode 100644 services/src/main/java/org/keycloak/services/scheduled/ClearExpiredClientInitialAccessTokens.java delete mode 100755 services/src/main/java/org/keycloak/services/scheduled/ClearExpiredEvents.java delete mode 100755 services/src/main/java/org/keycloak/services/scheduled/ClearExpiredUserSessions.java diff --git a/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredClientInitialAccessTokens.java b/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredClientInitialAccessTokens.java deleted file mode 100644 index 94a4f6b391..0000000000 --- a/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredClientInitialAccessTokens.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2017 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.services.scheduled; - -import org.keycloak.models.KeycloakSession; -import org.keycloak.timer.ScheduledTask; - -/** - * @author Marek Posolda - */ -public class ClearExpiredClientInitialAccessTokens implements ScheduledTask { - - @Override - public void run(KeycloakSession session) { - session.realms().removeExpiredClientInitialAccess(); - } -} diff --git a/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredEvents.java b/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredEvents.java deleted file mode 100755 index 16d70c089d..0000000000 --- a/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredEvents.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2016 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.services.scheduled; - -import org.jboss.logging.Logger; -import org.keycloak.common.util.Time; -import org.keycloak.events.EventStoreProvider; -import org.keycloak.models.KeycloakSession; -import org.keycloak.timer.ScheduledTask; - -/** - * @author Stian Thorgersen - */ -public class ClearExpiredEvents implements ScheduledTask { - - protected static final Logger logger = Logger.getLogger(ClearExpiredEvents.class); - - @Override - public void run(KeycloakSession session) { - long currentTimeMillis = Time.currentTimeMillis(); - - EventStoreProvider eventStore = session.getProvider(EventStoreProvider.class); - if (eventStore != null) { - eventStore.clearExpiredEvents(); - } - - long took = Time.currentTimeMillis() - currentTimeMillis; - logger.debugf("ClearExpiredEvents finished in %d ms", took); - } - -} diff --git a/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredUserSessions.java b/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredUserSessions.java deleted file mode 100755 index 904dc1f6e3..0000000000 --- a/services/src/main/java/org/keycloak/services/scheduled/ClearExpiredUserSessions.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2016 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.services.scheduled; - -import org.jboss.logging.Logger; -import org.keycloak.common.util.Time; -import org.keycloak.models.KeycloakSession; -import org.keycloak.timer.ScheduledTask; - -/** - * @author Stian Thorgersen - */ -public class ClearExpiredUserSessions implements ScheduledTask { - - protected static final Logger logger = Logger.getLogger(ClearExpiredUserSessions.class); - - public static final String TASK_NAME = "ClearExpiredUserSessions"; - - @Override - public void run(KeycloakSession session) { - long currentTimeMillis = Time.currentTimeMillis(); - - session.authenticationSessions().removeAllExpired(); - session.sessions().removeAllExpired(); - - long took = Time.currentTimeMillis() - currentTimeMillis; - logger.debugf("ClearExpiredUserSessions finished in %d ms", took); - } - -}