diff --git a/dependencies/server-all/pom.xml b/dependencies/server-all/pom.xml index 8155428589..b8d082413d 100755 --- a/dependencies/server-all/pom.xml +++ b/dependencies/server-all/pom.xml @@ -40,10 +40,6 @@ org.keycloak keycloak-model-file - - org.keycloak - keycloak-model-sessions-mem - org.keycloak keycloak-model-sessions-jpa @@ -181,4 +177,4 @@ - \ No newline at end of file + diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json b/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json index 9b8f05171d..ee56f78dc8 100644 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json @@ -23,18 +23,15 @@ }, "userSessions": { - "provider" : "mem" + "provider" : "infinispan" }, "realmCache": { - "provider": "mem" + "provider": "infinispan" }, "userCache": { - "provider": "mem", - "mem": { - "maxSize": 20000 - } + "provider": "infinispan" }, "timer": { @@ -78,5 +75,11 @@ "dataSource": "java:jboss/datasources/KeycloakDS", "databaseSchema": "update" } + }, + + "connectionsInfinispan": { + "default" : { + "cacheContainer" : "java:jboss/infinispan/Keycloak" + } } } \ No newline at end of file diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-mem/main/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-mem/main/module.xml deleted file mode 100644 index 47c9d408be..0000000000 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-mem/main/module.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/server-war/META-INF/keycloak-server.json b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/server-war/META-INF/keycloak-server.json deleted file mode 100755 index 9b8f05171d..0000000000 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/server-war/META-INF/keycloak-server.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "providers": [ - "classpath:${jboss.server.config.dir}/providers/*" - ], - - "admin": { - "realm": "master" - }, - - "eventsStore": { - "provider": "jpa", - "jpa": { - "exclude-events": [ "REFRESH_TOKEN" ] - } - }, - - "realm": { - "provider": "jpa" - }, - - "user": { - "provider": "jpa" - }, - - "userSessions": { - "provider" : "mem" - }, - - "realmCache": { - "provider": "mem" - }, - - "userCache": { - "provider": "mem", - "mem": { - "maxSize": 20000 - } - }, - - "timer": { - "provider": "basic" - }, - - "theme": { - "default": "keycloak", - "staticMaxAge": 2592000, - "cacheTemplates": true, - "cacheThemes": true, - "folder": { - "dir": "${jboss.server.config.dir}/themes" - } - }, - - "login": { - "provider": "freemarker" - }, - - "account": { - "provider": "freemarker" - }, - - "email": { - "provider": "freemarker" - }, - - "scheduled": { - "interval": 900 - }, - - "connectionsHttpClient": { - "default": { - "disable-trust-manager": true - } - }, - - "connectionsJpa": { - "default": { - "dataSource": "java:jboss/datasources/KeycloakDS", - "databaseSchema": "update" - } - } -} \ No newline at end of file diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml index f67884e3b7..92057483bc 100755 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml @@ -37,7 +37,6 @@ - diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-services/main/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-services/main/module.xml index 5b55602247..b062204302 100644 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-services/main/module.xml +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-services/main/module.xml @@ -47,7 +47,6 @@ - diff --git a/distribution/server-overlay/eap6/eap6-server-modules/build.xml b/distribution/server-overlay/eap6/eap6-server-modules/build.xml index a46a26af50..1f30da0092 100755 --- a/distribution/server-overlay/eap6/eap6-server-modules/build.xml +++ b/distribution/server-overlay/eap6/eap6-server-modules/build.xml @@ -189,10 +189,6 @@ - - - - diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/META-INF/keycloak-server.json b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/META-INF/keycloak-server.json deleted file mode 100755 index 9b8f05171d..0000000000 --- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/META-INF/keycloak-server.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "providers": [ - "classpath:${jboss.server.config.dir}/providers/*" - ], - - "admin": { - "realm": "master" - }, - - "eventsStore": { - "provider": "jpa", - "jpa": { - "exclude-events": [ "REFRESH_TOKEN" ] - } - }, - - "realm": { - "provider": "jpa" - }, - - "user": { - "provider": "jpa" - }, - - "userSessions": { - "provider" : "mem" - }, - - "realmCache": { - "provider": "mem" - }, - - "userCache": { - "provider": "mem", - "mem": { - "maxSize": 20000 - } - }, - - "timer": { - "provider": "basic" - }, - - "theme": { - "default": "keycloak", - "staticMaxAge": 2592000, - "cacheTemplates": true, - "cacheThemes": true, - "folder": { - "dir": "${jboss.server.config.dir}/themes" - } - }, - - "login": { - "provider": "freemarker" - }, - - "account": { - "provider": "freemarker" - }, - - "email": { - "provider": "freemarker" - }, - - "scheduled": { - "interval": 900 - }, - - "connectionsHttpClient": { - "default": { - "disable-trust-manager": true - } - }, - - "connectionsJpa": { - "default": { - "dataSource": "java:jboss/datasources/KeycloakDS", - "databaseSchema": "update" - } - } -} \ No newline at end of file diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml index f67884e3b7..92057483bc 100755 --- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml +++ b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml @@ -37,7 +37,6 @@ - diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-mem/main/module.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-mem/main/module.xml deleted file mode 100755 index 20ab6d0c95..0000000000 --- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-mem/main/module.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-services/main/module.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-services/main/module.xml index 268a788a5a..337a5a1530 100755 --- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-services/main/module.xml +++ b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-services/main/module.xml @@ -47,7 +47,6 @@ - diff --git a/distribution/server-overlay/eap6/eap6-server-overlay/assembly.xml b/distribution/server-overlay/eap6/eap6-server-overlay/assembly.xml index e95f6aa88a..9a9e49069f 100755 --- a/distribution/server-overlay/eap6/eap6-server-overlay/assembly.xml +++ b/distribution/server-overlay/eap6/eap6-server-overlay/assembly.xml @@ -34,7 +34,7 @@ standalone-keycloak-ha.xml - src/main/keycloak-server.json + ../../../feature-packs/server-feature-pack/src/main/resources/content/standalone/configuration/keycloak-server.json standalone/configuration diff --git a/distribution/server-overlay/eap6/eap6-server-overlay/src/main/keycloak-server.json b/distribution/server-overlay/eap6/eap6-server-overlay/src/main/keycloak-server.json deleted file mode 100644 index 9b8f05171d..0000000000 --- a/distribution/server-overlay/eap6/eap6-server-overlay/src/main/keycloak-server.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "providers": [ - "classpath:${jboss.server.config.dir}/providers/*" - ], - - "admin": { - "realm": "master" - }, - - "eventsStore": { - "provider": "jpa", - "jpa": { - "exclude-events": [ "REFRESH_TOKEN" ] - } - }, - - "realm": { - "provider": "jpa" - }, - - "user": { - "provider": "jpa" - }, - - "userSessions": { - "provider" : "mem" - }, - - "realmCache": { - "provider": "mem" - }, - - "userCache": { - "provider": "mem", - "mem": { - "maxSize": 20000 - } - }, - - "timer": { - "provider": "basic" - }, - - "theme": { - "default": "keycloak", - "staticMaxAge": 2592000, - "cacheTemplates": true, - "cacheThemes": true, - "folder": { - "dir": "${jboss.server.config.dir}/themes" - } - }, - - "login": { - "provider": "freemarker" - }, - - "account": { - "provider": "freemarker" - }, - - "email": { - "provider": "freemarker" - }, - - "scheduled": { - "interval": 900 - }, - - "connectionsHttpClient": { - "default": { - "disable-trust-manager": true - } - }, - - "connectionsJpa": { - "default": { - "dataSource": "java:jboss/datasources/KeycloakDS", - "databaseSchema": "update" - } - } -} \ No newline at end of file diff --git a/distribution/server-overlay/eap6/eap6-server-overlay/src/main/xslt/standalone.xsl b/distribution/server-overlay/eap6/eap6-server-overlay/src/main/xslt/standalone.xsl index 519b4a71b6..3d4b77cedb 100755 --- a/distribution/server-overlay/eap6/eap6-server-overlay/src/main/xslt/standalone.xsl +++ b/distribution/server-overlay/eap6/eap6-server-overlay/src/main/xslt/standalone.xsl @@ -9,6 +9,7 @@ + @@ -44,6 +45,18 @@ + + + + + + + + + + + + diff --git a/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml b/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml index 256f100fbb..8b4d6e53b0 100755 --- a/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml +++ b/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml @@ -79,6 +79,21 @@
Version specific migration +
+ Migrating to 1.5.0.Final + + Infinispan set to default cache and user session providers + + Infinispan is now the default cache and user session provider. + + + + Mem user session provider + + The mem user session provider has been removed. Instead the Infinispan user session provider with a local cache should be used. + + +
Migrating to 1.3.0.Final diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml b/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml index 30706ac978..1d92afc6d5 100644 --- a/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml +++ b/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml @@ -7,6 +7,12 @@ + + + + + + diff --git a/model/jpa/pom.xml b/model/jpa/pom.xml index bb4512a8ff..8c21ceeafa 100755 --- a/model/jpa/pom.xml +++ b/model/jpa/pom.xml @@ -52,12 +52,6 @@ hibernate-entitymanager provided - - org.keycloak - keycloak-model-sessions-mem - test - - org.jboss.resteasy resteasy-jaxrs diff --git a/model/pom.xml b/model/pom.xml index 6601bc608a..6b70f5ace1 100755 --- a/model/pom.xml +++ b/model/pom.xml @@ -31,7 +31,6 @@ mongo file sessions-jpa - sessions-mem sessions-mongo sessions-infinispan diff --git a/model/sessions-mem/pom.xml b/model/sessions-mem/pom.xml deleted file mode 100755 index 6d011b86ed..0000000000 --- a/model/sessions-mem/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - keycloak-parent - org.keycloak - 1.5.0.Final-SNAPSHOT - ../../pom.xml - - 4.0.0 - - keycloak-model-sessions-mem - Keycloak Model Sessions Mem - - - - - org.keycloak - keycloak-core - provided - - - org.keycloak - keycloak-model-api - provided - - - - diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/ClientSessionAdapter.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/ClientSessionAdapter.java deleted file mode 100755 index 27c744e84c..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/ClientSessionAdapter.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.keycloak.models.sessions.mem; - -import org.keycloak.models.ClientModel; -import org.keycloak.models.ClientSessionModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.RealmModel; -import org.keycloak.models.UserModel; -import org.keycloak.models.UserSessionModel; -import org.keycloak.models.sessions.mem.entities.ClientSessionEntity; -import org.keycloak.models.sessions.mem.entities.UserSessionEntity; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author Stian Thorgersen - */ -public class ClientSessionAdapter implements ClientSessionModel { - - private KeycloakSession session; - private MemUserSessionProvider provider; - private RealmModel realm; - private ClientSessionEntity entity; - - public ClientSessionAdapter(KeycloakSession session, MemUserSessionProvider provider, RealmModel realm, ClientSessionEntity entity) { - this.session = session; - this.provider = provider; - this.realm = realm; - this.entity = entity; - } - - @Override - public String getId() { - return entity.getId(); - } - - @Override - public RealmModel getRealm() { - return session.realms().getRealm(entity.getRealmId()); - } - - public ClientSessionEntity getEntity() { - return entity; - } - - @Override - public ClientModel getClient() { - return realm.getClientById(entity.getClientId()); - } - - @Override - public UserSessionModel getUserSession() { - if (entity.getSession() == null) return null; - return new UserSessionAdapter(session, provider, realm, entity.getSession()); - } - - @Override - public void setUserSession(UserSessionModel userSession) { - if (userSession == null) { - if (entity.getSession() != null) { - entity.getSession().getClientSessions().remove(entity); - } - entity.setSession(null); - } else { - UserSessionAdapter adapter = (UserSessionAdapter) userSession; - UserSessionEntity userSessionEntity = adapter.getEntity(); - entity.setSession(userSessionEntity); - userSessionEntity.getClientSessions().add(entity); - } - } - - @Override - public void setRedirectUri(String uri) { - entity.setRedirectUri(uri); - } - - @Override - public void setRoles(Set roles) { - entity.setRoles(roles); - } - - @Override - public String getRedirectUri() { - return entity.getRedirectUri(); - } - - @Override - public int getTimestamp() { - return entity.getTimestamp(); - } - - @Override - public void setTimestamp(int timestamp) { - entity.setTimestamp(timestamp); - } - - @Override - public String getAction() { - return entity.getAction(); - } - - @Override - public void setAction(String action) { - entity.setAction(action); - } - - @Override - public Set getRoles() { - return entity.getRoles(); - } - - @Override - public Set getProtocolMappers() { - return entity.getProtocolMappers(); - } - - @Override - public void setProtocolMappers(Set protocolMappers) { - entity.setProtocolMappers(protocolMappers); - } - - @Override - public String getNote(String name) { - return entity.getNotes().get(name); - } - - @Override - public void setNote(String name, String value) { - entity.getNotes().put(name, value); - - } - - @Override - public void removeNote(String name) { - entity.getNotes().remove(name); - - } - - @Override - public Map getNotes() { - if (entity.getNotes() == null || entity.getNotes().isEmpty()) return Collections.emptyMap(); - Map copy = new HashMap<>(); - copy.putAll(entity.getNotes()); - return copy; - } - - @Override - public void setUserSessionNote(String name, String value) { - entity.getUserSessionNotes().put(name, value); - } - - @Override - public Map getUserSessionNotes() { - return entity.getUserSessionNotes(); - } - - @Override - public String getAuthMethod() { - return entity.getAuthMethod(); - } - - @Override - public void setAuthMethod(String method) { - entity.setAuthMethod(method); - } - - @Override - public Map getExecutionStatus() { - return entity.getAuthenticatorStatus(); - } - - @Override - public void setExecutionStatus(String authenticator, ExecutionStatus status) { - entity.getAuthenticatorStatus().put(authenticator, status); - - } - - @Override - public void clearExecutionStatus() { - entity.getAuthenticatorStatus().clear(); - } - - @Override - public void clearUserSessionNotes() { - entity.getUserSessionNotes().clear(); - } - - @Override - public UserModel getAuthenticatedUser() { - return entity.getAuthUserId() == null ? null : session.users().getUserById(entity.getAuthUserId(), realm); } - - @Override - public void setAuthenticatedUser(UserModel user) { - if (user == null) entity.setAuthUserId(null); - else entity.setAuthUserId(user.getId()); - - } -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/MemUserSessionProvider.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/MemUserSessionProvider.java deleted file mode 100755 index c32c4dba7b..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/MemUserSessionProvider.java +++ /dev/null @@ -1,382 +0,0 @@ -package org.keycloak.models.sessions.mem; - -import org.keycloak.models.ClientModel; -import org.keycloak.models.ClientSessionModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.ModelDuplicateException; -import org.keycloak.models.RealmModel; -import org.keycloak.models.UserModel; -import org.keycloak.models.UserSessionModel; -import org.keycloak.models.UserSessionProvider; -import org.keycloak.models.UsernameLoginFailureModel; -import org.keycloak.models.sessions.mem.entities.ClientSessionEntity; -import org.keycloak.models.sessions.mem.entities.UserSessionEntity; -import org.keycloak.models.sessions.mem.entities.UsernameLoginFailureEntity; -import org.keycloak.models.sessions.mem.entities.UsernameLoginFailureKey; -import org.keycloak.models.utils.KeycloakModelUtils; -import org.keycloak.models.utils.RealmInfoUtil; -import org.keycloak.util.Time; - -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author Stian Thorgersen - */ -public class MemUserSessionProvider implements UserSessionProvider { - - private final KeycloakSession session; - private final ConcurrentHashMap userSessions; - private final ConcurrentHashMap userSessionsByBrokerSessionId; - private final ConcurrentHashMap> userSessionsByBrokerUserId; - private final ConcurrentHashMap clientSessions; - private final ConcurrentHashMap loginFailures; - - public MemUserSessionProvider(KeycloakSession session, ConcurrentHashMap userSessions, ConcurrentHashMap userSessionsByBrokerSessionId, ConcurrentHashMap> userSessionsByBrokerUserId, ConcurrentHashMap clientSessions, ConcurrentHashMap loginFailures) { - this.session = session; - this.userSessions = userSessions; - this.clientSessions = clientSessions; - this.loginFailures = loginFailures; - this.userSessionsByBrokerSessionId = userSessionsByBrokerSessionId; - this.userSessionsByBrokerUserId = userSessionsByBrokerUserId; - } - - @Override - public ClientSessionModel createClientSession(RealmModel realm, ClientModel client) { - ClientSessionEntity entity = new ClientSessionEntity(); - entity.setId(KeycloakModelUtils.generateId()); - entity.setTimestamp(Time.currentTime()); - entity.setClientId(client.getId()); - entity.setRealmId(realm.getId()); - clientSessions.put(entity.getId(), entity); - return new ClientSessionAdapter(session, this, realm, entity); - } - - @Override - public void removeClientSession(RealmModel realm, ClientSessionModel clientSession) { - ClientSessionEntity entity = ((ClientSessionAdapter)clientSession).getEntity(); - UserSessionModel userSession = clientSession.getUserSession(); - if (userSession != null) { - UserSessionEntity userSessionEntity = ((UserSessionAdapter)userSession).getEntity(); - userSessionEntity.getClientSessions().remove(entity); - } - clientSessions.remove(clientSession.getId()); - } - - @Override - public ClientSessionModel getClientSession(RealmModel realm, String id) { - ClientSessionEntity entity = clientSessions.get(id); - return entity != null ? new ClientSessionAdapter(session, this, realm, entity) : null; - } - - @Override - public ClientSessionModel getClientSession(String id) { - ClientSessionEntity entity = clientSessions.get(id); - if (entity != null) { - RealmModel realm = session.realms().getRealm(entity.getRealmId()); - return new ClientSessionAdapter(session, this, realm, entity); - } - return null; - } - - @Override - public UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId) { - String id = KeycloakModelUtils.generateId(); - - UserSessionEntity entity = new UserSessionEntity(); - entity.setId(id); - entity.setRealm(realm.getId()); - entity.setUser(user.getId()); - entity.setLoginUsername(loginUsername); - entity.setIpAddress(ipAddress); - entity.setAuthMethod(authMethod); - entity.setRememberMe(rememberMe); - - int currentTime = Time.currentTime(); - - entity.setStarted(currentTime); - entity.setLastSessionRefresh(currentTime); - entity.setBrokerSessionId(brokerSessionId); - entity.setBrokerUserId(brokerUserId); - - userSessions.put(id, entity); - if (brokerSessionId != null) { - userSessionsByBrokerSessionId.put(brokerSessionId, id); - } - if (brokerUserId != null) { - while (true) { // while loop gets around a race condition when a user session is removed - Set set = userSessionsByBrokerUserId.get(brokerUserId); - if (set == null) { - Set value = new HashSet<>(); - set = userSessionsByBrokerUserId.putIfAbsent(brokerUserId, value); - if (set == null) { - set = value; - } - } - synchronized (set) { - set.add(id); - } - if (userSessionsByBrokerUserId.get(brokerUserId) == set) { - // we are ensured set isn't deleted before the new id is added - break; - } - } - } - - return new UserSessionAdapter(session, this, realm, entity); - } - - @Override - public List getUserSessionByBrokerUserId(RealmModel realm, String brokerUserId) { - Set sessions = userSessionsByBrokerUserId.get(brokerUserId); - if (sessions == null) return Collections.emptyList(); - List userSessions = new LinkedList(); - for (String id : sessions) { - UserSessionModel userSession = getUserSession(realm, id); - if (userSession != null) userSessions.add(userSession); - } - return userSessions; - } - - @Override - public UserSessionModel getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId) { - String id = userSessionsByBrokerSessionId.get(brokerSessionId); - if (id == null) return null; - return getUserSession(realm, id); - } - - @Override - public UserSessionModel getUserSession(RealmModel realm, String id) { - UserSessionEntity entity = getUserSessionEntity(realm, id); - return entity != null ? new UserSessionAdapter(session, this, realm, entity) : null; - } - - UserSessionEntity getUserSessionEntity(RealmModel realm, String id) { - UserSessionEntity entity = userSessions.get(id); - if (entity != null && entity.getRealm().equals(realm.getId())) { - return entity; - } - return null; - } - - @Override - public List getUserSessions(RealmModel realm, UserModel user) { - List userSessions = new LinkedList(); - for (UserSessionEntity s : this.userSessions.values()) { - if (s.getRealm().equals(realm.getId()) && s.getUser().equals(user.getId())) { - userSessions.add(new UserSessionAdapter(session, this, realm, s)); - } - } - return userSessions; - } - - @Override - public List getUserSessionsByNote(RealmModel realm, String noteName, String noteValue) { - List userSessions = new LinkedList(); - for (UserSessionEntity s : this.userSessions.values()) { - if (s.getRealm().equals(realm.getId()) && noteValue.equals(s.getNotes().get(noteName))) { - userSessions.add(new UserSessionAdapter(session, this, realm, s)); - } - } - return userSessions; - } - - @Override - public List getUserSessions(RealmModel realm, ClientModel client) { - List userSessionEntities = new LinkedList(); - for (ClientSessionEntity s : clientSessions.values()) { - String realmId = realm.getId(); - String clientId = client.getId(); - if (s.getSession() != null && s.getSession().getRealm().equals(realmId) && s.getClientId().equals(clientId)) { - if (!userSessionEntities.contains(s.getSession())) { - userSessionEntities.add(s.getSession()); - } - } - } - - List userSessions = new LinkedList(); - for (UserSessionEntity e : userSessionEntities) { - userSessions.add(new UserSessionAdapter(session, this, realm, e)); - } - Collections.sort(userSessions, new UserSessionSort()); - return userSessions; - } - - @Override - public List getUserSessions(RealmModel realm, ClientModel client, int firstResult, int maxResults) { - List userSessions = getUserSessions(realm, client); - if (firstResult > userSessions.size()) { - return Collections.emptyList(); - } - - int toIndex = (firstResult + maxResults) < userSessions.size() ? firstResult + maxResults : userSessions.size(); - return userSessions.subList(firstResult, toIndex); - } - - @Override - public int getActiveUserSessions(RealmModel realm, ClientModel client) { - return getUserSessions(realm, client).size(); - } - - @Override - public void removeUserSession(RealmModel realm, UserSessionModel session) { - UserSessionEntity entity = getUserSessionEntity(realm, session.getId()); - if (entity != null) { - userSessions.remove(entity.getId()); - remove(entity); - } - } - - @Override - public void removeUserSessions(RealmModel realm, UserModel user) { - Iterator itr = userSessions.values().iterator(); - while (itr.hasNext()) { - UserSessionEntity s = itr.next(); - if (s.getRealm().equals(realm.getId()) && s.getUser().equals(user.getId())) { - itr.remove(); - remove(s); - } - } - } - - protected void remove(UserSessionEntity s) { - if (s.getBrokerSessionId() != null) { - userSessionsByBrokerSessionId.remove(s.getBrokerSessionId()); - } - if (s.getBrokerUserId() != null) { - Set set = userSessionsByBrokerUserId.get(s.getBrokerUserId()); - if (set != null) { - synchronized (set) { - set.remove(s.getId()); - // this is a race condition :( - // Since it will be very rare for a user to have concurrent sessions, I'm hoping we never hit this - if (set.isEmpty()) userSessionsByBrokerUserId.remove(s.getBrokerUserId()); - } - } - } - for (ClientSessionEntity clientSession : s.getClientSessions()) { - clientSessions.remove(clientSession.getId()); - } - } - - @Override - public void removeExpiredUserSessions(RealmModel realm) { - Iterator itr = userSessions.values().iterator(); - while (itr.hasNext()) { - UserSessionEntity s = itr.next(); - if (s.getRealm().equals(realm.getId()) && (s.getLastSessionRefresh() < Time.currentTime() - realm.getSsoSessionIdleTimeout() || s.getStarted() < Time.currentTime() - realm.getSsoSessionMaxLifespan())) { - itr.remove(); - - remove(s); - } - } - int expired = Time.currentTime() - RealmInfoUtil.getDettachedClientSessionLifespan(realm); - Iterator citr = clientSessions.values().iterator(); - while (citr.hasNext()) { - ClientSessionEntity c = citr.next(); - if (c.getSession() == null && c.getRealmId().equals(realm.getId()) && c.getTimestamp() < expired) { - citr.remove(); - } - } - } - - @Override - public void removeUserSessions(RealmModel realm) { - Iterator itr = userSessions.values().iterator(); - while (itr.hasNext()) { - UserSessionEntity s = itr.next(); - if (s.getRealm().equals(realm.getId())) { - itr.remove(); - - remove(s); - } - } - Iterator citr = clientSessions.values().iterator(); - while (citr.hasNext()) { - ClientSessionEntity c = citr.next(); - if (c.getSession() == null && c.getRealmId().equals(realm.getId())) { - citr.remove(); - } - } - } - - @Override - public UsernameLoginFailureModel getUserLoginFailure(RealmModel realm, String username) { - UsernameLoginFailureEntity entity = loginFailures.get(new UsernameLoginFailureKey(realm.getId(), username)); - return entity != null ? new UsernameLoginFailureAdapter(entity) : null; - } - - @Override - public UsernameLoginFailureModel addUserLoginFailure(RealmModel realm, String username) { - UsernameLoginFailureKey key = new UsernameLoginFailureKey(realm.getId(), username); - UsernameLoginFailureEntity entity = new UsernameLoginFailureEntity(username, realm.getId()); - if (loginFailures.putIfAbsent(key, entity) != null) { - throw new ModelDuplicateException(); - } - return new UsernameLoginFailureAdapter(entity); - } - - @Override - public void removeUserLoginFailure(RealmModel realm, String username) { - loginFailures.remove(new UsernameLoginFailureKey(realm.getId(), username)); - } - - @Override - public void removeAllUserLoginFailures(RealmModel realm) { - Iterator itr = loginFailures.values().iterator(); - while (itr.hasNext()) { - if (itr.next().getRealm().equals(realm.getId())) { - itr.remove(); - } - } - - } - - @Override - public void onRealmRemoved(RealmModel realm) { - removeUserSessions(realm); - removeAllUserLoginFailures(realm); - } - - @Override - public void onClientRemoved(RealmModel realm, ClientModel client) { - for (ClientSessionEntity e : clientSessions.values()) { - if (e.getRealmId().equals(realm.getId()) && e.getClientId().equals(client.getId())) { - clientSessions.remove(e.getId()); - e.getSession().removeClientSession(e); - } - } - } - - @Override - public void onUserRemoved(RealmModel realm, UserModel user) { - removeUserSessions(realm, user); - - loginFailures.remove(new UsernameLoginFailureKey(realm.getId(), user.getUsername())); - loginFailures.remove(new UsernameLoginFailureKey(realm.getId(), user.getEmail())); - } - - @Override - public void close() { - } - - private class UserSessionSort implements Comparator { - - @Override - public int compare(UserSessionModel o1, UserSessionModel o2) { - int r = o1.getStarted() - o2.getStarted(); - if (r == 0) { - return o1.getId().compareTo(o2.getId()); - } else { - return r; - } - } - } - -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/MemUserSessionProviderFactory.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/MemUserSessionProviderFactory.java deleted file mode 100755 index 73b7ebca06..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/MemUserSessionProviderFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.keycloak.models.sessions.mem; - -import org.keycloak.Config; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakSessionFactory; -import org.keycloak.models.UserSessionProvider; -import org.keycloak.models.UserSessionProviderFactory; -import org.keycloak.models.sessions.mem.entities.ClientSessionEntity; -import org.keycloak.models.sessions.mem.entities.UserSessionEntity; -import org.keycloak.models.sessions.mem.entities.UsernameLoginFailureEntity; -import org.keycloak.models.sessions.mem.entities.UsernameLoginFailureKey; - -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author Stian Thorgersen - */ -public class MemUserSessionProviderFactory implements UserSessionProviderFactory { - - public static final String ID = "mem"; - - private ConcurrentHashMap userSessions = new ConcurrentHashMap(); - - private ConcurrentHashMap clientSessions = new ConcurrentHashMap(); - - private ConcurrentHashMap loginFailures = new ConcurrentHashMap(); - private final ConcurrentHashMap userSessionsByBrokerSessionId = new ConcurrentHashMap<>(); - private final ConcurrentHashMap> userSessionsByBrokerUserId = new ConcurrentHashMap<>(); - - @Override - public UserSessionProvider create(KeycloakSession session) { - return new MemUserSessionProvider(session, userSessions, userSessionsByBrokerSessionId, userSessionsByBrokerUserId, clientSessions, loginFailures); - } - - @Override - public void init(Config.Scope config) { - } - - @Override - public void postInit(KeycloakSessionFactory factory) { - - } - - @Override - public void close() { - userSessions.clear(); - loginFailures.clear(); - userSessionsByBrokerSessionId.clear(); - userSessionsByBrokerUserId.clear(); - } - - @Override - public String getId() { - return ID; - } - -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/UserSessionAdapter.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/UserSessionAdapter.java deleted file mode 100755 index 86b01877eb..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/UserSessionAdapter.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.keycloak.models.sessions.mem; - -import org.keycloak.models.ClientSessionModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.RealmModel; -import org.keycloak.models.UserModel; -import org.keycloak.models.UserSessionModel; -import org.keycloak.models.sessions.mem.entities.ClientSessionEntity; -import org.keycloak.models.sessions.mem.entities.UserSessionEntity; - -import java.util.LinkedList; -import java.util.List; - -/** - * @author Stian Thorgersen - */ -public class UserSessionAdapter implements UserSessionModel { - - private final KeycloakSession session; - - private MemUserSessionProvider provider; - private final RealmModel realm; - - private final UserSessionEntity entity; - - public UserSessionAdapter(KeycloakSession session, MemUserSessionProvider provider, RealmModel realm, UserSessionEntity entity) { - this.session = session; - this.provider = provider; - this.realm = realm; - this.entity = entity; - } - - public UserSessionEntity getEntity() { - return entity; - } - - public String getId() { - return entity.getId(); - } - - @Override - public String getBrokerSessionId() { - return entity.getBrokerSessionId(); - } - - @Override - public String getBrokerUserId() { - return entity.getBrokerUserId(); - } - - public void setId(String id) { - entity.setId(id); - } - - public UserModel getUser() { - return session.users().getUserById(entity.getUser(), realm); - } - - public void setUser(UserModel user) { - entity.setUser(user.getId()); - } - - @Override - public String getLoginUsername() { - return entity.getLoginUsername(); - } - - public String getIpAddress() { - return entity.getIpAddress(); - } - - @Override - public String getAuthMethod() { - return entity.getAuthMethod(); - } - - @Override - public boolean isRememberMe() { - return entity.isRememberMe(); - } - - public int getStarted() { - return entity.getStarted(); - } - - public int getLastSessionRefresh() { - return entity.getLastSessionRefresh(); - } - - public void setLastSessionRefresh(int lastSessionRefresh) { - entity.setLastSessionRefresh(lastSessionRefresh); - } - - @Override - public State getState() { - return entity.getState(); - } - - @Override - public void setState(State state) { - entity.setState(state); - - } - - @Override - public List getClientSessions() { - List clientSessionModels = new LinkedList(); - if (entity.getClientSessions() != null) { - for (ClientSessionEntity e : entity.getClientSessions()) { - clientSessionModels.add(new ClientSessionAdapter(session, provider, realm, e)); - } - } - return clientSessionModels; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || !(o instanceof UserSessionModel)) return false; - - UserSessionModel that = (UserSessionModel) o; - return that.getId().equals(getId()); - } - - @Override - public int hashCode() { - return getId().hashCode(); - } - - @Override - public String getNote(String name) { - return entity.getNotes().get(name); - } - - @Override - public void setNote(String name, String value) { - entity.getNotes().put(name, value); - - } - - @Override - public void removeNote(String name) { - entity.getNotes().remove(name); - - } - - -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/UsernameLoginFailureAdapter.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/UsernameLoginFailureAdapter.java deleted file mode 100644 index e47a643df8..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/UsernameLoginFailureAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.keycloak.models.sessions.mem; - -import org.keycloak.models.UsernameLoginFailureModel; -import org.keycloak.models.sessions.mem.entities.UsernameLoginFailureEntity; - -/** - * @author Stian Thorgersen - */ -public class UsernameLoginFailureAdapter implements UsernameLoginFailureModel { - - private final UsernameLoginFailureEntity entity; - - public UsernameLoginFailureAdapter(UsernameLoginFailureEntity entity) { - this.entity = entity; - } - - @Override - public String getUsername() { - return entity.getUsername(); - } - - public String getRealm() { - return entity.getRealm(); - } - - @Override - public int getFailedLoginNotBefore() { - return entity.getFailedLoginNotBefore().get(); - } - - @Override - public void setFailedLoginNotBefore(int notBefore) { - entity.getFailedLoginNotBefore().set(notBefore); - } - - @Override - public int getNumFailures() { - return entity.getNumFailures().get(); - } - - @Override - public void incrementFailures() { - entity.getNumFailures().incrementAndGet(); - } - - @Override - public void clearFailures() { - entity.clearFailures(); - } - - @Override - public long getLastFailure() { - return entity.getLastFailure().get(); - } - - @Override - public void setLastFailure(long lastFailure) { - entity.getLastFailure().set(lastFailure); - } - - @Override - public String getLastIPFailure() { - return entity.getLastIpFailure().get(); - } - - @Override - public void setLastIPFailure(String ip) { - entity.getLastIpFailure().set(ip); - } - -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/ClientSessionEntity.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/ClientSessionEntity.java deleted file mode 100755 index 7c6fb22fca..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/ClientSessionEntity.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.keycloak.models.sessions.mem.entities; - -import org.keycloak.models.ClientSessionModel; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author Stian Thorgersen - */ -public class ClientSessionEntity { - - private String id; - private String clientId; - private String realmId; - private Map authenticatorStatus = new HashMap<>(); - private String authUserId; - - private UserSessionEntity session; - - private String redirectUri; - private String authMethod; - - private int timestamp; - private String action; - private Set roles; - private Set protocolMappers; - private Map notes = new HashMap<>(); - private Map userSessionNotes = new HashMap<>(); - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getRealmId() { - return realmId; - } - - public void setRealmId(String realmId) { - this.realmId = realmId; - } - - public UserSessionEntity getSession() { - return session; - } - - public void setSession(UserSessionEntity session) { - this.session = session; - } - - public String getRedirectUri() { - return redirectUri; - } - - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - public int getTimestamp() { - return timestamp; - } - - public void setTimestamp(int timestamp) { - this.timestamp = timestamp; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public Set getRoles() { - return roles; - } - - public void setRoles(Set roles) { - this.roles = roles; - } - - public Set getProtocolMappers() { - return protocolMappers; - } - - public void setProtocolMappers(Set protocolMappers) { - this.protocolMappers = protocolMappers; - } - - public Map getNotes() { - return notes; - } - - public String getAuthMethod() { - return authMethod; - } - - public void setAuthMethod(String authMethod) { - this.authMethod = authMethod; - } - - public String getAuthUserId() { - return authUserId; - } - - public void setAuthUserId(String authUserId) { - this.authUserId = authUserId; - } - - public Map getAuthenticatorStatus() { - return authenticatorStatus; - } - - public void setAuthenticatorStatus(Map authenticatorStatus) { - this.authenticatorStatus = authenticatorStatus; - } - - public Map getUserSessionNotes() { - return userSessionNotes; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ClientSessionEntity)) return false; - - ClientSessionEntity that = (ClientSessionEntity) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - - return true; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UserSessionEntity.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UserSessionEntity.java deleted file mode 100755 index c7d0e26cd4..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UserSessionEntity.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.keycloak.models.sessions.mem.entities; - -import org.keycloak.models.UserSessionModel; - -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/** - * @author Stian Thorgersen - */ -public class UserSessionEntity { - - private String id; - private String brokerSessionId; - private String brokerUserId; - private String realm; - private String user; - private String loginUsername; - private String ipAddress; - private String authMethod; - private boolean rememberMe; - private int started; - private int lastSessionRefresh; - private UserSessionModel.State state; - private Map notes = new HashMap(); - private List clientSessions = Collections.synchronizedList(new LinkedList()); - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getRealm() { - return realm; - } - - public void setRealm(String realm) { - this.realm = realm; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getLoginUsername() { - return loginUsername; - } - - public void setLoginUsername(String loginUsername) { - this.loginUsername = loginUsername; - } - - public String getIpAddress() { - return ipAddress; - } - - public void setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; - } - - public String getAuthMethod() { - return authMethod; - } - - public void setAuthMethod(String authMethod) { - this.authMethod = authMethod; - } - - public boolean isRememberMe() { - return rememberMe; - } - - public void setRememberMe(boolean rememberMe) { - this.rememberMe = rememberMe; - } - - public int getStarted() { - return started; - } - - public void setStarted(int started) { - this.started = started; - } - - public int getLastSessionRefresh() { - return lastSessionRefresh; - } - - public void setLastSessionRefresh(int lastSessionRefresh) { - this.lastSessionRefresh = lastSessionRefresh; - } - - public void addClientSession(ClientSessionEntity clientSession) { - if (clientSessions == null) { - clientSessions = new LinkedList(); - } - clientSessions.add(clientSession); - } - - public void removeClientSession(ClientSessionEntity clientSession) { - if (clientSessions != null) { - clientSessions.remove(clientSession); - } - } - - public List getClientSessions() { - return clientSessions; - } - - public Map getNotes() { - return notes; - } - - public UserSessionModel.State getState() { - return state; - } - - public void setState(UserSessionModel.State state) { - this.state = state; - } - - public String getBrokerSessionId() { - return brokerSessionId; - } - - public void setBrokerSessionId(String brokerSessionId) { - this.brokerSessionId = brokerSessionId; - } - - public String getBrokerUserId() { - return brokerUserId; - } - - public void setBrokerUserId(String brokerUserId) { - this.brokerUserId = brokerUserId; - } -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UsernameLoginFailureEntity.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UsernameLoginFailureEntity.java deleted file mode 100644 index 32cf9815c5..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UsernameLoginFailureEntity.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.keycloak.models.sessions.mem.entities; - -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - -/** - * @author Stian Thorgersen - */ -public class UsernameLoginFailureEntity { - - private String username; - private String realm; - - private AtomicInteger failedLoginNotBefore = new AtomicInteger(); - private AtomicInteger numFailures = new AtomicInteger(); - private AtomicLong lastFailure = new AtomicLong(); - private AtomicReference lastIpFailure = new AtomicReference(); - - public UsernameLoginFailureEntity(String username, String realm) { - this.username = username; - this.realm = realm; - } - - public String getUsername() { - return username; - } - - public String getRealm() { - return realm; - } - - public AtomicInteger getFailedLoginNotBefore() { - return failedLoginNotBefore; - } - - public void setFailedLoginNotBefore(AtomicInteger failedLoginNotBefore) { - this.failedLoginNotBefore = failedLoginNotBefore; - } - - public AtomicInteger getNumFailures() { - return numFailures; - } - - public void setNumFailures(AtomicInteger numFailures) { - this.numFailures = numFailures; - } - - public AtomicLong getLastFailure() { - return lastFailure; - } - - public void setLastFailure(AtomicLong lastFailure) { - this.lastFailure = lastFailure; - } - - public AtomicReference getLastIpFailure() { - return lastIpFailure; - } - - public void setLastIpFailure(AtomicReference lastIpFailure) { - this.lastIpFailure = lastIpFailure; - } - - public void clearFailures() { - this.failedLoginNotBefore = new AtomicInteger(); - this.lastFailure = new AtomicLong(); - this.lastIpFailure = new AtomicReference(); - this.numFailures = new AtomicInteger(); - } - -} diff --git a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UsernameLoginFailureKey.java b/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UsernameLoginFailureKey.java deleted file mode 100644 index 68c7a4b9f5..0000000000 --- a/model/sessions-mem/src/main/java/org/keycloak/models/sessions/mem/entities/UsernameLoginFailureKey.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.keycloak.models.sessions.mem.entities; - -/** - * @author Stian Thorgersen - */ -public class UsernameLoginFailureKey { - - private final String realm; - private final String username; - - public UsernameLoginFailureKey(String realm, String username) { - this.realm = realm; - this.username = username; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - UsernameLoginFailureKey key = (UsernameLoginFailureKey) o; - - if (realm != null ? !realm.equals(key.realm) : key.realm != null) return false; - if (username != null ? !username.equals(key.username) : key.username != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = realm != null ? realm.hashCode() : 0; - result = 31 * result + (username != null ? username.hashCode() : 0); - return result; - } - -} diff --git a/model/sessions-mem/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory b/model/sessions-mem/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory deleted file mode 100644 index a869fa17ff..0000000000 --- a/model/sessions-mem/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory +++ /dev/null @@ -1 +0,0 @@ -org.keycloak.models.sessions.mem.MemUserSessionProviderFactory \ No newline at end of file diff --git a/pom.xml b/pom.xml index c10aa50513..a5044554da 100755 --- a/pom.xml +++ b/pom.xml @@ -950,11 +950,6 @@ keycloak-model-sessions-jpa ${project.version} - - org.keycloak - keycloak-model-sessions-mem - ${project.version} - org.keycloak keycloak-model-sessions-mongo