Convert authentication session entities into interface
This commit is contained in:
parent
ebfc24d6c1
commit
6c64d465ea
7 changed files with 128 additions and 242 deletions
|
@ -102,7 +102,7 @@ public class Util {
|
|||
public static String singularToPlural(String word) {
|
||||
if (word.endsWith("y")) {
|
||||
return word.substring(0, word.length() -1) + "ies";
|
||||
} else if (word.endsWith("ss")) {
|
||||
} else if (word.endsWith("s")) {
|
||||
return word + "es";
|
||||
} else {
|
||||
return word + "s";
|
||||
|
@ -112,7 +112,7 @@ public class Util {
|
|||
public static String pluralToSingular(String word) {
|
||||
if (word.endsWith("ies")) {
|
||||
return word.substring(0, word.length() - 3) + "y";
|
||||
} else if (word.endsWith("sses")) {
|
||||
} else if (word.endsWith("ses")) {
|
||||
return word.substring(0, word.length() - 2);
|
||||
} else {
|
||||
return word.endsWith("s") ? word.substring(0, word.length() - 1) : word;
|
||||
|
|
|
@ -23,11 +23,10 @@ import org.keycloak.models.UserModel;
|
|||
import org.keycloak.sessions.AuthenticationSessionModel;
|
||||
import org.keycloak.sessions.RootAuthenticationSessionModel;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mkanis@redhat.com">Martin Kanis</a>
|
||||
|
@ -59,20 +58,20 @@ public class MapAuthenticationSessionAdapter implements AuthenticationSessionMod
|
|||
|
||||
@Override
|
||||
public Map<String, ExecutionStatus> getExecutionStatus() {
|
||||
return entity.getExecutionStatus();
|
||||
Map<String, ExecutionStatus> executionStatus = entity.getExecutionStatuses();
|
||||
return executionStatus == null ? Collections.emptyMap() : Collections.unmodifiableMap(executionStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecutionStatus(String authenticator, ExecutionStatus status) {
|
||||
Objects.requireNonNull(authenticator, "The provided authenticator can't be null!");
|
||||
Objects.requireNonNull(status, "The provided execution status can't be null!");
|
||||
parent.setUpdated(!Objects.equals(entity.getExecutionStatus().put(authenticator, status), status));
|
||||
this.entity.setExecutionStatus(authenticator, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearExecutionStatus() {
|
||||
parent.setUpdated(!entity.getExecutionStatus().isEmpty());
|
||||
entity.getExecutionStatus().clear();
|
||||
entity.setExecutionStatuses(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,25 +82,25 @@ public class MapAuthenticationSessionAdapter implements AuthenticationSessionMod
|
|||
@Override
|
||||
public void setAuthenticatedUser(UserModel user) {
|
||||
String userId = (user == null) ? null : user.getId();
|
||||
parent.setUpdated(!Objects.equals(userId, entity.getAuthUserId()));
|
||||
entity.setAuthUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getRequiredActions() {
|
||||
return new HashSet<>(entity.getRequiredActions());
|
||||
Set<String> requiredActions = entity.getRequiredActions();
|
||||
return requiredActions == null ? Collections.emptySet() : Collections.unmodifiableSet(requiredActions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequiredAction(String action) {
|
||||
Objects.requireNonNull(action, "The provided action can't be null!");
|
||||
parent.setUpdated(entity.getRequiredActions().add(action));
|
||||
entity.addRequiredAction(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRequiredAction(String action) {
|
||||
Objects.requireNonNull(action, "The provided action can't be null!");
|
||||
parent.setUpdated(entity.getRequiredActions().remove(action));
|
||||
entity.removeRequiredAction(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,99 +117,77 @@ public class MapAuthenticationSessionAdapter implements AuthenticationSessionMod
|
|||
|
||||
@Override
|
||||
public void setUserSessionNote(String name, String value) {
|
||||
if (name != null) {
|
||||
if (value == null) {
|
||||
parent.setUpdated(entity.getUserSessionNotes().remove(name) != null);
|
||||
} else {
|
||||
parent.setUpdated(!Objects.equals(entity.getUserSessionNotes().put(name, value), value));
|
||||
}
|
||||
}
|
||||
entity.setUserSessionNote(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getUserSessionNotes() {
|
||||
return new ConcurrentHashMap<>(entity.getUserSessionNotes());
|
||||
Map<String, String> userSessionNotes = entity.getUserSessionNotes();
|
||||
return userSessionNotes == null ? Collections.emptyMap() : Collections.unmodifiableMap(userSessionNotes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearUserSessionNotes() {
|
||||
parent.setUpdated(!entity.getUserSessionNotes().isEmpty());
|
||||
entity.getUserSessionNotes().clear();
|
||||
entity.setUserSessionNotes(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthNote(String name) {
|
||||
return (name != null) ? entity.getAuthNotes().get(name) : null;
|
||||
Map<String, String> authNotes = entity.getAuthNotes();
|
||||
return (name != null && authNotes != null) ? authNotes.get(name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthNote(String name, String value) {
|
||||
if (name != null) {
|
||||
if (value == null) {
|
||||
parent.setUpdated(entity.getAuthNotes().remove(name) != null);
|
||||
} else {
|
||||
parent.setUpdated(!Objects.equals(entity.getAuthNotes().put(name, value), value));
|
||||
}
|
||||
}
|
||||
entity.setAuthNote(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAuthNote(String name) {
|
||||
if (name != null) {
|
||||
parent.setUpdated(entity.getAuthNotes().remove(name) != null);
|
||||
}
|
||||
entity.removeAuthNote(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAuthNotes() {
|
||||
parent.setUpdated(!entity.getAuthNotes().isEmpty());
|
||||
entity.getAuthNotes().clear();
|
||||
entity.setAuthNotes(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientNote(String name) {
|
||||
return (name != null) ? entity.getClientNotes().get(name) : null;
|
||||
return (name != null) ? getClientNotes().get(name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientNote(String name, String value) {
|
||||
if (name != null) {
|
||||
if (value == null) {
|
||||
parent.setUpdated(entity.getClientNotes().remove(name) != null);
|
||||
} else {
|
||||
parent.setUpdated(!Objects.equals(entity.getClientNotes().put(name, value), value));
|
||||
}
|
||||
}
|
||||
entity.setClientNote(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeClientNote(String name) {
|
||||
if (name != null) {
|
||||
parent.setUpdated(entity.getClientNotes().remove(name) != null);
|
||||
}
|
||||
entity.removeClientNote(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getClientNotes() {
|
||||
return new ConcurrentHashMap<>(entity.getClientNotes());
|
||||
Map<String, String> clientNotes = entity.getClientNotes();
|
||||
return clientNotes == null ? Collections.emptyMap() : Collections.unmodifiableMap(clientNotes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearClientNotes() {
|
||||
parent.setUpdated(!entity.getClientNotes().isEmpty());
|
||||
entity.getClientNotes().clear();
|
||||
entity.setClientNotes(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getClientScopes() {
|
||||
return new HashSet<>(entity.getClientScopes());
|
||||
Set<String> clientScopes = entity.getClientScopes();
|
||||
return clientScopes == null ? Collections.emptySet() : Collections.unmodifiableSet(clientScopes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientScopes(Set<String> clientScopes) {
|
||||
Objects.requireNonNull(clientScopes, "The provided client scopes set can't be null!");
|
||||
parent.setUpdated(!Objects.equals(entity.getClientScopes(), clientScopes));
|
||||
entity.setClientScopes(new HashSet<>(clientScopes));
|
||||
entity.setClientScopes(clientScopes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -220,7 +197,6 @@ public class MapAuthenticationSessionAdapter implements AuthenticationSessionMod
|
|||
|
||||
@Override
|
||||
public void setRedirectUri(String uri) {
|
||||
parent.setUpdated(!Objects.equals(entity.getRedirectUri(), uri));
|
||||
entity.setRedirectUri(uri);
|
||||
}
|
||||
|
||||
|
@ -241,7 +217,6 @@ public class MapAuthenticationSessionAdapter implements AuthenticationSessionMod
|
|||
|
||||
@Override
|
||||
public void setAction(String action) {
|
||||
parent.setUpdated(!Objects.equals(entity.getAction(), action));
|
||||
entity.setAction(action);
|
||||
}
|
||||
|
||||
|
@ -252,7 +227,6 @@ public class MapAuthenticationSessionAdapter implements AuthenticationSessionMod
|
|||
|
||||
@Override
|
||||
public void setProtocol(String method) {
|
||||
parent.setUpdated(!Objects.equals(entity.getProtocol(), method));
|
||||
entity.setProtocol(method);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,129 +16,62 @@
|
|||
*/
|
||||
package org.keycloak.models.map.authSession;
|
||||
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.sessions.AuthenticationSessionModel;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mkanis@redhat.com">Martin Kanis</a>
|
||||
*/
|
||||
public class MapAuthenticationSessionEntity {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapAuthenticationSessionEntity extends UpdatableEntity {
|
||||
|
||||
private String clientUUID;
|
||||
Map<String, String> getUserSessionNotes();
|
||||
void setUserSessionNotes(Map<String, String> userSessionNotes);
|
||||
void setUserSessionNote(String name, String value);
|
||||
|
||||
private String authUserId;
|
||||
String getClientUUID();
|
||||
void setClientUUID(String clientUUID);
|
||||
|
||||
private int timestamp;
|
||||
String getAuthUserId();
|
||||
void setAuthUserId(String authUserId);
|
||||
|
||||
private String redirectUri;
|
||||
private String action;
|
||||
private Set<String> clientScopes = new HashSet<>();
|
||||
Integer getTimestamp();
|
||||
void setTimestamp(Integer timestamp);
|
||||
|
||||
private Map<String, AuthenticationSessionModel.ExecutionStatus> executionStatus = new ConcurrentHashMap<>();
|
||||
private String protocol;
|
||||
String getRedirectUri();
|
||||
void setRedirectUri(String redirectUri);
|
||||
|
||||
private Map<String, String> clientNotes= new ConcurrentHashMap<>();;
|
||||
private Map<String, String> authNotes = new ConcurrentHashMap<>();;
|
||||
private Set<String> requiredActions = new HashSet<>();
|
||||
private Map<String, String> userSessionNotes = new ConcurrentHashMap<>();
|
||||
String getAction();
|
||||
void setAction(String action);
|
||||
|
||||
public Map<String, String> getUserSessionNotes() {
|
||||
return userSessionNotes;
|
||||
}
|
||||
Set<String> getClientScopes();
|
||||
void setClientScopes(Set<String> clientScopes);
|
||||
|
||||
public void setUserSessionNotes(Map<String, String> userSessionNotes) {
|
||||
this.userSessionNotes = userSessionNotes;
|
||||
}
|
||||
Set<String> getRequiredActions();
|
||||
void setRequiredActions(Set<String> requiredActions);
|
||||
void addRequiredAction(String requiredAction);
|
||||
void removeRequiredAction(String action);
|
||||
|
||||
public String getClientUUID() {
|
||||
return clientUUID;
|
||||
}
|
||||
String getProtocol();
|
||||
void setProtocol(String protocol);
|
||||
|
||||
public void setClientUUID(String clientUUID) {
|
||||
this.clientUUID = clientUUID;
|
||||
}
|
||||
Map<String, String> getClientNotes();
|
||||
void setClientNotes(Map<String, String> clientNotes);
|
||||
void setClientNote(String name, String value);
|
||||
void removeClientNote(String name);
|
||||
|
||||
public String getAuthUserId() {
|
||||
return authUserId;
|
||||
}
|
||||
Map<String, String> getAuthNotes();
|
||||
void setAuthNotes(Map<String, String> authNotes);
|
||||
void setAuthNote(String name, String value);
|
||||
void removeAuthNote(String name);
|
||||
|
||||
public void setAuthUserId(String authUserId) {
|
||||
this.authUserId = authUserId;
|
||||
}
|
||||
|
||||
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 Set<String> getClientScopes() {
|
||||
return clientScopes;
|
||||
}
|
||||
|
||||
public void setClientScopes(Set<String> clientScopes) {
|
||||
this.clientScopes = clientScopes;
|
||||
}
|
||||
|
||||
public Set<String> getRequiredActions() {
|
||||
return requiredActions;
|
||||
}
|
||||
|
||||
public void setRequiredActions(Set<String> requiredActions) {
|
||||
this.requiredActions = requiredActions;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public Map<String, String> getClientNotes() {
|
||||
return clientNotes;
|
||||
}
|
||||
|
||||
public void setClientNotes(Map<String, String> clientNotes) {
|
||||
this.clientNotes = clientNotes;
|
||||
}
|
||||
|
||||
public Map<String, String> getAuthNotes() {
|
||||
return authNotes;
|
||||
}
|
||||
|
||||
public void setAuthNotes(Map<String, String> authNotes) {
|
||||
this.authNotes = authNotes;
|
||||
}
|
||||
|
||||
public Map<String, AuthenticationSessionModel.ExecutionStatus> getExecutionStatus() {
|
||||
return executionStatus;
|
||||
}
|
||||
|
||||
public void setExecutionStatus(Map<String, AuthenticationSessionModel.ExecutionStatus> executionStatus) {
|
||||
this.executionStatus = executionStatus;
|
||||
}
|
||||
Map<String, AuthenticationSessionModel.ExecutionStatus> getExecutionStatuses();
|
||||
void setExecutionStatuses(Map<String, AuthenticationSessionModel.ExecutionStatus> executionStatus);
|
||||
void setExecutionStatus(String authenticator, AuthenticationSessionModel.ExecutionStatus status);
|
||||
}
|
||||
|
|
|
@ -24,8 +24,10 @@ import org.keycloak.models.KeycloakSession;
|
|||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.sessions.AuthenticationSessionModel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -59,10 +61,9 @@ public class MapRootAuthenticationSessionAdapter extends AbstractRootAuthenticat
|
|||
|
||||
@Override
|
||||
public Map<String, AuthenticationSessionModel> getAuthenticationSessions() {
|
||||
return entity.getAuthenticationSessions().entrySet()
|
||||
.stream()
|
||||
return Optional.ofNullable(entity.getAuthenticationSessions()).orElseGet(Collections::emptyMap).entrySet().stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey,
|
||||
entry -> new MapAuthenticationSessionAdapter(session, this, entry.getKey(), entry.getValue())));
|
||||
entry -> new MapAuthenticationSessionAdapter(session, this, entry.getKey(), (MapAuthenticationSessionEntity) entry.getValue())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,26 +85,27 @@ public class MapRootAuthenticationSessionAdapter extends AbstractRootAuthenticat
|
|||
public AuthenticationSessionModel createAuthenticationSession(ClientModel client) {
|
||||
Objects.requireNonNull(client, "The provided client can't be null!");
|
||||
|
||||
MapAuthenticationSessionEntity authSessionEntity = new MapAuthenticationSessionEntity();
|
||||
MapAuthenticationSessionEntity authSessionEntity = new MapAuthenticationSessionEntityImpl();
|
||||
authSessionEntity.setClientUUID(client.getId());
|
||||
|
||||
int timestamp = Time.currentTime();
|
||||
authSessionEntity.setTimestamp(timestamp);
|
||||
|
||||
String tabId = generateTabId();
|
||||
entity.getAuthenticationSessions().put(tabId, authSessionEntity);
|
||||
entity.setAuthenticationSession(tabId, authSessionEntity);
|
||||
|
||||
// Update our timestamp when adding new authenticationSession
|
||||
entity.setTimestamp(timestamp);
|
||||
|
||||
MapAuthenticationSessionAdapter authSession = new MapAuthenticationSessionAdapter(session, this, tabId, authSessionEntity);
|
||||
MapAuthenticationSessionAdapter authSession = new MapAuthenticationSessionAdapter(session, this, tabId, entity.getAuthenticationSessions().get(tabId));
|
||||
session.getContext().setAuthenticationSession(authSession);
|
||||
return authSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAuthenticationSessionByTabId(String tabId) {
|
||||
if (entity.removeAuthenticationSession(tabId) != null) {
|
||||
Boolean result = entity.removeAuthenticationSession(tabId);
|
||||
if (result == null || result) {
|
||||
if (entity.getAuthenticationSessions().isEmpty()) {
|
||||
session.authenticationSessions().removeRootAuthenticationSession(realm, this);
|
||||
} else {
|
||||
|
@ -114,14 +116,10 @@ public class MapRootAuthenticationSessionAdapter extends AbstractRootAuthenticat
|
|||
|
||||
@Override
|
||||
public void restartSession(RealmModel realm) {
|
||||
entity.clearAuthenticationSessions();
|
||||
entity.setAuthenticationSessions(null);
|
||||
entity.setTimestamp(Time.currentTime());
|
||||
}
|
||||
|
||||
public void setUpdated(boolean updated) {
|
||||
entity.signalUpdated(updated);
|
||||
}
|
||||
|
||||
private String generateTabId() {
|
||||
return Base64Url.encode(SecretGenerator.getInstance().randomBytes(8));
|
||||
}
|
||||
|
|
|
@ -16,89 +16,62 @@
|
|||
*/
|
||||
package org.keycloak.models.map.authSession;
|
||||
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mkanis@redhat.com">Martin Kanis</a>
|
||||
*/
|
||||
public class MapRootAuthenticationSessionEntity extends UpdatableEntity.Impl implements AbstractEntity {
|
||||
@GenerateEntityImplementations(
|
||||
inherits = "org.keycloak.models.map.authSession.MapRootAuthenticationSessionEntity.AbstractRootAuthenticationSessionEntity"
|
||||
)
|
||||
@DeepCloner.Root
|
||||
public interface MapRootAuthenticationSessionEntity extends AbstractEntity, UpdatableEntity {
|
||||
|
||||
private String id;
|
||||
private String realmId;
|
||||
public abstract class AbstractRootAuthenticationSessionEntity extends UpdatableEntity.Impl implements MapRootAuthenticationSessionEntity {
|
||||
|
||||
/**
|
||||
* Flag signalizing that any of the setters has been meaningfully used.
|
||||
*/
|
||||
private int timestamp;
|
||||
private Map<String, MapAuthenticationSessionEntity> authenticationSessions = new ConcurrentHashMap<>();
|
||||
private String id;
|
||||
|
||||
public MapRootAuthenticationSessionEntity() {}
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public MapRootAuthenticationSessionEntity(String id, String realmId) {
|
||||
this.id = id;
|
||||
this.realmId = realmId;
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
if (this.id != null) throw new IllegalStateException("Id cannot be changed");
|
||||
this.id = id;
|
||||
this.updated |= id != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdated() {
|
||||
return this.updated ||
|
||||
Optional.ofNullable(getAuthenticationSessions()).orElseGet(Collections::emptyMap).values().stream().anyMatch(MapAuthenticationSessionEntity::isUpdated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearUpdatedFlag() {
|
||||
this.updated = false;
|
||||
Optional.ofNullable(getAuthenticationSessions()).orElseGet(Collections::emptyMap).values().forEach(UpdatableEntity::clearUpdatedFlag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
String getRealmId();
|
||||
void setRealmId(String realmId);
|
||||
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
if (this.id != null) throw new IllegalStateException("Id cannot be changed");
|
||||
this.id = id;
|
||||
this.updated |= id != null;
|
||||
}
|
||||
Integer getTimestamp();
|
||||
void setTimestamp(Integer timestamp);
|
||||
|
||||
public String getRealmId() {
|
||||
return realmId;
|
||||
}
|
||||
|
||||
public void setRealmId(String realmId) {
|
||||
this.updated |= !Objects.equals(this.realmId, realmId);
|
||||
this.realmId = realmId;
|
||||
}
|
||||
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(int timestamp) {
|
||||
this.updated |= !Objects.equals(this.timestamp, timestamp);
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public Map<String, MapAuthenticationSessionEntity> getAuthenticationSessions() {
|
||||
return authenticationSessions;
|
||||
}
|
||||
|
||||
public void setAuthenticationSessions(Map<String, MapAuthenticationSessionEntity> authenticationSessions) {
|
||||
this.updated |= !Objects.equals(this.authenticationSessions, authenticationSessions);
|
||||
this.authenticationSessions = authenticationSessions;
|
||||
}
|
||||
|
||||
public MapAuthenticationSessionEntity removeAuthenticationSession(String tabId) {
|
||||
MapAuthenticationSessionEntity entity = this.authenticationSessions.remove(tabId);
|
||||
this.updated |= entity != null;
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void addAuthenticationSession(String tabId, MapAuthenticationSessionEntity entity) {
|
||||
this.updated |= !Objects.equals(this.authenticationSessions.put(tabId, entity), entity);
|
||||
}
|
||||
|
||||
public void clearAuthenticationSessions() {
|
||||
this.updated |= !this.authenticationSessions.isEmpty();
|
||||
this.authenticationSessions.clear();
|
||||
}
|
||||
|
||||
void signalUpdated(boolean updated) {
|
||||
this.updated |= updated;
|
||||
}
|
||||
Map<String, MapAuthenticationSessionEntity> getAuthenticationSessions();
|
||||
void setAuthenticationSessions(Map<String, MapAuthenticationSessionEntity> authenticationSessions);
|
||||
void setAuthenticationSession(String tabId, MapAuthenticationSessionEntity entity);
|
||||
Boolean removeAuthenticationSession(String tabId);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,9 @@ public class MapRootAuthenticationSessionProvider implements AuthenticationSessi
|
|||
LOG.tracef("createRootAuthenticationSession(%s)%s", realm.getName(), getShortStackTrace());
|
||||
|
||||
// create map authentication session entity
|
||||
MapRootAuthenticationSessionEntity entity = new MapRootAuthenticationSessionEntity(id, realm.getId());
|
||||
MapRootAuthenticationSessionEntity entity = new MapRootAuthenticationSessionEntityImpl();
|
||||
entity.setId(id);
|
||||
entity.setRealmId(realm.getId());
|
||||
entity.setTimestamp(Time.currentTime());
|
||||
|
||||
if (id != null && tx.read(id) != null) {
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
*/
|
||||
package org.keycloak.models.map.storage.chm;
|
||||
|
||||
import org.keycloak.models.map.authSession.MapAuthenticationSessionEntity;
|
||||
import org.keycloak.models.map.authSession.MapAuthenticationSessionEntityImpl;
|
||||
import org.keycloak.models.map.authSession.MapRootAuthenticationSessionEntity;
|
||||
import org.keycloak.models.map.authSession.MapRootAuthenticationSessionEntityImpl;
|
||||
import org.keycloak.models.map.authorization.entity.MapPermissionTicketEntity;
|
||||
import org.keycloak.models.map.authorization.entity.MapPermissionTicketEntityImpl;
|
||||
import org.keycloak.models.map.authorization.entity.MapPolicyEntity;
|
||||
|
@ -122,6 +126,8 @@ public class ConcurrentHashMapStorageProviderFactory implements AmphibianProvide
|
|||
.constructor(MapRequiredActionProviderEntity.class, MapRequiredActionProviderEntityImpl::new)
|
||||
.constructor(MapRequiredCredentialEntity.class, MapRequiredCredentialEntityImpl::new)
|
||||
.constructor(MapWebAuthnPolicyEntity.class, MapWebAuthnPolicyEntityImpl::new)
|
||||
.constructor(MapRootAuthenticationSessionEntity.class, MapRootAuthenticationSessionEntityImpl::new)
|
||||
.constructor(MapAuthenticationSessionEntity.class, MapAuthenticationSessionEntityImpl::new)
|
||||
.build();
|
||||
|
||||
private static final Map<String, StringKeyConvertor> KEY_CONVERTORS = new HashMap<>();
|
||||
|
|
Loading…
Reference in a new issue