forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KEYCLOAK-19709 Remove MapStorage.createCriteriaBuilder
- Loading branch information
1 parent
58e8110
commit 9c287af
Showing
21 changed files
with
221 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
|
||
import static org.keycloak.common.util.StackUtil.getShortStackTrace; | ||
import static org.keycloak.models.map.storage.QueryParameters.withCriteria; | ||
import static org.keycloak.models.map.storage.criteria.DefaultModelCriteria.criteria; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Martin Kanis</a> | ||
|
@@ -49,13 +50,11 @@ public class MapRootAuthenticationSessionProvider implements AuthenticationSessi | |
private static final Logger LOG = Logger.getLogger(MapRootAuthenticationSessionProvider.class); | ||
private final KeycloakSession session; | ||
protected final MapKeycloakTransaction<MapRootAuthenticationSessionEntity, RootAuthenticationSessionModel> tx; | ||
private final MapStorage<MapRootAuthenticationSessionEntity, RootAuthenticationSessionModel> sessionStore; | ||
|
||
private static final String AUTHENTICATION_SESSION_EVENTS = "AUTHENTICATION_SESSION_EVENTS"; | ||
|
||
public MapRootAuthenticationSessionProvider(KeycloakSession session, MapStorage<MapRootAuthenticationSessionEntity, RootAuthenticationSessionModel> sessionStore) { | ||
this.session = session; | ||
this.sessionStore = sessionStore; | ||
this.tx = sessionStore.createTransaction(session); | ||
|
||
session.getTransactionManager().enlistAfterCompletion(tx); | ||
|
@@ -132,8 +131,8 @@ public void removeExpired(RealmModel realm) { | |
|
||
int expired = Time.currentTime() - RealmInfoUtil.getDettachedClientSessionLifespan(realm); | ||
|
||
ModelCriteriaBuilder<RootAuthenticationSessionModel> mcb = sessionStore.createCriteriaBuilder() | ||
.compare(SearchableFields.REALM_ID, Operator.EQ, realm.getId()) | ||
ModelCriteriaBuilder<RootAuthenticationSessionModel> mcb = criteria(); | ||
mcb = mcb.compare(SearchableFields.REALM_ID, Operator.EQ, realm.getId()) | ||
.compare(SearchableFields.TIMESTAMP, Operator.LT, expired); | ||
|
||
long deletedCount = tx.delete(withCriteria(mcb)); | ||
|
@@ -144,8 +143,8 @@ public void removeExpired(RealmModel realm) { | |
@Override | ||
public void onRealmRemoved(RealmModel realm) { | ||
Objects.requireNonNull(realm, "The provided realm can't be null!"); | ||
ModelCriteriaBuilder<RootAuthenticationSessionModel> mcb = sessionStore.createCriteriaBuilder() | ||
.compare(SearchableFields.REALM_ID, Operator.EQ, realm.getId()); | ||
ModelCriteriaBuilder<RootAuthenticationSessionModel> mcb = criteria(); | ||
mcb = mcb.compare(SearchableFields.REALM_ID, Operator.EQ, realm.getId()); | ||
|
||
tx.delete(withCriteria(mcb)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.