Merge pull request #4105 from patriot1burke/master

KEYCLOAK-4821
This commit is contained in:
Bill Burke authored and GitHub committed 2017-04-29 18:01:43 -04:00
commit 93ef2ec9bf
3 files changed
+12 -13

No files matched your search

@@ -478,9 +478,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
void attachSession(UserSessionAdapter userSession, ClientSessionModel clientSession) { void attachSession(UserSessionAdapter userSession, ClientSessionModel clientSession) {
UserSessionEntity entity = userSession.getEntity(); UserSessionEntity entity = userSession.getEntity();
String clientSessionId = clientSession.getId(); String clientSessionId = clientSession.getId();
if (entity.getClientSessions() == null) {
entity.setClientSessions(new HashSet<String>());
}
if (!entity.getClientSessions().contains(clientSessionId)) { if (!entity.getClientSessions().contains(clientSessionId)) {
entity.getClientSessions().add(clientSessionId); entity.getClientSessions().add(clientSessionId);
userSession.update(); userSession.update();
@@ -513,9 +510,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
String clientSessionId = clientSession.getId(); String clientSessionId = clientSession.getId();
if (entity.getClientSessions() != null && entity.getClientSessions().contains(clientSessionId)) { if (entity.getClientSessions() != null && entity.getClientSessions().contains(clientSessionId)) {
entity.getClientSessions().remove(clientSessionId); entity.getClientSessions().remove(clientSessionId);
if (entity.getClientSessions().isEmpty()) {
entity.setClientSessions(null);
}
userSession.update(); userSession.update();
} }
} }
@@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a> * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
@@ -121,7 +122,13 @@ public class UserSessionAdapter implements UserSessionModel {
@Override @Override
public void setNote(String name, String value) { public void setNote(String name, String value) {
if (entity.getNotes() == null) { if (entity.getNotes() == null) {
entity.setNotes(new HashMap<String, String>()); entity.setNotes(new ConcurrentHashMap<>());
}
if (value == null) {
if (entity.getNotes().containsKey(name)) {
removeNote(name);
}
return;
} }
entity.getNotes().put(name, value); entity.getNotes().put(name, value);
update(); update();
@@ -21,6 +21,8 @@ import org.keycloak.models.UserSessionModel;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
/** /**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a> * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
@@ -44,11 +46,11 @@ public class UserSessionEntity extends SessionEntity {
private int lastSessionRefresh; private int lastSessionRefresh;
private Set<String> clientSessions; private Set<String> clientSessions = new CopyOnWriteArraySet<>();
private UserSessionModel.State state; private UserSessionModel.State state;
private Map<String, String> notes; private Map<String, String> notes = new ConcurrentHashMap<>();
public String getUser() { public String getUser() {
return user; return user;
@@ -110,10 +112,6 @@ public class UserSessionEntity extends SessionEntity {
return clientSessions; return clientSessions;
} }
public void setClientSessions(Set<String> clientSessions) {
this.clientSessions = clientSessions;
}
public Map<String, String> getNotes() { public Map<String, String> getNotes() {
return notes; return notes;
} }