diff --git a/dependencies/server-all/pom.xml b/dependencies/server-all/pom.xml
index b8d082413d..c193c0077c 100755
--- a/dependencies/server-all/pom.xml
+++ b/dependencies/server-all/pom.xml
@@ -40,14 +40,6 @@
org.keycloak
keycloak-model-file
-
- org.keycloak
- keycloak-model-sessions-jpa
-
-
- org.keycloak
- keycloak-model-sessions-mongo
-
org.keycloak
keycloak-model-sessions-infinispan
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 6ee6adb848..188a2a2d3e 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
@@ -22,10 +22,6 @@
"provider": "jpa"
},
- "userSessions": {
- "provider" : "infinispan"
- },
-
"timer": {
"provider": "basic"
},
diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-jpa/main/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-jpa/main/module.xml
deleted file mode 100644
index 39490fc473..0000000000
--- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-jpa/main/module.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-mongo/main/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-mongo/main/module.xml
deleted file mode 100644
index 0b5aaa05bd..0000000000
--- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-model-sessions-mongo/main/module.xml
+++ /dev/null
@@ -1,18 +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/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 92057483bc..38ecba81fe 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
@@ -36,8 +36,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 b062204302..052383de49 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
@@ -46,8 +46,6 @@
-
-
diff --git a/distribution/server-overlay/eap6/eap6-server-modules/build.xml b/distribution/server-overlay/eap6/eap6-server-modules/build.xml
index 1f30da0092..8f9ba8b8c1 100755
--- a/distribution/server-overlay/eap6/eap6-server-modules/build.xml
+++ b/distribution/server-overlay/eap6/eap6-server-modules/build.xml
@@ -189,14 +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/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 92057483bc..38ecba81fe 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
@@ -36,8 +36,6 @@
-
-
diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-jpa/main/module.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-jpa/main/module.xml
deleted file mode 100755
index f09407df79..0000000000
--- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-jpa/main/module.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-mongo/main/module.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-mongo/main/module.xml
deleted file mode 100755
index f1408f3d1c..0000000000
--- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-model-sessions-mongo/main/module.xml
+++ /dev/null
@@ -1,18 +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 337a5a1530..64915d3bab 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
@@ -46,8 +46,6 @@
-
-
diff --git a/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml b/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml
index 5e99637862..a49d432c41 100755
--- a/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml
+++ b/docbook/reference/en/en-US/modules/MigrationFromOlderVersions.xml
@@ -84,16 +84,24 @@
Realm and User cache providers
- Infinispan is now the default realm and user cache provider. In non-clustered mode a local Infinispan cache is used. We've also removed our
+ Infinispan is now the default and only realm and user cache providers. In non-clustered mode a local Infinispan cache is used. We've also removed our
custom in-memory cache and the no cache providers. If you have realmCache or userCache set in keycloak-server.json to mem or none please
remove these. As Infinispan is the only provider there's no longer any need for the realmCache and userCache objects so these can
be removed.
- User Session provider
+ Uses Session providers
- The mem user session provider has been removed. Instead the Infinispan user session provider with a local cache should be used.
+ Infinispan is now the default and only user session provider. In non-clustered mode a local Infinispan cache is used. We've also removed the JPA
+ and Mongo user session providers. If you have userSession set in keycloak-server.json to mem, jpa or mongo please
+ remove it. As Infinispan is the only provider there's no longer any need for the userSession object so it can
+ be removed.
+
+
+ For anyone that wants to achieve increased durability of user sessions this can be achieved by configuring the user session cache with
+ more than one owner or use a replicated cache. It's also possible to configure Infinispan to persist caches, although that would have
+ impacts on performance.
diff --git a/model/pom.xml b/model/pom.xml
index 6b70f5ace1..de7e486c9d 100755
--- a/model/pom.xml
+++ b/model/pom.xml
@@ -30,8 +30,6 @@
jpa
mongo
file
- sessions-jpa
- sessions-mongo
sessions-infinispan
diff --git a/model/sessions-jpa/pom.xml b/model/sessions-jpa/pom.xml
deleted file mode 100755
index 3b6b97310a..0000000000
--- a/model/sessions-jpa/pom.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
- keycloak-parent
- org.keycloak
- 1.5.0.Final-SNAPSHOT
- ../../pom.xml
-
- 4.0.0
-
- keycloak-model-sessions-jpa
- Keycloak Model Sessions JPA
-
-
-
-
- org.keycloak
- keycloak-core
- provided
-
-
- org.keycloak
- keycloak-model-api
- provided
-
-
- org.keycloak
- keycloak-connections-jpa
- provided
-
-
- org.hibernate.javax.persistence
- hibernate-jpa-2.1-api
- provided
-
-
- org.hibernate
- hibernate-entitymanager
- provided
-
-
-
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/ClientSessionAdapter.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/ClientSessionAdapter.java
deleted file mode 100755
index 2f9e199809..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/ClientSessionAdapter.java
+++ /dev/null
@@ -1,322 +0,0 @@
-package org.keycloak.models.sessions.jpa;
-
-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.jpa.entities.ClientSessionAuthStatusEntity;
-import org.keycloak.models.sessions.jpa.entities.ClientSessionEntity;
-import org.keycloak.models.sessions.jpa.entities.ClientSessionNoteEntity;
-import org.keycloak.models.sessions.jpa.entities.ClientSessionProtocolMapperEntity;
-import org.keycloak.models.sessions.jpa.entities.ClientSessionRoleEntity;
-import org.keycloak.models.sessions.jpa.entities.ClientUserSessionNoteEntity;
-import org.keycloak.models.sessions.jpa.entities.UserSessionEntity;
-
-import javax.persistence.EntityManager;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Stian Thorgersen
- */
-public class ClientSessionAdapter implements ClientSessionModel {
-
- private KeycloakSession session;
- private ClientSessionEntity entity;
- private EntityManager em;
- private RealmModel realm;
-
- public ClientSessionAdapter(KeycloakSession session, EntityManager em, RealmModel realm, ClientSessionEntity entity) {
- this.session = session;
- this.em = em;
- this.realm = realm;
- this.entity = entity;
- }
-
- @Override
- public RealmModel getRealm() {
- return session.realms().getRealm(entity.getRealmId());
- }
-
- @Override
- public void setNote(String name, String value) {
- for (ClientSessionNoteEntity attr : entity.getNotes()) {
- if (attr.getName().equals(name)) {
- attr.setValue(value);
- return;
- }
- }
- ClientSessionNoteEntity attr = new ClientSessionNoteEntity();
- attr.setName(name);
- attr.setValue(value);
- attr.setClientSession(entity);
- em.persist(attr);
- entity.getNotes().add(attr);
- }
-
- @Override
- public void removeNote(String name) {
- Iterator it = entity.getNotes().iterator();
- while (it.hasNext()) {
- ClientSessionNoteEntity attr = it.next();
- if (attr.getName().equals(name)) {
- it.remove();
- em.remove(attr);
- }
- }
- }
-
- @Override
- public String getNote(String name) {
- for (ClientSessionNoteEntity attr : entity.getNotes()) {
- if (attr.getName().equals(name)) {
- return attr.getValue();
- }
- }
- return null;
- }
-
- @Override
- public Map getNotes() {
- Map copy = new HashMap<>();
- for (ClientSessionNoteEntity attr : entity.getNotes()) {
- copy.put(attr.getName(), attr.getValue());
- }
-
- return copy;
- }
-
- @Override
- public void setUserSessionNote(String name, String value) {
- for (ClientUserSessionNoteEntity attr : entity.getUserSessionNotes()) {
- if (attr.getName().equals(name)) {
- attr.setValue(value);
- return;
- }
- }
- ClientUserSessionNoteEntity attr = new ClientUserSessionNoteEntity();
- attr.setName(name);
- attr.setValue(value);
- attr.setClientSession(entity);
- em.persist(attr);
- entity.getUserSessionNotes().add(attr);
-
- }
-
- @Override
- public Map getUserSessionNotes() {
- Map copy = new HashMap<>();
- for (ClientUserSessionNoteEntity attr : entity.getUserSessionNotes()) {
- copy.put(attr.getName(), attr.getValue());
- }
- return copy;
- }
-
- @Override
- public void clearUserSessionNotes() {
- Iterator it = entity.getUserSessionNotes().iterator();
- while (it.hasNext()) {
- ClientUserSessionNoteEntity attr = it.next();
- it.remove();
- em.remove(attr);
- }
-
- }
-
- @Override
- public String getId() {
- return entity.getId();
- }
-
- @Override
- public ClientModel getClient() {
- return realm.getClientById(entity.getClientId());
- }
-
- public ClientSessionEntity getEntity() {
- return entity;
- }
-
- @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) {
- if (roles != null) {
- for (String r : roles) {
- ClientSessionRoleEntity roleEntity = new ClientSessionRoleEntity();
- roleEntity.setClientSession(entity);
- roleEntity.setRoleId(r);
- em.persist(roleEntity);
-
- entity.getRoles().add(roleEntity);
- }
- } else {
- if (entity.getRoles() != null) {
- for (ClientSessionRoleEntity r : entity.getRoles()) {
- em.remove(r);
- }
- entity.getRoles().clear();
- }
- }
- }
-
- @Override
- public String getAuthMethod() {
- return entity.getAuthMethod();
- }
-
- @Override
- public void setAuthMethod(String method) {
- entity.setAuthMethod(method);
- }
-
- @Override
- public UserSessionModel getUserSession() {
- if (entity.getSession() == null) return null;
- return new UserSessionAdapter(session, em, realm, entity.getSession());
- }
-
- @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() {
- Set roles = new HashSet();
- if (entity.getRoles() != null) {
- for (ClientSessionRoleEntity e : entity.getRoles()) {
- roles.add(e.getRoleId());
- }
- }
- return roles;
- }
-
- @Override
- public Set getProtocolMappers() {
- Set protMappers = new HashSet();
- if (entity.getProtocolMappers() != null) {
- for (ClientSessionProtocolMapperEntity e : entity.getProtocolMappers()) {
- protMappers.add(e.getProtocolMapperId());
- }
- }
- return protMappers;
- }
-
- @Override
- public void setProtocolMappers(Set protocolMappers) {
- if (protocolMappers != null) {
- for (String pm : protocolMappers) {
- ClientSessionProtocolMapperEntity protMapperEntity = new ClientSessionProtocolMapperEntity();
- protMapperEntity.setClientSession(entity);
- protMapperEntity.setProtocolMapperId(pm);
- em.persist(protMapperEntity);
-
- entity.getProtocolMappers().add(protMapperEntity);
- }
- } else {
- if (entity.getProtocolMappers() != null) {
- for (ClientSessionProtocolMapperEntity pm : entity.getProtocolMappers()) {
- em.remove(pm);
- }
- entity.getProtocolMappers().clear();
- }
- }
- }
-
- @Override
- public Map getExecutionStatus() {
- Map result = new HashMap<>();
- for (ClientSessionAuthStatusEntity status : entity.getAuthanticatorStatus()) {
- result.put(status.getAuthenticator(), status.getStatus());
- }
- return result;
- }
-
- @Override
- public void setExecutionStatus(String authenticator, ExecutionStatus status) {
- boolean exists = false;
- for (ClientSessionAuthStatusEntity authStatus : entity.getAuthanticatorStatus()) {
- if (authStatus.getAuthenticator().equals(authenticator)) {
- authStatus.setStatus(status);
- exists = true;
- }
- }
-
- if (!exists) {
- ClientSessionAuthStatusEntity authStatus = new ClientSessionAuthStatusEntity();
- authStatus.setAuthenticator(authenticator);
- authStatus.setClientSession(entity);
- authStatus.setStatus(status);
- em.persist(authStatus);
- entity.getAuthanticatorStatus().add(authStatus);
- }
- em.flush();
-
-
- }
-
- @Override
- public void clearExecutionStatus() {
- Iterator iterator = entity.getAuthanticatorStatus().iterator();
- while (iterator.hasNext()) {
- ClientSessionAuthStatusEntity authStatus = iterator.next();
- iterator.remove();
- em.remove(authStatus);
- }
- }
-
- @Override
- public UserModel getAuthenticatedUser() {
- return entity.getUserId() == null ? null : session.users().getUserById(entity.getUserId(), realm);
- }
-
- @Override
- public void setAuthenticatedUser(UserModel user) {
- if (user == null) entity.setUserId(null);
- else entity.setUserId(user.getId());
- }
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaKeycloakTransaction.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaKeycloakTransaction.java
deleted file mode 100755
index 7af2775dfe..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaKeycloakTransaction.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.keycloak.models.sessions.jpa;
-
-import org.keycloak.models.KeycloakTransaction;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceException;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-public class JpaKeycloakTransaction implements KeycloakTransaction {
-
- protected EntityManager em;
-
- public JpaKeycloakTransaction(EntityManager em) {
- this.em = em;
- }
-
- @Override
- public void begin() {
- em.getTransaction().begin();
- }
-
- @Override
- public void commit() {
- try {
- em.getTransaction().commit();
- } catch (PersistenceException e) {
- throw PersistenceExceptionConverter.convert(e.getCause() != null ? e.getCause() : e);
- }
- }
-
- @Override
- public void rollback() {
- em.getTransaction().rollback();
- }
-
- @Override
- public void setRollbackOnly() {
- em.getTransaction().setRollbackOnly();
- }
-
- @Override
- public boolean getRollbackOnly() {
- return em.getTransaction().getRollbackOnly();
- }
-
- @Override
- public boolean isActive() {
- return em.getTransaction().isActive();
- }
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaUserSessionProvider.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaUserSessionProvider.java
deleted file mode 100755
index e8b460a08d..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaUserSessionProvider.java
+++ /dev/null
@@ -1,373 +0,0 @@
-package org.keycloak.models.sessions.jpa;
-
-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.UserSessionProvider;
-import org.keycloak.models.UsernameLoginFailureModel;
-import org.keycloak.models.sessions.jpa.entities.ClientSessionEntity;
-import org.keycloak.models.sessions.jpa.entities.UserSessionEntity;
-import org.keycloak.models.sessions.jpa.entities.UserSessionNoteEntity;
-import org.keycloak.models.sessions.jpa.entities.UsernameLoginFailureEntity;
-import org.keycloak.models.utils.KeycloakModelUtils;
-import org.keycloak.models.utils.RealmInfoUtil;
-import org.keycloak.util.Time;
-
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Stian Thorgersen
- */
-public class JpaUserSessionProvider implements UserSessionProvider {
-
- protected final KeycloakSession session;
-
- protected final EntityManager em;
-
- public JpaUserSessionProvider(KeycloakSession session, EntityManager em) {
- this.session = session;
- this.em = em;
- }
-
- @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());
- em.persist(entity);
-
- return new ClientSessionAdapter(session, em, realm, entity);
- }
-
- @Override
- public void removeClientSession(RealmModel realm, ClientSessionModel clientSession) {
- ClientSessionEntity clientSessionEntity = ((ClientSessionAdapter)clientSession).getEntity();
- em.remove(clientSessionEntity);
- em.flush();
- }
-
- @Override
- public ClientSessionModel getClientSession(RealmModel realm, String id) {
- ClientSessionEntity clientSession = em.find(ClientSessionEntity.class, id);
- if (clientSession != null && clientSession.getRealmId().equals(realm.getId())) {
- return new ClientSessionAdapter(session, em, realm, clientSession);
- }
- return null;
- }
-
- @Override
- public ClientSessionModel getClientSession(String id) {
- ClientSessionEntity clientSession = em.find(ClientSessionEntity.class, id);
- if (clientSession != null) {
- RealmModel realm = session.realms().getRealm(clientSession.getRealmId());
- return new ClientSessionAdapter(session, em, realm, clientSession);
- }
- return null;
- }
-
- @Override
- public UsernameLoginFailureModel getUserLoginFailure(RealmModel realm, String username) {
- UsernameLoginFailureEntity entity = em.find(UsernameLoginFailureEntity.class, new UsernameLoginFailureEntity.Key(realm.getId(), username));
- if (entity == null) return null;
- return new UsernameLoginFailureAdapter(entity);
- }
-
- @Override
- public UsernameLoginFailureModel addUserLoginFailure(RealmModel realm, String username) {
- UsernameLoginFailureModel model = getUserLoginFailure(realm, username);
- if (model != null) return model;
- UsernameLoginFailureEntity entity = new UsernameLoginFailureEntity();
- entity.setUsername(username);
- entity.setRealmId(realm.getId());
- em.persist(entity);
- return new UsernameLoginFailureAdapter(entity);
- }
-
- @Override
- public void removeUserLoginFailure(RealmModel realm, String username) {
- UsernameLoginFailureEntity entity = em.find(UsernameLoginFailureEntity.class, new UsernameLoginFailureEntity.Key(realm.getId(), username));
- if (entity == null) return;
- em.remove(entity);
- }
-
- @Override
- public void removeAllUserLoginFailures(RealmModel realm) {
- em.createNamedQuery("removeLoginFailuresByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- }
-
- @Override
- public UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId) {
- UserSessionEntity entity = new UserSessionEntity();
- entity.setId(KeycloakModelUtils.generateId());
- entity.setRealmId(realm.getId());
- entity.setUserId(user.getId());
- entity.setLoginUsername(loginUsername);
- entity.setIpAddress(ipAddress);
- entity.setAuthMethod(authMethod);
- entity.setRememberMe(rememberMe);
- entity.setBrokerSessionId(brokerSessionId);
- entity.setBrokerUserId(brokerUserId);
-
- int currentTime = Time.currentTime();
-
- entity.setStarted(currentTime);
- entity.setLastSessionRefresh(currentTime);
-
- em.persist(entity);
- return new UserSessionAdapter(session, em, realm, entity);
- }
-
- @Override
- public UserSessionModel getUserSession(RealmModel realm, String id) {
- UserSessionEntity entity = em.find(UserSessionEntity.class, id);
- return entity != null ? new UserSessionAdapter(session, em, realm, entity) : null;
- }
-
- @Override
- public List getUserSessions(RealmModel realm, UserModel user) {
- List sessions = new LinkedList();
- TypedQuery query = em.createNamedQuery("getUserSessionByUser", UserSessionEntity.class)
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId());
- for (UserSessionEntity e : query.getResultList()) {
- sessions.add(new UserSessionAdapter(session, em, realm, e));
- }
- return sessions;
- }
-
- @Override
- public List getUserSessionByBrokerUserId(RealmModel realm, String brokerUserId) {
- List sessions = new LinkedList();
- TypedQuery query = em.createNamedQuery("getUserSessionByBrokerUserId", UserSessionEntity.class)
- .setParameter("realmId", realm.getId())
- .setParameter("brokerUserId", brokerUserId);
- for (UserSessionEntity e : query.getResultList()) {
- sessions.add(new UserSessionAdapter(session, em, realm, e));
- }
- return sessions;
- }
-
- @Override
- public UserSessionModel getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId) {
- List sessions = new LinkedList();
- TypedQuery query = em.createNamedQuery("getUserSessionByBrokerSessionId", UserSessionEntity.class)
- .setParameter("realmId", realm.getId())
- .setParameter("brokerSessionId", brokerSessionId);
- for (UserSessionEntity e : query.getResultList()) {
- sessions.add(new UserSessionAdapter(session, em, realm, e));
- }
- if (sessions.isEmpty()) return null;
- return sessions.get(0);
- }
-
- @Override
- public List getUserSessionsByNote(RealmModel realm, String noteName, String noteValue) {
- List sessions = new LinkedList();
- TypedQuery query = em.createNamedQuery("selectNoteByNameValue", UserSessionNoteEntity.class)
- .setParameter("name", noteName)
- .setParameter("value", noteValue);
- for (UserSessionNoteEntity note : query.getResultList()) {
- if (!note.getUserSession().getRealmId().equals(realm.getId())) continue;
- sessions.add(new UserSessionAdapter(session, em, realm, note.getUserSession()));
- }
- return sessions;
- }
-
- @Override
- public List getUserSessions(RealmModel realm, ClientModel client) {
- return getUserSessions(realm, client, -1, -1);
- }
-
- public List getUserSessions(RealmModel realm, ClientModel client, int firstResult, int maxResults) {
- List list = new LinkedList();
- TypedQuery query = em.createNamedQuery("getUserSessionByClient", UserSessionEntity.class)
- .setParameter("realmId", realm.getId())
- .setParameter("clientId", client.getId());
- if (firstResult != -1) {
- query.setFirstResult(firstResult);
- }
- if (maxResults != -1) {
- query.setMaxResults(maxResults);
- }
- for (UserSessionEntity entity : query.getResultList()) {
- list.add(new UserSessionAdapter(session, em, realm, entity));
- }
- return list;
- }
-
- @Override
- public int getActiveUserSessions(RealmModel realm, ClientModel client) {
- Object count = em.createNamedQuery("getActiveUserSessionByClient")
- .setParameter("realmId", realm.getId())
- .setParameter("clientId", client.getId())
- .getSingleResult();
- return ((Number)count).intValue();
- }
-
- @Override
- public void removeUserSession(RealmModel realm, UserSessionModel session) {
- UserSessionEntity entity = em.find(UserSessionEntity.class, session.getId());
- if (entity != null) {
- for (ClientSessionEntity c : entity.getClientSessions()) {
- em.remove(c);
- }
- em.remove(entity);
- }
- }
-
- @Override
- public void removeUserSessions(RealmModel realm, UserModel user) {
- em.createNamedQuery("removeClientSessionNoteByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- em.createNamedQuery("removeClientSessionRoleByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- em.createNamedQuery("removeClientSessionProtMapperByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- em.createNamedQuery("removeClientSessionAuthStatusByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- em.createNamedQuery("removeClientUserSessionNoteByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- em.createNamedQuery("removeClientSessionByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- em.createNamedQuery("removeUserSessionNoteByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- em.createNamedQuery("removeUserSessionByUser")
- .setParameter("realmId", realm.getId())
- .setParameter("userId", user.getId())
- .executeUpdate();
- }
-
- @Override
- public void removeExpiredUserSessions(RealmModel realm) {
- int maxTime = Time.currentTime() - realm.getSsoSessionMaxLifespan();
- int idleTime = Time.currentTime() - realm.getSsoSessionIdleTimeout();
- int dettachedClientSessionExpired = Time.currentTime() - RealmInfoUtil.getDettachedClientSessionLifespan(realm);
-
- em.createNamedQuery("removeDetachedClientSessionRoleByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", dettachedClientSessionExpired)
- .executeUpdate();
- em.createNamedQuery("removeDetachedClientSessionProtMapperByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", dettachedClientSessionExpired)
- .executeUpdate();
- em.createNamedQuery("removeDetachedClientSessionNoteByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", dettachedClientSessionExpired)
- .executeUpdate();
- em.createNamedQuery("removeDetachedClientSessionAuthStatusByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", dettachedClientSessionExpired)
- .executeUpdate();
- em.createNamedQuery("removeDetachedUserClientSessionNoteByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", dettachedClientSessionExpired)
- .executeUpdate();
- em.createNamedQuery("removeDetachedClientSessionByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", dettachedClientSessionExpired)
- .executeUpdate();
- em.createNamedQuery("removeClientSessionRoleByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- em.createNamedQuery("removeClientSessionProtMapperByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- em.createNamedQuery("removeClientSessionNoteByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- em.createNamedQuery("removeClientSessionAuthStatusByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- em.createNamedQuery("removeClientUserSessionNoteByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- em.createNamedQuery("removeClientSessionByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- em.createNamedQuery("removeUserSessionNoteByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- em.createNamedQuery("removeUserSessionByExpired")
- .setParameter("realmId", realm.getId())
- .setParameter("maxTime", maxTime)
- .setParameter("idleTime", idleTime)
- .executeUpdate();
- }
-
- @Override
- public void removeUserSessions(RealmModel realm) {
- em.createNamedQuery("removeClientSessionNoteByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionRoleByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionProtMapperByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionAuthStatusByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- em.createNamedQuery("removeClientUserSessionNoteByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- em.createNamedQuery("removeUserSessionNoteByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- em.createNamedQuery("removeUserSessionByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- }
-
- @Override
- public void onRealmRemoved(RealmModel realm) {
- removeUserSessions(realm);
- em.createNamedQuery("removeLoginFailuresByRealm").setParameter("realmId", realm.getId()).executeUpdate();
- }
-
- @Override
- public void onClientRemoved(RealmModel realm, ClientModel client) {
- em.createNamedQuery("removeClientSessionNoteByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionRoleByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionProtMapperByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionAuthStatusByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate();
- em.createNamedQuery("removeClientUserSessionNoteByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate();
- em.createNamedQuery("removeClientSessionByClient").setParameter("realmId", realm.getId()).setParameter("clientId", client.getId()).executeUpdate();
- }
-
- @Override
- public void onUserRemoved(RealmModel realm, UserModel user) {
- removeUserSessions(realm, user);
- em.createNamedQuery("removeLoginFailuresByUser").setParameter("realmId", realm.getId()).setParameter("username", user.getUsername()).setParameter("email", user.getEmail()).executeUpdate();
- }
-
- @Override
- public void close() {
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaUserSessionProviderFactory.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaUserSessionProviderFactory.java
deleted file mode 100755
index d1eddc245f..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/JpaUserSessionProviderFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.keycloak.models.sessions.jpa;
-
-import org.keycloak.Config;
-import org.keycloak.connections.jpa.JpaConnectionProvider;
-import org.keycloak.models.KeycloakSession;
-import org.keycloak.models.KeycloakSessionFactory;
-import org.keycloak.models.UserSessionProvider;
-import org.keycloak.models.UserSessionProviderFactory;
-
-import javax.persistence.EntityManager;
-
-/**
- * @author Stian Thorgersen
- */
-public class JpaUserSessionProviderFactory implements UserSessionProviderFactory {
-
- public static final String ID = "jpa";
-
- @Override
- public void init(Config.Scope config) {
- }
-
- @Override
- public void postInit(KeycloakSessionFactory factory) {
-
- }
-
- @Override
- public String getId() {
- return ID;
- }
-
- @Override
- public UserSessionProvider create(KeycloakSession session) {
- EntityManager em = session.getProvider(JpaConnectionProvider.class).getEntityManager();
- return new JpaUserSessionProvider(session, em);
- }
-
- @Override
- public void close() {
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/PersistenceExceptionConverter.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/PersistenceExceptionConverter.java
deleted file mode 100644
index 2d27df0c74..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/PersistenceExceptionConverter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.keycloak.models.sessions.jpa;
-
-import org.hibernate.exception.ConstraintViolationException;
-import org.keycloak.models.ModelDuplicateException;
-import org.keycloak.models.ModelException;
-
-import javax.persistence.EntityExistsException;
-import javax.persistence.EntityManager;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-/**
- * @author Stian Thorgersen
- */
-public class PersistenceExceptionConverter implements InvocationHandler {
-
- private EntityManager em;
-
- public static EntityManager create(EntityManager em) {
- return (EntityManager) Proxy.newProxyInstance(EntityManager.class.getClassLoader(), new Class[]{EntityManager.class}, new PersistenceExceptionConverter(em));
- }
-
- private PersistenceExceptionConverter(EntityManager em) {
- this.em = em;
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- try {
- return method.invoke(em, args);
- } catch (InvocationTargetException e) {
- throw convert(e.getCause());
- }
- }
-
- public static ModelException convert(Throwable t) {
- if (t.getCause() != null && t.getCause() instanceof ConstraintViolationException) {
- throw new ModelDuplicateException(t);
- } if (t instanceof EntityExistsException) {
- throw new ModelDuplicateException(t);
- } else {
- throw new ModelException(t);
- }
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/UserSessionAdapter.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/UserSessionAdapter.java
deleted file mode 100755
index 5b0b87ec00..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/UserSessionAdapter.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.keycloak.models.sessions.jpa;
-
-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.jpa.entities.ClientSessionEntity;
-import org.keycloak.models.sessions.jpa.entities.UserSessionEntity;
-import org.keycloak.models.sessions.jpa.entities.UserSessionNoteEntity;
-
-import javax.persistence.EntityManager;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Stian Thorgersen
- */
-public class UserSessionAdapter implements UserSessionModel {
-
- private KeycloakSession session;
- private RealmModel realm;
- private UserSessionEntity entity;
- private EntityManager em;
-
- public UserSessionAdapter(KeycloakSession session, EntityManager em, RealmModel realm, UserSessionEntity entity) {
- this.session = session;
- this.realm = realm;
- this.entity = entity;
- this.em = em;
- }
-
- public UserSessionEntity getEntity() {
- return entity;
- }
-
- @Override
- public String getId() {
- return entity.getId();
- }
-
- @Override
- public String getBrokerSessionId() {
- return entity.getBrokerSessionId();
- }
-
- @Override
- public String getBrokerUserId() {
- return entity.getBrokerUserId();
- }
-
- @Override
- public UserModel getUser() {
- return session.users().getUserById(entity.getUserId(), realm);
- }
-
- @Override
- public String getLoginUsername() {
- return entity.getLoginUsername();
- }
-
- @Override
- public String getIpAddress() {
- return entity.getIpAddress();
- }
-
- @Override
- public String getAuthMethod() {
- return entity.getAuthMethod();
- }
-
- @Override
- public boolean isRememberMe() {
- return entity.isRememberMe();
- }
-
- @Override
- public int getStarted() {
- return entity.getStarted();
- }
-
- @Override
- public int getLastSessionRefresh() {
- return entity.getLastSessionRefresh();
- }
-
- @Override
- public void setLastSessionRefresh(int seconds) {
- entity.setLastSessionRefresh(seconds);
- }
-
- @Override
- public void setNote(String name, String value) {
- for (UserSessionNoteEntity attr : entity.getNotes()) {
- if (attr.getName().equals(name)) {
- attr.setValue(value);
- return;
- }
- }
- UserSessionNoteEntity attr = new UserSessionNoteEntity();
- attr.setName(name);
- attr.setValue(value);
- attr.setUserSession(entity);
- em.persist(attr);
- entity.getNotes().add(attr);
- em.flush();
- }
-
- @Override
- public void removeNote(String name) {
- Iterator it = entity.getNotes().iterator();
- while (it.hasNext()) {
- UserSessionNoteEntity attr = it.next();
- if (attr.getName().equals(name)) {
- it.remove();
- em.remove(attr);
- }
- }
- em.flush();
- }
-
- @Override
- public String getNote(String name) {
- for (UserSessionNoteEntity attr : entity.getNotes()) {
- if (attr.getName().equals(name)) {
- return attr.getValue();
- }
- }
- return null;
- }
-
- @Override
- public State getState() {
- return entity.getState();
- }
-
- @Override
- public void setState(State state) {
- entity.setState(state);
-
- }
-
- @Override
- public List getClientSessions() {
- List clientSessions = new LinkedList();
- for (ClientSessionEntity e : entity.getClientSessions()) {
- clientSessions.add(new ClientSessionAdapter(session, em, realm, e));
- }
- return clientSessions;
- }
-
- @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();
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/UsernameLoginFailureAdapter.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/UsernameLoginFailureAdapter.java
deleted file mode 100755
index ebe1d2e7da..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/UsernameLoginFailureAdapter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.keycloak.models.sessions.jpa;
-
-import org.keycloak.models.UsernameLoginFailureModel;
-import org.keycloak.models.sessions.jpa.entities.UsernameLoginFailureEntity;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-public class UsernameLoginFailureAdapter implements UsernameLoginFailureModel
-{
- protected UsernameLoginFailureEntity user;
-
- public UsernameLoginFailureAdapter(UsernameLoginFailureEntity user) {
- this.user = user;
- }
-
- @Override
- public String getUsername()
- {
- return user.getUsername();
- }
-
- @Override
- public int getFailedLoginNotBefore() {
- return user.getFailedLoginNotBefore();
- }
-
- @Override
- public void setFailedLoginNotBefore(int notBefore) {
- user.setFailedLoginNotBefore(notBefore);
- }
-
- @Override
- public int getNumFailures() {
- return user.getNumFailures();
- }
-
- @Override
- public void incrementFailures() {
- user.setNumFailures(getNumFailures() + 1);
- }
-
- @Override
- public void clearFailures() {
- user.clearFailures();
- }
-
- @Override
- public long getLastFailure() {
- return user.getLastFailure();
- }
-
- @Override
- public void setLastFailure(long lastFailure) {
- user.setLastFailure(lastFailure);
- }
-
- @Override
- public String getLastIPFailure() {
- return user.getLastIPFailure();
- }
-
- @Override
- public void setLastIPFailure(String ip) {
- user.setLastIPFailure(ip);
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionAuthStatusEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionAuthStatusEntity.java
deleted file mode 100755
index a30d81e9fe..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionAuthStatusEntity.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import org.keycloak.models.ClientSessionModel;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-@NamedQueries({
- @NamedQuery(name = "removeClientSessionAuthStatusByUser", query="delete from ClientSessionAuthStatusEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId))"),
- @NamedQuery(name = "removeClientSessionAuthStatusByClient", query="delete from ClientSessionAuthStatusEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.clientId = :clientId and c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionAuthStatusByRealm", query="delete from ClientSessionAuthStatusEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionAuthStatusByExpired", query = "delete from ClientSessionAuthStatusEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime)))"),
- @NamedQuery(name = "removeDetachedClientSessionAuthStatusByExpired", query = "delete from ClientSessionAuthStatusEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IS NULL and c.realmId = :realmId and c.timestamp < :maxTime )")
-})
-@Table(name="CLIENT_SESSION_AUTH_STATUS")
-@Entity
-@IdClass(ClientSessionAuthStatusEntity.Key.class)
-public class ClientSessionAuthStatusEntity {
-
- @Id
- @ManyToOne(fetch= FetchType.LAZY)
- @JoinColumn(name = "CLIENT_SESSION")
- protected ClientSessionEntity clientSession;
-
- @Id
- @Column(name = "AUTHENTICATOR")
- protected String authenticator;
- @Column(name = "STATUS")
- protected ClientSessionModel.ExecutionStatus status;
-
- public String getAuthenticator() {
- return authenticator;
- }
-
- public void setAuthenticator(String authenticator) {
- this.authenticator = authenticator;
- }
-
- public ClientSessionModel.ExecutionStatus getStatus() {
- return status;
- }
-
- public void setStatus(ClientSessionModel.ExecutionStatus status) {
- this.status = status;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public void setClientSession(ClientSessionEntity clientSession) {
- this.clientSession = clientSession;
- }
-
- public static class Key implements Serializable {
-
- protected ClientSessionEntity clientSession;
-
- protected String authenticator;
-
- public Key() {
- }
-
- public Key(ClientSessionEntity clientSession, String authenticator) {
- this.clientSession = clientSession;
- this.authenticator = authenticator;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public String getAuthenticator() {
- return authenticator;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Key key = (Key) o;
-
- if (authenticator != null ? !authenticator.equals(key.authenticator) : key.authenticator != null) return false;
- if (clientSession != null ? !clientSession.getId().equals(key.clientSession != null ? key.clientSession.getId() : null) : key.clientSession != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = clientSession != null ? clientSession.getId().hashCode() : 0;
- result = 31 * result + (authenticator != null ? authenticator.hashCode() : 0);
- return result;
- }
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionEntity.java
deleted file mode 100755
index 1c359b208c..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionEntity.java
+++ /dev/null
@@ -1,206 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import org.keycloak.models.ClientSessionModel;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-@Entity
-@Table(name = "CLIENT_SESSION")
-@NamedQueries({
- @NamedQuery(name = "removeClientSessionByRealm", query = "delete from ClientSessionEntity a where a.realmId = :realmId"),
- @NamedQuery(name = "removeClientSessionByUser", query = "delete from ClientSessionEntity a where a.session IN (select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId)"),
- @NamedQuery(name = "removeClientSessionByClient", query = "delete from ClientSessionEntity a where a.clientId = :clientId and a.realmId = :realmId"),
- @NamedQuery(name = "removeClientSessionByExpired", query = "delete from ClientSessionEntity a where a.session IN (select s from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime))"),
- @NamedQuery(name = "removeDetachedClientSessionByExpired", query = "delete from ClientSessionEntity a where a.session IS NULL and a.timestamp < :maxTime and a.realmId = :realmId")
-})
-public class ClientSessionEntity {
-
- @Id
- @Column(name = "ID", length = 36)
- protected String id;
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "SESSION_ID")
- protected UserSessionEntity session;
-
- @Column(name="CLIENT_ID",length = 36)
- protected String clientId;
-
- @Column(name="REALM_ID")
- protected String realmId;
-
- @Column(name="TIMESTAMP")
- protected int timestamp;
-
- @Column(name="REDIRECT_URI")
- protected String redirectUri;
-
- @Column(name="AUTH_METHOD")
- protected String authMethod;
-
- @Column(name="CURRENT_ACTION")
- protected String action;
-
- @Column(name="AUTH_USER_ID")
- protected String userId;
-
- @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="clientSession")
- protected Collection roles = new ArrayList();
-
- @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="clientSession")
- protected Collection protocolMappers = new ArrayList();
-
- @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="clientSession")
- protected Collection notes = new ArrayList();
-
- @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="clientSession")
- protected Collection userSessionNotes = new ArrayList<>();
-
- @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="clientSession")
- protected Collection authanticatorStatus = new ArrayList<>();
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public UserSessionEntity getSession() {
- return session;
- }
-
- public void setSession(UserSessionEntity session) {
- this.session = session;
- }
-
- 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 int getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(int timestamp) {
- this.timestamp = timestamp;
- }
-
- public String getRedirectUri() {
- return redirectUri;
- }
-
- public void setRedirectUri(String redirectUri) {
- this.redirectUri = redirectUri;
- }
-
- public String getAction() {
- return action;
- }
-
- public void setAction(String action) {
- this.action = action;
- }
-
- public Collection getRoles() {
- return roles;
- }
-
- public void setRoles(Collection roles) {
- this.roles = roles;
- }
-
- public Collection getProtocolMappers() {
- return protocolMappers;
- }
-
- public void setProtocolMappers(Collection protocolMappers) {
- this.protocolMappers = protocolMappers;
- }
-
- public Collection getNotes() {
- return notes;
- }
-
- public void setNotes(Collection notes) {
- this.notes = notes;
- }
-
- public String getAuthMethod() {
- return authMethod;
- }
-
- public void setAuthMethod(String authMethod) {
- this.authMethod = authMethod;
- }
-
- public Collection getAuthanticatorStatus() {
- return authanticatorStatus;
- }
-
- public void setAuthanticatorStatus(Collection authanticatorStatus) {
- this.authanticatorStatus = authanticatorStatus;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public Collection getUserSessionNotes() {
- return userSessionNotes;
- }
-
- public void setUserSessionNotes(Collection userSessionNotes) {
- this.userSessionNotes = 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-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionNoteEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionNoteEntity.java
deleted file mode 100755
index 349d78da07..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionNoteEntity.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-@NamedQueries({
- @NamedQuery(name = "removeClientSessionNoteByUser", query="delete from ClientSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId))"),
- @NamedQuery(name = "removeClientSessionNoteByClient", query="delete from ClientSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.clientId = :clientId and c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionNoteByRealm", query="delete from ClientSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionNoteByExpired", query = "delete from ClientSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime)))"),
- @NamedQuery(name = "removeDetachedClientSessionNoteByExpired", query = "delete from ClientSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IS NULL and c.realmId = :realmId and c.timestamp < :maxTime )")
-})
-@Table(name="CLIENT_SESSION_NOTE")
-@Entity
-@IdClass(ClientSessionNoteEntity.Key.class)
-public class ClientSessionNoteEntity {
-
- @Id
- @ManyToOne(fetch= FetchType.LAZY)
- @JoinColumn(name = "CLIENT_SESSION")
- protected ClientSessionEntity clientSession;
-
- @Id
- @Column(name = "NAME")
- protected String name;
- @Column(name = "VALUE")
- protected String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public void setClientSession(ClientSessionEntity clientSession) {
- this.clientSession = clientSession;
- }
-
- public static class Key implements Serializable {
-
- protected ClientSessionEntity clientSession;
-
- protected String name;
-
- public Key() {
- }
-
- public Key(ClientSessionEntity clientSession, String name) {
- this.clientSession = clientSession;
- this.name = name;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Key key = (Key) o;
-
- if (name != null ? !name.equals(key.name) : key.name != null) return false;
- if (clientSession != null ? !clientSession.getId().equals(key.clientSession != null ? key.clientSession.getId() : null) : key.clientSession != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = clientSession != null ? clientSession.getId().hashCode() : 0;
- result = 31 * result + (name != null ? name.hashCode() : 0);
- return result;
- }
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionProtocolMapperEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionProtocolMapperEntity.java
deleted file mode 100644
index 628e0f36f3..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionProtocolMapperEntity.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-/**
- * @author Marek Posolda
- */
-@NamedQueries({
- @NamedQuery(name = "removeClientSessionProtMapperByUser", query="delete from ClientSessionProtocolMapperEntity pm where pm.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId))"),
- @NamedQuery(name = "removeClientSessionProtMapperByClient", query="delete from ClientSessionProtocolMapperEntity pm where pm.clientSession IN (select c from ClientSessionEntity c where c.clientId = :clientId and c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionProtMapperByRealm", query="delete from ClientSessionProtocolMapperEntity pm where pm.clientSession IN (select c from ClientSessionEntity c where c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionProtMapperByExpired", query = "delete from ClientSessionProtocolMapperEntity pm where pm.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime)))"),
- @NamedQuery(name = "removeDetachedClientSessionProtMapperByExpired", query = "delete from ClientSessionProtocolMapperEntity pm where pm.clientSession IN (select c from ClientSessionEntity c where c.session IS NULL and c.realmId = :realmId and c.timestamp < :maxTime )")
-})
-@Table(name="CLIENT_SESSION_PROT_MAPPER")
-@Entity
-@IdClass(ClientSessionProtocolMapperEntity.Key.class)
-public class ClientSessionProtocolMapperEntity {
-
- @Id
- @ManyToOne(fetch= FetchType.LAZY)
- @JoinColumn(name="CLIENT_SESSION")
- protected ClientSessionEntity clientSession;
-
- @Id
- @Column(name="PROTOCOL_MAPPER_ID")
- protected String protocolMapperId;
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public void setClientSession(ClientSessionEntity clientSession) {
- this.clientSession = clientSession;
- }
-
- public String getProtocolMapperId() {
- return protocolMapperId;
- }
-
- public void setProtocolMapperId(String protocolMapperId) {
- this.protocolMapperId = protocolMapperId;
- }
-
- public static class Key implements Serializable {
-
- protected ClientSessionEntity clientSession;
-
- protected String protocolMapperId;
-
- public Key() {
- }
-
- public Key(ClientSessionEntity clientSession, String protocolMapperId) {
- this.clientSession = clientSession;
- this.protocolMapperId = protocolMapperId;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public String getProtocolMapperId() {
- return protocolMapperId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Key key = (Key) o;
-
- if (!protocolMapperId.equals(key.protocolMapperId)) return false;
- if (!clientSession.getId().equals(key.clientSession.getId())) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = clientSession.getId().hashCode();
- result = 31 * result + protocolMapperId.hashCode();
- return result;
- }
- }
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionRoleEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionRoleEntity.java
deleted file mode 100755
index 988b04c81c..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientSessionRoleEntity.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * @author Stian Thorgersen
- */
-@NamedQueries({
- @NamedQuery(name = "removeClientSessionRoleByUser", query="delete from ClientSessionRoleEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId))"),
- @NamedQuery(name = "removeClientSessionRoleByClient", query="delete from ClientSessionRoleEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.clientId = :clientId and c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionRoleByRealm", query="delete from ClientSessionRoleEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientSessionRoleByExpired", query = "delete from ClientSessionRoleEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime)))"),
- @NamedQuery(name = "removeDetachedClientSessionRoleByExpired", query = "delete from ClientSessionRoleEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IS NULL and c.realmId = :realmId and c.timestamp < :maxTime )")
-})
-@Table(name="CLIENT_SESSION_ROLE")
-@Entity
-@IdClass(ClientSessionRoleEntity.Key.class)
-public class ClientSessionRoleEntity {
-
- @Id
- @ManyToOne(fetch= FetchType.LAZY)
- @JoinColumn(name="CLIENT_SESSION")
- protected ClientSessionEntity clientSession;
-
- @Id
- @Column(name = "ROLE_ID")
- protected String roleId;
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public void setClientSession(ClientSessionEntity clientSession) {
- this.clientSession = clientSession;
- }
-
- public String getRoleId() {
- return roleId;
- }
-
- public void setRoleId(String roleId) {
- this.roleId = roleId;
- }
-
-
- public static class Key implements Serializable {
-
- protected ClientSessionEntity clientSession;
-
- protected String roleId;
-
- public Key() {
- }
-
- public Key(ClientSessionEntity clientSession, String roleId) {
- this.clientSession = clientSession;
- this.roleId = roleId;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public String getRoleId() {
- return roleId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Key key = (Key) o;
-
- if (!roleId.equals(key.roleId)) return false;
- if (!clientSession.getId().equals(key.clientSession.getId())) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = clientSession.getId().hashCode();
- result = 31 * result + roleId.hashCode();
- return result;
- }
- }
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientUserSessionNoteEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientUserSessionNoteEntity.java
deleted file mode 100755
index 3804ed43ad..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/ClientUserSessionNoteEntity.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-@NamedQueries({
- @NamedQuery(name = "removeClientUserSessionNoteByUser", query="delete from ClientUserSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId))"),
- @NamedQuery(name = "removeClientUserSessionNoteByClient", query="delete from ClientUserSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.clientId = :clientId and c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientUserSessionNoteByRealm", query="delete from ClientUserSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.realmId = :realmId)"),
- @NamedQuery(name = "removeClientUserSessionNoteByExpired", query = "delete from ClientUserSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IN (select s from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime)))"),
- @NamedQuery(name = "removeDetachedUserClientSessionNoteByExpired", query = "delete from ClientUserSessionNoteEntity r where r.clientSession IN (select c from ClientSessionEntity c where c.session IS NULL and c.realmId = :realmId and c.timestamp < :maxTime )")
-})
-@Table(name="CLIENT_USER_SESSION_NOTE")
-@Entity
-@IdClass(ClientUserSessionNoteEntity.Key.class)
-public class ClientUserSessionNoteEntity {
-
- @Id
- @ManyToOne(fetch= FetchType.LAZY)
- @JoinColumn(name = "CLIENT_SESSION")
- protected ClientSessionEntity clientSession;
-
- @Id
- @Column(name = "NAME")
- protected String name;
- @Column(name = "VALUE")
- protected String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public void setClientSession(ClientSessionEntity clientSession) {
- this.clientSession = clientSession;
- }
-
- public static class Key implements Serializable {
-
- protected ClientSessionEntity clientSession;
-
- protected String name;
-
- public Key() {
- }
-
- public Key(ClientSessionEntity clientSession, String name) {
- this.clientSession = clientSession;
- this.name = name;
- }
-
- public ClientSessionEntity getClientSession() {
- return clientSession;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Key key = (Key) o;
-
- if (name != null ? !name.equals(key.name) : key.name != null) return false;
- if (clientSession != null ? !clientSession.getId().equals(key.clientSession != null ? key.clientSession.getId() : null) : key.clientSession != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = clientSession != null ? clientSession.getId().hashCode() : 0;
- result = 31 * result + (name != null ? name.hashCode() : 0);
- return result;
- }
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UserSessionEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UserSessionEntity.java
deleted file mode 100755
index 4a40699d3c..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UserSessionEntity.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import org.keycloak.models.UserSessionModel;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author Stian Thorgersen
- */
-@Entity
-@Table(name = "USER_SESSION")
-@NamedQueries({
- @NamedQuery(name = "getUserSessionByUser", query = "select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId order by s.started, s.id"),
- @NamedQuery(name = "getUserSessionByBrokerSessionId", query = "select s from UserSessionEntity s where s.realmId = :realmId and s.brokerSessionId = :brokerSessionId order by s.started, s.id"),
- @NamedQuery(name = "getUserSessionByBrokerUserId", query = "select s from UserSessionEntity s where s.realmId = :realmId and s.brokerUserId = :brokerUserId order by s.started, s.id"),
- @NamedQuery(name = "getUserSessionByClient", query = "select s from UserSessionEntity s join s.clientSessions c where s.realmId = :realmId and c.clientId = :clientId order by s.started, s.id"),
- @NamedQuery(name = "getActiveUserSessionByClient", query = "select count(s) from UserSessionEntity s join s.clientSessions c where s.realmId = :realmId and c.clientId = :clientId"),
- @NamedQuery(name = "removeUserSessionByRealm", query = "delete from UserSessionEntity s where s.realmId = :realmId"),
- @NamedQuery(name = "removeUserSessionByUser", query = "delete from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId"),
- @NamedQuery(name = "removeUserSessionByExpired", query = "delete from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime)")
-})
-public class UserSessionEntity {
-
- @Id
- @Column(name="ID",length = 36)
- protected String id;
-
- @Column(name="USER_ID")
- protected String userId;
-
- @Column(name="BROKER_SESSION_ID")
- protected String brokerSessionId;
-
- @Column(name="BROKER_USER_ID")
- protected String brokerUserId;
-
- @Column(name="LOGIN_USERNAME")
- protected String loginUsername;
-
- @Column(name="REALM_ID")
- protected String realmId;
-
- @Column(name="IP_ADDRESS")
- protected String ipAddress;
-
- @Column(name="AUTH_METHOD")
- protected String authMethod;
-
- @Column(name="REMEMBER_ME")
- protected boolean rememberMe;
-
- @Column(name="STARTED")
- protected int started;
-
- @Column(name="LAST_SESSION_REFRESH")
- protected int lastSessionRefresh;
-
- @Column(name="USER_SESSION_STATE")
- protected UserSessionModel.State state;
-
- @OneToMany(mappedBy="session")
- protected Collection clientSessions = new ArrayList();
-
- @OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy="userSession")
- protected Collection notes = new ArrayList();
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public String getLoginUsername() {
- return loginUsername;
- }
-
- public void setLoginUsername(String loginUsername) {
- this.loginUsername = loginUsername;
- }
-
- public String getRealmId() {
- return realmId;
- }
-
- public void setRealmId(String realmId) {
- this.realmId = realmId;
- }
-
- 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 Collection getClientSessions() {
- return clientSessions;
- }
-
- public UserSessionModel.State getState() {
- return state;
- }
-
- public void setState(UserSessionModel.State state) {
- this.state = state;
- }
-
- public Collection getNotes() {
- return notes;
- }
-
- public void setNotes(Collection notes) {
- this.notes = notes;
- }
-
- 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-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UserSessionNoteEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UserSessionNoteEntity.java
deleted file mode 100755
index 3956a572a6..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UserSessionNoteEntity.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-@NamedQueries({
- @NamedQuery(name = "selectNoteByNameValue", query="select r from UserSessionNoteEntity r where r.name = :name and r.value = :value"),
- @NamedQuery(name = "removeUserSessionNoteByUser", query="delete from UserSessionNoteEntity r where r.userSession IN (select s from UserSessionEntity s where s.realmId = :realmId and s.userId = :userId)"),
- @NamedQuery(name = "removeUserSessionNoteByRealm", query="delete from UserSessionNoteEntity r where r.userSession IN (select c from UserSessionEntity c where c.realmId = :realmId)"),
- @NamedQuery(name = "removeUserSessionNoteByExpired", query = "delete from UserSessionNoteEntity r where r.userSession IN (select s from UserSessionEntity s where s.realmId = :realmId and (s.started < :maxTime or s.lastSessionRefresh < :idleTime))")
-})
-@Table(name="USER_SESSION_NOTE")
-@Entity
-@IdClass(UserSessionNoteEntity.Key.class)
-public class UserSessionNoteEntity {
-
- @Id
- @ManyToOne(fetch= FetchType.LAZY)
- @JoinColumn(name = "USER_SESSION")
- protected UserSessionEntity userSession;
-
- @Id
- @Column(name = "NAME")
- protected String name;
- @Column(name = "VALUE")
- protected String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public UserSessionEntity getUserSession() {
- return userSession;
- }
-
- public void setUserSession(UserSessionEntity userSession) {
- this.userSession = userSession;
- }
-
- public static class Key implements Serializable {
-
- protected UserSessionEntity userSession;
-
- protected String name;
-
- public Key() {
- }
-
- public Key(UserSessionEntity clientSession, String name) {
- this.userSession = clientSession;
- this.name = name;
- }
-
- public UserSessionEntity getUserSession() {
- return userSession;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Key key = (Key) o;
-
- if (name != null ? !name.equals(key.name) : key.name != null) return false;
- if (userSession != null ? !userSession.getId().equals(key.userSession != null ? key.userSession.getId() : null) : key.userSession != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = userSession != null ? userSession.getId().hashCode() : 0;
- result = 31 * result + (name != null ? name.hashCode() : 0);
- return result;
- }
- }
-
-}
diff --git a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UsernameLoginFailureEntity.java b/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UsernameLoginFailureEntity.java
deleted file mode 100755
index f760d5625c..0000000000
--- a/model/sessions-jpa/src/main/java/org/keycloak/models/sessions/jpa/entities/UsernameLoginFailureEntity.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.keycloak.models.sessions.jpa.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-@Entity
-@Table(name="USERNAME_LOGIN_FAILURE")
-@NamedQueries({
- @NamedQuery(name="getAllFailures", query="select failure from UsernameLoginFailureEntity failure"),
- @NamedQuery(name = "removeLoginFailuresByRealm", query = "delete from UsernameLoginFailureEntity f where f.realmId = :realmId"),
- @NamedQuery(name = "removeLoginFailuresByUser", query = "delete from UsernameLoginFailureEntity f where f.realmId = :realmId and (f.username = :username or f.username = :email)")
-})
-@IdClass(UsernameLoginFailureEntity.Key.class)
-public class UsernameLoginFailureEntity {
-
- @Id
- @Column(name="USERNAME",length = 200)
- protected String username;
-
- @Id
- @Column(name="REALM_ID",length = 36)
- protected String realmId;
-
- @Column(name="FAILED_LOGIN_NOT_BEFORE")
- protected int failedLoginNotBefore;
-
- @Column(name="NUM_FAILURES")
- protected int numFailures;
-
- @Column(name="LAST_FAILURE")
- protected long lastFailure;
-
- @Column(name="LAST_IP_FAILURE")
- protected String lastIPFailure;
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public int getFailedLoginNotBefore() {
- return failedLoginNotBefore;
- }
-
- public void setFailedLoginNotBefore(int failedLoginNotBefore) {
- this.failedLoginNotBefore = failedLoginNotBefore;
- }
-
- public int getNumFailures() {
- return numFailures;
- }
-
- public void setNumFailures(int numFailures) {
- this.numFailures = numFailures;
- }
-
- public long getLastFailure() {
- return lastFailure;
- }
-
- public void setLastFailure(long lastFailure) {
- this.lastFailure = lastFailure;
- }
-
- public String getLastIPFailure() {
- return lastIPFailure;
- }
-
- public void setLastIPFailure(String lastIPFailure) {
- this.lastIPFailure = lastIPFailure;
- }
-
- public String getRealmId() {
- return realmId;
- }
-
- public void setRealmId(String realmId) {
- this.realmId = realmId;
- }
-
- public void clearFailures() {
- setFailedLoginNotBefore(0);
- setLastFailure(0);
- setLastIPFailure(null);
- setNumFailures(0);
- }
-
- public static class Key implements Serializable {
-
- private String realmId;
-
- private String username;
-
- public Key() {
- }
-
- public Key(String realmId, String username) {
- this.realmId = realmId;
- this.username = username;
- }
-
- public String getRealmId() {
- return realmId;
- }
-
- public String getUsername() {
- return username;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Key key = (Key) o;
-
- if (realmId != null ? !realmId.equals(key.realmId) : key.realmId != null) return false;
- if (username != null ? !username.equals(key.username) : key.username != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = realmId != null ? realmId.hashCode() : 0;
- result = 31 * result + (username != null ? username.hashCode() : 0);
- return result;
- }
- }
-
-}
diff --git a/model/sessions-jpa/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory b/model/sessions-jpa/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory
deleted file mode 100644
index 8dc16d67e1..0000000000
--- a/model/sessions-jpa/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.keycloak.models.sessions.jpa.JpaUserSessionProviderFactory
\ No newline at end of file
diff --git a/model/sessions-mongo/pom.xml b/model/sessions-mongo/pom.xml
deleted file mode 100755
index b947e8a022..0000000000
--- a/model/sessions-mongo/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
- keycloak-parent
- org.keycloak
- 1.5.0.Final-SNAPSHOT
- ../../pom.xml
-
- 4.0.0
-
- keycloak-model-sessions-mongo
- Keycloak Model Sessions Mongo
-
-
-
-
- org.keycloak
- keycloak-core
- provided
-
-
- org.keycloak
- keycloak-model-api
- provided
-
-
- org.keycloak
- keycloak-connections-mongo
- provided
-
-
- org.mongodb
- mongo-java-driver
- provided
-
-
-
\ No newline at end of file
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/AbstractMongoAdapter.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/AbstractMongoAdapter.java
deleted file mode 100644
index 3aea2c9f78..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/AbstractMongoAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.keycloak.models.sessions.mongo;
-
-import org.keycloak.connections.mongo.api.MongoIdentifiableEntity;
-import org.keycloak.connections.mongo.api.MongoStore;
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-
-/**
- * @author Marek Posolda
- */
-public abstract class AbstractMongoAdapter {
-
- protected final MongoStoreInvocationContext invocationContext;
-
- public AbstractMongoAdapter(MongoStoreInvocationContext invocationContext) {
- this.invocationContext = invocationContext;
- }
-
- protected abstract T getMongoEntity();
-
- protected void updateMongoEntity() {
- getMongoStore().updateEntity(getMongoEntity(), invocationContext);
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) return true;
-
- if (o == null || getClass() != o.getClass()) return false;
-
- AbstractMongoAdapter that = (AbstractMongoAdapter) o;
-
- if (getMongoEntity() == null && that.getMongoEntity() == null) return true;
- return getMongoEntity().equals(that.getMongoEntity());
- }
-
- @Override
- public int hashCode() {
- return getMongoEntity()!=null ? getMongoEntity().hashCode() : super.hashCode();
- }
-
- protected MongoStore getMongoStore() {
- return invocationContext.getMongoStore();
- }
-}
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/ClientSessionAdapter.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/ClientSessionAdapter.java
deleted file mode 100755
index 307b95bc9a..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/ClientSessionAdapter.java
+++ /dev/null
@@ -1,234 +0,0 @@
-package org.keycloak.models.sessions.mongo;
-
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-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.mongo.entities.MongoClientSessionEntity;
-import org.keycloak.models.sessions.mongo.entities.MongoUserSessionEntity;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Stian Thorgersen
- */
-public class ClientSessionAdapter extends AbstractMongoAdapter implements ClientSessionModel {
-
- private KeycloakSession session;
- private MongoUserSessionProvider provider;
- private RealmModel realm;
- private MongoClientSessionEntity entity;
-
- public ClientSessionAdapter(KeycloakSession session, MongoUserSessionProvider provider, RealmModel realm, MongoClientSessionEntity entity, MongoStoreInvocationContext invContext) {
- super(invContext);
- 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());
- }
-
- @Override
- public ClientModel getClient() {
- return realm.getClientById(entity.getClientId());
- }
-
- @Override
- public UserSessionModel getUserSession() {
- if (entity.getSessionId() == null) return null;
- return provider.getUserSession(realm, entity.getSessionId());
- }
-
- @Override
- public void setUserSession(UserSessionModel userSession) {
- if (userSession == null) {
- if (entity.getSessionId() != null) {
- MongoUserSessionEntity userSessionEntity = provider.getUserSessionEntity(realm, entity.getSessionId());
- provider.getMongoStore().pullItemFromList(userSessionEntity, "clientSessions", entity.getSessionId(), invocationContext);
- }
- entity.setSessionId(null);
- } else {
- MongoUserSessionEntity userSessionEntity = provider.getUserSessionEntity(realm, userSession.getId());
- entity.setSessionId(userSessionEntity.getId());
- updateMongoEntity();
-
- provider.getMongoStore().pushItemToList(userSessionEntity, "clientSessions", entity.getId(), true, invocationContext);
- }
- }
-
- @Override
- public void setRedirectUri(String uri) {
- entity.setRedirectUri(uri);
- updateMongoEntity();
- }
-
- @Override
- public void setRoles(Set roles) {
- if (roles == null) {
- entity.setRoles(null);
- } else {
- List list = new LinkedList();
- list.addAll(roles);
- entity.setRoles(list);
- }
- updateMongoEntity();
- }
-
- @Override
- public String getRedirectUri() {
- return entity.getRedirectUri();
- }
-
- @Override
- public int getTimestamp() {
- return entity.getTimestamp();
- }
-
- @Override
- public void setTimestamp(int timestamp) {
- entity.setTimestamp(timestamp);
- updateMongoEntity();
- }
-
- @Override
- public String getAction() {
- return entity.getAction();
- }
-
- @Override
- public void setAction(String action) {
- entity.setAction(action);
- updateMongoEntity();
- }
-
- @Override
- public Set getRoles() {
- return entity.getRoles() != null ? new HashSet(entity.getRoles()) : null;
- }
-
- @Override
- public Set getProtocolMappers() {
- return entity.getProtocolMappers() != null ? new HashSet(entity.getProtocolMappers()) : null;
- }
-
- @Override
- public void setProtocolMappers(Set protocolMappers) {
- if (protocolMappers == null) {
- entity.setProtocolMappers(null);
- } else {
- List list = new LinkedList();
- list.addAll(protocolMappers);
- entity.setProtocolMappers(list);
- }
- updateMongoEntity();
- }
-
- @Override
- public String getNote(String name) {
- return entity.getNotes().get(name);
- }
-
- @Override
- public void setNote(String name, String value) {
- entity.getNotes().put(name, value);
- updateMongoEntity();
- }
-
- @Override
- public void removeNote(String name) {
- entity.getNotes().remove(name);
- updateMongoEntity();
- }
-
- @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);
- updateMongoEntity();
- }
-
- @Override
- public Map getUserSessionNotes() {
- Map copy = new HashMap<>();
- copy.putAll(entity.getUserSessionNotes());
- return copy;
- }
-
- @Override
- public Map getExecutionStatus() {
- return entity.getAuthenticatorStatus();
- }
-
- @Override
- public void setExecutionStatus(String authenticator, ExecutionStatus status) {
- entity.getAuthenticatorStatus().put(authenticator, status);
- updateMongoEntity();
-
- }
-
- @Override
- public void clearExecutionStatus() {
- entity.getAuthenticatorStatus().clear();
- updateMongoEntity();
- }
-
- @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());
- updateMongoEntity();
-
- }
-
- @Override
- public String getAuthMethod() {
- return entity.getAuthMethod();
- }
-
- @Override
- public void setAuthMethod(String method) {
- entity.setAuthMethod(method);
- updateMongoEntity();
- }
-
- @Override
- protected MongoClientSessionEntity getMongoEntity() {
- return entity;
- }
-}
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProvider.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProvider.java
deleted file mode 100755
index d75da9a9b4..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProvider.java
+++ /dev/null
@@ -1,329 +0,0 @@
-package org.keycloak.models.sessions.mongo;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-import com.mongodb.QueryBuilder;
-import org.keycloak.connections.mongo.api.MongoStore;
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-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.UserSessionProvider;
-import org.keycloak.models.UsernameLoginFailureModel;
-import org.keycloak.models.sessions.mongo.entities.MongoClientSessionEntity;
-import org.keycloak.models.sessions.mongo.entities.MongoUserSessionEntity;
-import org.keycloak.models.sessions.mongo.entities.MongoUsernameLoginFailureEntity;
-import org.keycloak.models.utils.KeycloakModelUtils;
-import org.keycloak.models.utils.RealmInfoUtil;
-import org.keycloak.util.Time;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Stian Thorgersen
- */
-public class MongoUserSessionProvider implements UserSessionProvider {
-
- private final KeycloakSession session;
- private final MongoStore mongoStore;
- private final MongoStoreInvocationContext invocationContext;
-
- public MongoUserSessionProvider(KeycloakSession session, MongoStore mongoStore, MongoStoreInvocationContext invocationContext) {
- this.session = session;
- this.mongoStore = mongoStore;
- this.invocationContext = invocationContext;
- }
-
- public MongoStore getMongoStore() {
- return mongoStore;
- }
-
- @Override
- public ClientSessionModel createClientSession(RealmModel realm, ClientModel client) {
- MongoClientSessionEntity entity = new MongoClientSessionEntity();
- entity.setId(KeycloakModelUtils.generateId());
- entity.setTimestamp(Time.currentTime());
- entity.setClientId(client.getId());
- entity.setRealmId(realm.getId());
-
- mongoStore.insertEntity(entity, invocationContext);
-
- return new ClientSessionAdapter(session, this, realm, entity, invocationContext);
- }
-
- @Override
- public void removeClientSession(RealmModel realm, ClientSessionModel clientSession) {
- MongoClientSessionEntity entity = ((ClientSessionAdapter)clientSession).getMongoEntity();
- if (entity.getSessionId() != null) {
- MongoUserSessionEntity userSessionEntity = getUserSessionEntity(realm, entity.getSessionId());
- getMongoStore().pullItemFromList(userSessionEntity, "clientSessions", entity.getSessionId(), invocationContext);
-
- }
-
- mongoStore.removeEntity(entity, invocationContext);
-
- }
-
- @Override
- public ClientSessionModel getClientSession(RealmModel realm, String id) {
- MongoClientSessionEntity entity = getClientSessionEntity(id);
- if (entity == null) return null;
- return new ClientSessionAdapter(session, this, realm, entity, invocationContext);
- }
-
- @Override
- public ClientSessionModel getClientSession(String id) {
- MongoClientSessionEntity entity = getClientSessionEntity(id);
- if (entity != null) {
- RealmModel realm = session.realms().getRealm(entity.getRealmId());
- return new ClientSessionAdapter(session, this, realm, entity, invocationContext);
- }
- return null;
- }
-
-
- @Override
- public UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId) {
- MongoUserSessionEntity entity = new MongoUserSessionEntity();
- entity.setRealmId(realm.getId());
- entity.setUser(user.getId());
- entity.setLoginUsername(loginUsername);
- entity.setIpAddress(ipAddress);
- entity.setAuthMethod(authMethod);
- entity.setRememberMe(rememberMe);
- entity.setRealmId(realm.getId());
- entity.setBrokerSessionId(brokerSessionId);
- entity.setBrokerUserId(brokerUserId);
-
- int currentTime = Time.currentTime();
-
- entity.setStarted(currentTime);
- entity.setLastSessionRefresh(currentTime);
-
- mongoStore.insertEntity(entity, invocationContext);
- return new UserSessionAdapter(session, this, entity, realm, invocationContext);
- }
-
- @Override
- public UserSessionModel getUserSession(RealmModel realm, String id) {
- MongoUserSessionEntity entity = getUserSessionEntity(realm, id);
- if (entity == null) {
- return null;
- } else {
- return new UserSessionAdapter(session, this, entity, realm, invocationContext);
- }
- }
-
- MongoUserSessionEntity getUserSessionEntity(RealmModel realm, String id) {
- return mongoStore.loadEntity(MongoUserSessionEntity.class, id, invocationContext);
- }
-
- MongoClientSessionEntity getClientSessionEntity(String id) {
- return mongoStore.loadEntity(MongoClientSessionEntity.class, id, invocationContext);
- }
-
- @Override
- public List getUserSessions(RealmModel realm, UserModel user) {
- DBObject query = new BasicDBObject("user", user.getId());
- List sessions = new LinkedList();
- for (MongoUserSessionEntity e : mongoStore.loadEntities(MongoUserSessionEntity.class, query, invocationContext)) {
- sessions.add(new UserSessionAdapter(session, this, e, realm, invocationContext));
- }
- return sessions;
- }
-
- @Override
- public List getUserSessionByBrokerUserId(RealmModel realm, String brokerUserId) {
- DBObject query = new BasicDBObject("brokerUserId", brokerUserId);
- List sessions = new LinkedList();
- for (MongoUserSessionEntity e : mongoStore.loadEntities(MongoUserSessionEntity.class, query, invocationContext)) {
- sessions.add(new UserSessionAdapter(session, this, e, realm, invocationContext));
- }
- return sessions;
- }
-
- @Override
- public UserSessionModel getUserSessionByBrokerSessionId(RealmModel realm, String brokerSessionId) {
- DBObject query = new BasicDBObject("brokerSessionId", brokerSessionId);
- List sessions = new LinkedList();
- for (MongoUserSessionEntity e : mongoStore.loadEntities(MongoUserSessionEntity.class, query, invocationContext)) {
- sessions.add(new UserSessionAdapter(session, this, e, realm, invocationContext));
- }
- if (sessions.isEmpty()) return null;
- return sessions.get(0);
- }
-
- @Override
- public List getUserSessionsByNote(RealmModel realm, String noteName, String noteValue) {
- DBObject query = new QueryBuilder()
- .and("realmId").is(realm.getId())
- .and("notes." + noteName).is(noteValue).get();
- List sessions = new LinkedList();
- for (MongoUserSessionEntity e : mongoStore.loadEntities(MongoUserSessionEntity.class, query, invocationContext)) {
- sessions.add(new UserSessionAdapter(session, this, e, realm, invocationContext));
- }
- return sessions;
- }
-
- @Override
- public List getUserSessions(RealmModel realm, ClientModel client) {
- return getUserSessions(realm, client, -1, -1);
- }
-
- public List getUserSessions(RealmModel realm, ClientModel client, int firstResult, int maxResults) {
- DBObject query = new QueryBuilder()
- .and("clientId").is(client.getId())
- .and("sessionId").notEquals(null)
- .get();
- DBObject sort = new BasicDBObject("timestamp", 1).append("id", 1);
-
- List clientSessions = mongoStore.loadEntities(MongoClientSessionEntity.class, query, sort, firstResult, maxResults, invocationContext);
- List result = new LinkedList();
- for (MongoClientSessionEntity clientSession : clientSessions) {
- MongoUserSessionEntity userSession = mongoStore.loadEntity(MongoUserSessionEntity.class, clientSession.getSessionId(), invocationContext);
- result.add(new UserSessionAdapter(session, this, userSession, realm, invocationContext));
- }
- return result;
- }
-
- @Override
- public int getActiveUserSessions(RealmModel realm, ClientModel client) {
- DBObject query = new QueryBuilder()
- .and("clientId").is(client.getId())
- .and("sessionId").notEquals(null)
- .get();
- return mongoStore.countEntities(MongoClientSessionEntity.class, query, invocationContext);
- }
-
- @Override
- public void removeUserSession(RealmModel realm, UserSessionModel session) {
- mongoStore.removeEntity(((UserSessionAdapter) session).getMongoEntity(), invocationContext);
- }
-
- @Override
- public void removeUserSessions(RealmModel realm, UserModel user) {
- DBObject query = new BasicDBObject("user", user.getId());
- mongoStore.removeEntities(MongoUserSessionEntity.class, query, true, invocationContext);
- }
-
- @Override
- public void removeUserSessions(RealmModel realm) {
- DBObject query = new BasicDBObject("realmId", realm.getId());
- mongoStore.removeEntities(MongoUserSessionEntity.class, query, false, invocationContext);
- mongoStore.removeEntities(MongoClientSessionEntity.class, query, false, invocationContext);
- }
-
- @Override
- public void removeExpiredUserSessions(RealmModel realm) {
- int currentTime = Time.currentTime();
- DBObject query = new QueryBuilder()
- .and("realmId").is(realm.getId())
- .and("started").lessThan(currentTime - realm.getSsoSessionMaxLifespan())
- .get();
-
- mongoStore.removeEntities(MongoUserSessionEntity.class, query, true, invocationContext);
- query = new QueryBuilder()
- .and("realmId").is(realm.getId())
- .and("lastSessionRefresh").lessThan(currentTime - realm.getSsoSessionIdleTimeout())
- .get();
-
- mongoStore.removeEntities(MongoUserSessionEntity.class, query, true, invocationContext);
- query = new QueryBuilder()
- .and("sessionId").is(null)
- .and("realmId").is(realm.getId())
- .and("timestamp").lessThan(currentTime - RealmInfoUtil.getDettachedClientSessionLifespan(realm))
- .get();
-
- mongoStore.removeEntities(MongoClientSessionEntity.class, query, false, invocationContext);
- }
-
- @Override
- public UsernameLoginFailureModel getUserLoginFailure(RealmModel realm, String username) {
- DBObject query = new QueryBuilder()
- .and("username").is(username)
- .and("realmId").is(realm.getId())
- .get();
- MongoUsernameLoginFailureEntity user = mongoStore.loadSingleEntity(MongoUsernameLoginFailureEntity.class, query, invocationContext);
-
- if (user == null) {
- return null;
- } else {
- return new UsernameLoginFailureAdapter(invocationContext, user);
- }
- }
-
- @Override
- public UsernameLoginFailureModel addUserLoginFailure(RealmModel realm, String username) {
- UsernameLoginFailureModel userLoginFailure = getUserLoginFailure(realm, username);
- if (userLoginFailure != null) {
- return userLoginFailure;
- }
-
- MongoUsernameLoginFailureEntity userEntity = new MongoUsernameLoginFailureEntity();
- userEntity.setUsername(username);
- userEntity.setRealmId(realm.getId());
-
- mongoStore.insertEntity(userEntity, invocationContext);
- return new UsernameLoginFailureAdapter(invocationContext, userEntity);
- }
-
- @Override
- public void removeUserLoginFailure(RealmModel realm, String username) {
- DBObject query = new QueryBuilder()
- .and("username").is(username)
- .and("realmId").is(realm.getId())
- .get();
- mongoStore.removeEntities(MongoUsernameLoginFailureEntity.class, query, false, invocationContext);
- }
-
- @Override
- public void removeAllUserLoginFailures(RealmModel realm) {
- DBObject query = new QueryBuilder()
- .and("realmId").is(realm.getId())
- .get();
- mongoStore.removeEntities(MongoUsernameLoginFailureEntity.class, query, false, invocationContext);
-
- }
-
- @Override
- public void onRealmRemoved(RealmModel realm) {
- removeUserSessions(realm);
- removeAllUserLoginFailures(realm);
- }
-
- @Override
- // TODO Not very efficient, should use Mongo $pull to remove directly
- public void onClientRemoved(RealmModel realm, ClientModel client) {
- DBObject query = new QueryBuilder()
- .and("clientId").is(client.getId())
- .get();
- DBObject sort = new BasicDBObject("timestamp", 1).append("id", 1);
-
- List clientSessions = mongoStore.loadEntities(MongoClientSessionEntity.class, query, sort, -1, -1, invocationContext);
- for (MongoClientSessionEntity clientSession : clientSessions) {
- MongoUserSessionEntity userSession = mongoStore.loadEntity(MongoUserSessionEntity.class, clientSession.getSessionId(), invocationContext);
- getMongoStore().pullItemFromList(userSession, "clientSessions", clientSession.getId(), invocationContext);
- mongoStore.removeEntity(clientSession, invocationContext);
- }
- }
-
- @Override
- public void onUserRemoved(RealmModel realm, UserModel user) {
- removeUserSessions(realm, user);
-
- DBObject query = new QueryBuilder()
- .or(new BasicDBObject("username", user.getUsername()), new BasicDBObject("username", user.getEmail()))
- .and("realmId").is(realm.getId())
- .get();
- mongoStore.removeEntities(MongoUsernameLoginFailureEntity.class, query, true, invocationContext);
- }
-
- @Override
- public void close() {
- }
-
-}
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProviderFactory.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProviderFactory.java
deleted file mode 100755
index 70c4af172c..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProviderFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.keycloak.models.sessions.mongo;
-
-import org.keycloak.Config;
-import org.keycloak.connections.mongo.MongoConnectionProvider;
-import org.keycloak.models.KeycloakSession;
-import org.keycloak.models.KeycloakSessionFactory;
-import org.keycloak.models.UserSessionProvider;
-import org.keycloak.models.UserSessionProviderFactory;
-
-/**
- * @author Stian Thorgersen
- */
-public class MongoUserSessionProviderFactory implements UserSessionProviderFactory {
-
- public static final String ID = "mongo";
-
- @Override
- public UserSessionProvider create(KeycloakSession session) {
- MongoConnectionProvider connection = session.getProvider(MongoConnectionProvider.class);
- return new MongoUserSessionProvider(session, connection.getMongoStore(), connection.getInvocationContext());
- }
-
- @Override
- public void init(Config.Scope config) {
- }
-
- @Override
- public void postInit(KeycloakSessionFactory factory) {
-
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public String getId() {
- return ID;
- }
-
-}
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/UserSessionAdapter.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/UserSessionAdapter.java
deleted file mode 100755
index 644bbdbec4..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/UserSessionAdapter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.keycloak.models.sessions.mongo;
-
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-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.mongo.entities.MongoUserSessionEntity;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Stian Thorgersen
- */
-public class UserSessionAdapter extends AbstractMongoAdapter implements UserSessionModel {
-
- private final MongoUserSessionProvider provider;
- private MongoUserSessionEntity entity;
- private RealmModel realm;
- private KeycloakSession keycloakSession;
- private final MongoStoreInvocationContext invContext;
-
- public UserSessionAdapter(KeycloakSession keycloakSession, MongoUserSessionProvider provider, MongoUserSessionEntity entity, RealmModel realm, MongoStoreInvocationContext invContext) {
- super(invContext);
- this.provider = provider;
- this.entity = entity;
- this.realm = realm;
- this.keycloakSession = keycloakSession;
- this.invContext = invContext;
- }
-
- @Override
- protected MongoUserSessionEntity getMongoEntity() {
- return entity;
- }
-
- @Override
- public String getId() {
- return entity.getId();
- }
-
- @Override
- public String getBrokerSessionId() {
- return entity.getBrokerSessionId();
- }
-
- @Override
- public String getBrokerUserId() {
- return entity.getBrokerUserId();
- }
-
- @Override
- public UserModel getUser() {
- return keycloakSession.users().getUserById(entity.getUser(), realm);
- }
-
- @Override
- public String getLoginUsername() {
- return entity.getLoginUsername();
- }
-
- @Override
- public String getIpAddress() {
- return entity.getIpAddress();
- }
-
- @Override
- public String getAuthMethod() {
- return entity.getAuthMethod();
- }
-
- @Override
- public boolean isRememberMe() {
- return entity.isRememberMe();
- }
-
- @Override
- public int getStarted() {
- return entity.getStarted();
- }
-
- @Override
- public int getLastSessionRefresh() {
- return entity.getLastSessionRefresh();
- }
-
- @Override
- public void setLastSessionRefresh(int seconds) {
- entity.setLastSessionRefresh(seconds);
- updateMongoEntity();
- }
-
- @Override
- public State getState() {
- return entity.getState();
- }
-
- @Override
- public void setState(State state) {
- entity.setState(state);
- updateMongoEntity();
-
- }
-
- @Override
- public List getClientSessions() {
- List sessions = new LinkedList();
- if (entity.getClientSessions() == null) {
- return sessions;
- }
-
- for (String id : entity.getClientSessions()) {
- ClientSessionModel clientSession = provider.getClientSession(realm, id);
- if (clientSession == null) continue;
- sessions.add(clientSession);
- }
- return sessions;
- }
-
- @Override
- public String getNote(String name) {
- return entity.getNotes().get(name);
- }
-
- @Override
- public void setNote(String name, String value) {
- entity.getNotes().put(name, value);
- updateMongoEntity();
- }
-
- @Override
- public void removeNote(String name) {
- entity.getNotes().remove(name);
- updateMongoEntity();
- }
-
- @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();
- }
-
-}
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/UsernameLoginFailureAdapter.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/UsernameLoginFailureAdapter.java
deleted file mode 100755
index 7cd5249ff4..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/UsernameLoginFailureAdapter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.keycloak.models.sessions.mongo;
-
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-import org.keycloak.models.UsernameLoginFailureModel;
-import org.keycloak.models.sessions.mongo.entities.MongoUsernameLoginFailureEntity;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-public class UsernameLoginFailureAdapter extends AbstractMongoAdapter implements UsernameLoginFailureModel {
- protected MongoUsernameLoginFailureEntity user;
-
- public UsernameLoginFailureAdapter(MongoStoreInvocationContext invocationContext, MongoUsernameLoginFailureEntity user) {
- super(invocationContext);
- this.user = user;
- }
-
- @Override
- protected MongoUsernameLoginFailureEntity getMongoEntity() {
- return user;
- }
-
- @Override
- public String getUsername() {
- return user.getUsername();
- }
-
- @Override
- public int getFailedLoginNotBefore() {
- return user.getFailedLoginNotBefore();
- }
-
- @Override
- public void setFailedLoginNotBefore(int notBefore) {
- user.setFailedLoginNotBefore(notBefore);
- updateMongoEntity();
- }
-
- @Override
- public int getNumFailures() {
- return user.getNumFailures();
- }
-
- @Override
- public void incrementFailures() {
- user.setNumFailures(getNumFailures() + 1);
- updateMongoEntity();
- }
-
- @Override
- public void clearFailures() {
- user.clearFailures();
- updateMongoEntity();
- }
-
- @Override
- public long getLastFailure() {
- return user.getLastFailure();
- }
-
- @Override
- public void setLastFailure(long lastFailure) {
- user.setLastFailure(lastFailure);
- updateMongoEntity();
- }
-
- @Override
- public String getLastIPFailure() {
- return user.getLastIPFailure();
- }
-
- @Override
- public void setLastIPFailure(String ip) {
- user.setLastIPFailure(ip);
- updateMongoEntity();
- }}
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoClientSessionEntity.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoClientSessionEntity.java
deleted file mode 100755
index de7bed3cd5..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoClientSessionEntity.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package org.keycloak.models.sessions.mongo.entities;
-
-import org.keycloak.connections.mongo.api.MongoCollection;
-import org.keycloak.connections.mongo.api.MongoIdentifiableEntity;
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-import org.keycloak.models.ClientSessionModel;
-import org.keycloak.models.entities.AbstractIdentifiableEntity;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Stian Thorgersen
- */
-@MongoCollection(collectionName = "clientSessions")
-public class MongoClientSessionEntity extends AbstractIdentifiableEntity implements MongoIdentifiableEntity {
-
- private String id;
- private String clientId;
- private String realmId;
- private String sessionId;
-
- private String redirectUri;
- private String authMethod;
-
- private int timestamp;
- private String action;
- private List roles;
- private List protocolMappers;
- private Map notes = new HashMap();
- private Map userSessionNotes = new HashMap();
- private Map authenticatorStatus = new HashMap<>();
- private String authUserId;
-
- 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 String getRedirectUri() {
- return redirectUri;
- }
-
- public void setRedirectUri(String redirectUri) {
- this.redirectUri = redirectUri;
- }
-
- public String getAuthMethod() {
- return authMethod;
- }
-
- public void setAuthMethod(String authMethod) {
- this.authMethod = authMethod;
- }
-
- 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 List getRoles() {
- return roles;
- }
-
- public void setRoles(List roles) {
- this.roles = roles;
- }
-
- public List getProtocolMappers() {
- return protocolMappers;
- }
-
- public void setProtocolMappers(List protocolMappers) {
- this.protocolMappers = protocolMappers;
- }
-
- public Map getNotes() {
- return notes;
- }
-
- public void setNotes(Map notes) {
- this.notes = notes;
- }
-
- public Map getUserSessionNotes() {
- return userSessionNotes;
- }
-
- public void setUserSessionNotes(Map userSessionNotes) {
- this.userSessionNotes = userSessionNotes;
- }
-
- public String getSessionId() {
- return sessionId;
- }
-
- public void setSessionId(String sessionId) {
- this.sessionId = sessionId;
- }
-
- public Map getAuthenticatorStatus() {
- return authenticatorStatus;
- }
-
- public void setAuthenticatorStatus(Map authenticatorStatus) {
- this.authenticatorStatus = authenticatorStatus;
- }
-
- public String getAuthUserId() {
- return authUserId;
- }
-
- public void setAuthUserId(String authUserId) {
- this.authUserId = authUserId;
- }
-
- @Override
- public void afterRemove(MongoStoreInvocationContext context) {
- }
-
-}
diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoUserSessionEntity.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoUserSessionEntity.java
deleted file mode 100755
index 0c637db12f..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoUserSessionEntity.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package org.keycloak.models.sessions.mongo.entities;
-
-import com.mongodb.DBObject;
-import com.mongodb.QueryBuilder;
-import org.keycloak.connections.mongo.api.MongoCollection;
-import org.keycloak.connections.mongo.api.MongoIdentifiableEntity;
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-import org.keycloak.models.UserSessionModel;
-import org.keycloak.models.entities.AbstractIdentifiableEntity;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Stian Thorgersen
- */
-@MongoCollection(collectionName = "sessions")
-public class MongoUserSessionEntity extends AbstractIdentifiableEntity implements MongoIdentifiableEntity {
-
- private String realmId;
-
- private String brokerSessionId;
- private String brokerUserId;
-
- private String user;
-
- private String loginUsername;
-
- private String ipAddress;
-
- private String authMethod;
-
- private boolean rememberMe;
-
- private int started;
-
- private int lastSessionRefresh;
-
- private List clientSessions = new ArrayList();
-
- private Map notes = new HashMap();
-
- private UserSessionModel.State state;
-
- public String getRealmId() {
- return realmId;
- }
-
- public void setRealmId(String realmId) {
- this.realmId = realmId;
- }
-
- 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 List getClientSessions() {
- return clientSessions;
- }
-
- public void setClientSessions(List clientSessions) {
- this.clientSessions = clientSessions;
- }
-
- @Override
- public void afterRemove(MongoStoreInvocationContext context) {
- DBObject query = new QueryBuilder()
- .and("sessionId").is(getId())
- .get();
- context.getMongoStore().removeEntities(MongoClientSessionEntity.class, query, true, context);
- }
-
- public Map getNotes() {
- return notes;
- }
-
- public void setNotes(Map notes) {
- this.notes = 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-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoUsernameLoginFailureEntity.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoUsernameLoginFailureEntity.java
deleted file mode 100755
index d49657121a..0000000000
--- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/entities/MongoUsernameLoginFailureEntity.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.keycloak.models.sessions.mongo.entities;
-
-import org.keycloak.connections.mongo.api.MongoCollection;
-import org.keycloak.connections.mongo.api.MongoIdentifiableEntity;
-import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
-import org.keycloak.models.entities.UsernameLoginFailureEntity;
-
-/**
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-@MongoCollection(collectionName = "userFailures")
-public class MongoUsernameLoginFailureEntity extends UsernameLoginFailureEntity implements MongoIdentifiableEntity {
-
- @Override
- public void afterRemove(MongoStoreInvocationContext invocationContext) {
- }
-
-}
diff --git a/model/sessions-mongo/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory b/model/sessions-mongo/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory
deleted file mode 100644
index 3766f43594..0000000000
--- a/model/sessions-mongo/src/main/resources/META-INF/services/org.keycloak.models.UserSessionProviderFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.keycloak.models.sessions.mongo.MongoUserSessionProviderFactory
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a5044554da..e5d04b336f 100755
--- a/pom.xml
+++ b/pom.xml
@@ -945,16 +945,6 @@
keycloak-model-sessions-infinispan
${project.version}
-
- org.keycloak
- keycloak-model-sessions-jpa
- ${project.version}
-
-
- org.keycloak
- keycloak-model-sessions-mongo
- ${project.version}
-
org.keycloak
launcher
diff --git a/testsuite/integration/pom.xml b/testsuite/integration/pom.xml
index 91449c7021..3653fd97b4 100755
--- a/testsuite/integration/pom.xml
+++ b/testsuite/integration/pom.xml
@@ -340,7 +340,6 @@
jpa
jpa
jpa
- jpa
debug
@@ -405,7 +404,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -454,26 +452,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/integration/src/test/resources/META-INF/keycloak-server.json b/testsuite/integration/src/test/resources/META-INF/keycloak-server.json
index ef4b9d4023..cd56ce0511 100755
--- a/testsuite/integration/src/test/resources/META-INF/keycloak-server.json
+++ b/testsuite/integration/src/test/resources/META-INF/keycloak-server.json
@@ -22,10 +22,6 @@
"provider": "${keycloak.user.provider:jpa}"
},
- "userSessions": {
- "provider" : "${keycloak.userSessions.provider:infinispan}"
- },
-
"timer": {
"provider": "basic"
},
diff --git a/testsuite/jetty/jetty81/pom.xml b/testsuite/jetty/jetty81/pom.xml
index c9024ff00b..840282ef6b 100755
--- a/testsuite/jetty/jetty81/pom.xml
+++ b/testsuite/jetty/jetty81/pom.xml
@@ -322,7 +322,6 @@
jpa
jpa
jpa
- jpa
@@ -360,7 +359,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -410,26 +408,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/jetty/jetty91/pom.xml b/testsuite/jetty/jetty91/pom.xml
index 2456de5bae..fea7a82610 100755
--- a/testsuite/jetty/jetty91/pom.xml
+++ b/testsuite/jetty/jetty91/pom.xml
@@ -322,7 +322,6 @@
jpa
jpa
jpa
- jpa
@@ -360,7 +359,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -410,26 +408,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/jetty/jetty92/pom.xml b/testsuite/jetty/jetty92/pom.xml
index 439365b9a4..0afd207506 100755
--- a/testsuite/jetty/jetty92/pom.xml
+++ b/testsuite/jetty/jetty92/pom.xml
@@ -329,7 +329,6 @@
jpa
jpa
jpa
- jpa
@@ -367,7 +366,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -417,26 +415,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/proxy/pom.xml b/testsuite/proxy/pom.xml
index b4e738326d..d195398f21 100755
--- a/testsuite/proxy/pom.xml
+++ b/testsuite/proxy/pom.xml
@@ -306,7 +306,6 @@
jpa
jpa
jpa
- jpa
@@ -344,7 +343,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -394,26 +392,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/tomcat6/pom.xml b/testsuite/tomcat6/pom.xml
index 8a5b855652..92a4953178 100755
--- a/testsuite/tomcat6/pom.xml
+++ b/testsuite/tomcat6/pom.xml
@@ -299,7 +299,6 @@
jpa
jpa
jpa
- jpa
@@ -337,7 +336,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -387,26 +385,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/tomcat7/pom.xml b/testsuite/tomcat7/pom.xml
index 9b3b0a8e10..f9dc4f3032 100755
--- a/testsuite/tomcat7/pom.xml
+++ b/testsuite/tomcat7/pom.xml
@@ -302,7 +302,6 @@
jpa
jpa
jpa
- jpa
@@ -340,7 +339,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -390,26 +388,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/tomcat8/pom.xml b/testsuite/tomcat8/pom.xml
index 8ede611b62..30cbf0d3c7 100755
--- a/testsuite/tomcat8/pom.xml
+++ b/testsuite/tomcat8/pom.xml
@@ -301,7 +301,6 @@
jpa
jpa
jpa
- jpa
@@ -339,7 +338,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -389,26 +387,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-
diff --git a/testsuite/wildfly/pom.xml b/testsuite/wildfly/pom.xml
index 8f494bcf0e..d91657eb28 100644
--- a/testsuite/wildfly/pom.xml
+++ b/testsuite/wildfly/pom.xml
@@ -326,7 +326,6 @@
jpa
jpa
jpa
- jpa
@@ -364,7 +363,6 @@
mongo
mongo
mongo
- mongo
${keycloak.connectionsMongo.host}
${keycloak.connectionsMongo.port}
${keycloak.connectionsMongo.db}
@@ -414,26 +412,6 @@
-
- infinispan
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- infinispan
- infinispan
- infinispan
-
-
-
-
-
-
-