KEYCLOAK-1972 docs and export/import fixes for offline tokens. DB fixes
This commit is contained in:
1 parent
d13c120b6c
commit
9cc5ca3ce4
14 files changed
+40
-281
No files matched your search
@@ -32,8 +32,6 @@ import org.keycloak.representations.idm.CredentialRepresentation;
|
||||
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
||||
import org.keycloak.representations.idm.IdentityProviderMapperRepresentation;
|
||||
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||
import org.keycloak.representations.idm.OfflineClientSessionRepresentation;
|
||||
import org.keycloak.representations.idm.OfflineUserSessionRepresentation;
|
||||
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
|
||||
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
@@ -517,33 +515,4 @@ public class ModelToRepresentation {
|
||||
return rep;
|
||||
}
|
||||
|
||||
public static OfflineUserSessionRepresentation toRepresentation(RealmModel realm, PersistentUserSessionModel model, Collection<PersistentClientSessionModel> clientSessions) {
|
||||
OfflineUserSessionRepresentation rep = new OfflineUserSessionRepresentation();
|
||||
rep.setData(model.getData());
|
||||
rep.setUserSessionId(model.getUserSessionId());
|
||||
|
||||
List<OfflineClientSessionRepresentation> clientSessionReps = new LinkedList<>();
|
||||
for (PersistentClientSessionModel clsm : clientSessions) {
|
||||
OfflineClientSessionRepresentation clrep = toRepresentation(realm, clsm);
|
||||
clientSessionReps.add(clrep);
|
||||
}
|
||||
rep.setOfflineClientSessions(clientSessionReps);
|
||||
return rep;
|
||||
}
|
||||
|
||||
public static OfflineClientSessionRepresentation toRepresentation(RealmModel realm, PersistentClientSessionModel model) {
|
||||
OfflineClientSessionRepresentation rep = new OfflineClientSessionRepresentation();
|
||||
|
||||
String clientInternalId = model.getClientId();
|
||||
ClientModel client = realm.getClientById(clientInternalId);
|
||||
rep.setClient(client.getClientId());
|
||||
|
||||
rep.setClientSessionId(model.getClientSessionId());
|
||||
rep.setData(model.getData());
|
||||
return rep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1161,30 +1161,6 @@ public class RepresentationToModel {
|
||||
return consentModel;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// public static void importOfflineSession(KeycloakSession session, RealmModel newRealm, UserModel user, OfflineUserSessionRepresentation sessionRep) {
|
||||
// PersistentUserSessionModel model = new PersistentUserSessionModel();
|
||||
// model.setUserSessionId(sessionRep.getUserSessionId());
|
||||
// model.setData(sessionRep.getData());
|
||||
// session.users().createOfflineUserSession(newRealm, user, model);
|
||||
//
|
||||
// for (OfflineClientSessionRepresentation csRep : sessionRep.getOfflineClientSessions()) {
|
||||
// PersistentClientSessionModel csModel = new PersistentClientSessionModel();
|
||||
// String clientId = csRep.getClient();
|
||||
// ClientModel client = newRealm.getClientByClientId(clientId);
|
||||
// if (client == null) {
|
||||
// throw new RuntimeException("Unable to find client " + clientId + " referenced from offlineClientSession of user " + user.getUsername());
|
||||
// }
|
||||
// csModel.setClientId(client.getId());
|
||||
// csModel.setUserId(user.getId());
|
||||
// csModel.setClientSessionId(csRep.getClientSessionId());
|
||||
// csModel.setUserSessionId(sessionRep.getUserSessionId());
|
||||
// csModel.setData(csRep.getData());
|
||||
//
|
||||
// session.users().createOfflineClientSession(newRealm, csModel);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static AuthenticationFlowModel toModel(AuthenticationFlowRepresentation rep) {
|
||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||
model.setBuiltIn(rep.isBuiltIn());
|
||||
|
||||
+3
-3
@@ -20,10 +20,10 @@ import javax.persistence.Table;
|
||||
@NamedQuery(name="deleteClientSessionsByRealm", query="delete from PersistentClientSessionEntity sess where sess.userSessionId IN (select u.userSessionId from PersistentUserSessionEntity u where u.realmId=:realmId)"),
|
||||
@NamedQuery(name="deleteClientSessionsByClient", query="delete from PersistentClientSessionEntity sess where sess.clientId=:clientId"),
|
||||
@NamedQuery(name="deleteClientSessionsByUser", query="delete from PersistentClientSessionEntity sess where sess.userSessionId IN (select u.userSessionId from PersistentUserSessionEntity u where u.userId=:userId)"),
|
||||
@NamedQuery(name="deleteClientSessionsByUserSession", query="delete from PersistentClientSessionEntity sess where sess.userSessionId=:userSessionId and offline=:offline"),
|
||||
@NamedQuery(name="deleteClientSessionsByUserSession", query="delete from PersistentClientSessionEntity sess where sess.userSessionId=:userSessionId and sess.offline=:offline"),
|
||||
@NamedQuery(name="deleteDetachedClientSessions", query="delete from PersistentClientSessionEntity sess where sess.userSessionId NOT IN (select u.userSessionId from PersistentUserSessionEntity u)"),
|
||||
@NamedQuery(name="findClientSessionsByUserSession", query="select sess from PersistentClientSessionEntity sess where sess.userSessionId=:userSessionId and offline=:offline"),
|
||||
@NamedQuery(name="findClientSessionsByUserSessions", query="select sess from PersistentClientSessionEntity sess where offline=:offline and sess.userSessionId IN (:userSessionIds) order by sess.userSessionId"),
|
||||
@NamedQuery(name="findClientSessionsByUserSession", query="select sess from PersistentClientSessionEntity sess where sess.userSessionId=:userSessionId and sess.offline=:offline"),
|
||||
@NamedQuery(name="findClientSessionsByUserSessions", query="select sess from PersistentClientSessionEntity sess where sess.offline=:offline and sess.userSessionId IN (:userSessionIds) order by sess.userSessionId"),
|
||||
@NamedQuery(name="updateClientSessionsTimestamps", query="update PersistentClientSessionEntity c set timestamp=:timestamp"),
|
||||
})
|
||||
@Table(name="OFFLINE_CLIENT_SESSION")
|
||||
|
||||
+2
-2
@@ -25,8 +25,8 @@ import org.keycloak.models.jpa.entities.UserEntity;
|
||||
@NamedQuery(name="deleteUserSessionsByRealm", query="delete from PersistentUserSessionEntity sess where sess.realmId=:realmId"),
|
||||
@NamedQuery(name="deleteUserSessionsByUser", query="delete from PersistentUserSessionEntity sess where sess.userId=:userId"),
|
||||
@NamedQuery(name="deleteDetachedUserSessions", query="delete from PersistentUserSessionEntity sess where sess.userSessionId NOT IN (select c.userSessionId from PersistentClientSessionEntity c)"),
|
||||
@NamedQuery(name="findUserSessionsCount", query="select count(sess) from PersistentUserSessionEntity sess where offline=:offline"),
|
||||
@NamedQuery(name="findUserSessions", query="select sess from PersistentUserSessionEntity sess where offline=:offline order by sess.userSessionId"),
|
||||
@NamedQuery(name="findUserSessionsCount", query="select count(sess) from PersistentUserSessionEntity sess where sess.offline=:offline"),
|
||||
@NamedQuery(name="findUserSessions", query="select sess from PersistentUserSessionEntity sess where sess.offline=:offline order by sess.userSessionId"),
|
||||
@NamedQuery(name="updateUserSessionsTimestamps", query="update PersistentUserSessionEntity c set lastSessionRefresh=:lastSessionRefresh"),
|
||||
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user