KEYCLOAK-5688 Externalizers for cluster messages and predicates
This commit is contained in:
parent
73ba06b26b
commit
faf830dc77
48 changed files with 1821 additions and 17 deletions
|
@ -18,10 +18,17 @@
|
|||
package org.keycloak.cluster.infinispan;
|
||||
|
||||
import org.keycloak.cluster.ClusterEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(WrapperClusterEvent.ExternalizerImpl.class)
|
||||
public class WrapperClusterEvent implements ClusterEvent {
|
||||
|
||||
private String eventKey;
|
||||
|
@ -83,4 +90,46 @@ public class WrapperClusterEvent implements ClusterEvent {
|
|||
public String toString() {
|
||||
return String.format("WrapperClusterEvent [ eventKey=%s, sender=%s, senderSite=%s, delegateEvent=%s ]", eventKey, sender, senderSite, delegateEvent.toString());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<WrapperClusterEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, WrapperClusterEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.eventKey, output);
|
||||
MarshallUtil.marshallString(obj.sender, output);
|
||||
MarshallUtil.marshallString(obj.senderSite, output);
|
||||
output.writeBoolean(obj.ignoreSender);
|
||||
output.writeBoolean(obj.ignoreSenderSite);
|
||||
|
||||
output.writeObject(obj.delegateEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrapperClusterEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public WrapperClusterEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
WrapperClusterEvent res = new WrapperClusterEvent();
|
||||
|
||||
res.eventKey = MarshallUtil.unmarshallString(input);
|
||||
res.sender = MarshallUtil.unmarshallString(input);
|
||||
res.senderSite = MarshallUtil.unmarshallString(input);
|
||||
res.ignoreSender = input.readBoolean();
|
||||
res.ignoreSenderSite = input.readBoolean();
|
||||
|
||||
res.delegateEvent = (ClusterEvent) input.readObject();
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,17 @@
|
|||
package org.keycloak.keys.infinispan;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(PublicKeyStorageInvalidationEvent.ExternalizerImpl.class)
|
||||
public class PublicKeyStorageInvalidationEvent extends InvalidationEvent {
|
||||
|
||||
private String cacheKey;
|
||||
|
@ -45,4 +52,34 @@ public class PublicKeyStorageInvalidationEvent extends InvalidationEvent {
|
|||
public String toString() {
|
||||
return "PublicKeyStorageInvalidationEvent [ " + cacheKey + " ]";
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<PublicKeyStorageInvalidationEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, PublicKeyStorageInvalidationEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.cacheKey, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKeyStorageInvalidationEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public PublicKeyStorageInvalidationEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
PublicKeyStorageInvalidationEvent res = new PublicKeyStorageInvalidationEvent();
|
||||
res.cacheKey = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,10 +21,19 @@ import java.util.Set;
|
|||
|
||||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.HashSet;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(PolicyRemovedEvent.ExternalizerImpl.class)
|
||||
public class PolicyRemovedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
|
@ -59,4 +68,43 @@ public class PolicyRemovedEvent extends InvalidationEvent implements Authorizati
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.policyRemoval(id, name, resources, resourceTypes, scopes, serverId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<PolicyRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, PolicyRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
MarshallUtil.marshallString(obj.name, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.scopes, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.resources, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.resourceTypes, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
MarshallUtil.marshallString(obj.serverId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public PolicyRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
PolicyRemovedEvent res = new PolicyRemovedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
res.name = MarshallUtil.unmarshallString(input);
|
||||
res.scopes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.resources = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.resourceTypes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.serverId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,16 +20,25 @@ package org.keycloak.models.cache.infinispan.authorization.events;
|
|||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(PolicyUpdatedEvent.ExternalizerImpl.class)
|
||||
public class PolicyUpdatedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private static Set<String> resources;
|
||||
private Set<String> resources;
|
||||
private Set<String> resourceTypes;
|
||||
private Set<String> scopes;
|
||||
private String serverId;
|
||||
|
@ -59,4 +68,43 @@ public class PolicyUpdatedEvent extends InvalidationEvent implements Authorizati
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.policyUpdated(id, name, resources, resourceTypes, scopes, serverId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<PolicyUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, PolicyUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
MarshallUtil.marshallString(obj.name, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.resources, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.resourceTypes, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.scopes, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
MarshallUtil.marshallString(obj.serverId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public PolicyUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
PolicyUpdatedEvent res = new PolicyUpdatedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
res.name = MarshallUtil.unmarshallString(input);
|
||||
res.resources = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.resourceTypes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.scopes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.serverId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,20 @@ package org.keycloak.models.cache.infinispan.authorization.events;
|
|||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ResourceRemovedEvent.ExternalizerImpl.class)
|
||||
public class ResourceRemovedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
|
@ -61,4 +70,45 @@ public class ResourceRemovedEvent extends InvalidationEvent implements Authoriza
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.resourceRemoval(id, name, type, uri, owner, scopes, serverId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ResourceRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ResourceRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
MarshallUtil.marshallString(obj.name, output);
|
||||
MarshallUtil.marshallString(obj.type, output);
|
||||
MarshallUtil.marshallString(obj.uri, output);
|
||||
MarshallUtil.marshallString(obj.owner, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.scopes, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
MarshallUtil.marshallString(obj.serverId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ResourceRemovedEvent res = new ResourceRemovedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
res.name = MarshallUtil.unmarshallString(input);
|
||||
res.type = MarshallUtil.unmarshallString(input);
|
||||
res.uri = MarshallUtil.unmarshallString(input);
|
||||
res.owner = MarshallUtil.unmarshallString(input);
|
||||
res.scopes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.serverId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,18 @@ package org.keycloak.models.cache.infinispan.authorization.events;
|
|||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Set;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ResourceServerRemovedEvent.ExternalizerImpl.class)
|
||||
public class ResourceServerRemovedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
|
@ -51,4 +58,35 @@ public class ResourceServerRemovedEvent extends InvalidationEvent implements Aut
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.resourceServerRemoval(id, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ResourceServerRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ResourceServerRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
MarshallUtil.marshallString(obj.clientId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceServerRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceServerRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ResourceServerRemovedEvent res = new ResourceServerRemovedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
res.clientId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,18 @@ package org.keycloak.models.cache.infinispan.authorization.events;
|
|||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Set;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ResourceServerUpdatedEvent.ExternalizerImpl.class)
|
||||
public class ResourceServerUpdatedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
|
@ -49,4 +56,33 @@ public class ResourceServerUpdatedEvent extends InvalidationEvent implements Aut
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.resourceServerUpdated(id, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ResourceServerUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ResourceServerUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceServerUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceServerUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ResourceServerUpdatedEvent res = new ResourceServerUpdatedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,20 @@ package org.keycloak.models.cache.infinispan.authorization.events;
|
|||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ResourceUpdatedEvent.ExternalizerImpl.class)
|
||||
public class ResourceUpdatedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
|
@ -61,4 +70,45 @@ public class ResourceUpdatedEvent extends InvalidationEvent implements Authoriza
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.resourceUpdated(id, name, type, uri, scopes, serverId, owner, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ResourceUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ResourceUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
MarshallUtil.marshallString(obj.name, output);
|
||||
MarshallUtil.marshallString(obj.type, output);
|
||||
MarshallUtil.marshallString(obj.uri, output);
|
||||
KeycloakMarshallUtil.writeCollection(obj.scopes, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
MarshallUtil.marshallString(obj.serverId, output);
|
||||
MarshallUtil.marshallString(obj.owner, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ResourceUpdatedEvent res = new ResourceUpdatedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
res.name = MarshallUtil.unmarshallString(input);
|
||||
res.type = MarshallUtil.unmarshallString(input);
|
||||
res.uri = MarshallUtil.unmarshallString(input);
|
||||
res.scopes = KeycloakMarshallUtil.readCollection(input, KeycloakMarshallUtil.STRING_EXT, HashSet::new);
|
||||
res.serverId = MarshallUtil.unmarshallString(input);
|
||||
res.owner = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,18 @@ package org.keycloak.models.cache.infinispan.authorization.events;
|
|||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Set;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ScopeRemovedEvent.ExternalizerImpl.class)
|
||||
public class ScopeRemovedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
|
@ -53,4 +60,37 @@ public class ScopeRemovedEvent extends InvalidationEvent implements Authorizatio
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.scopeRemoval(id, name, serverId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ScopeRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ScopeRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
MarshallUtil.marshallString(obj.name, output);
|
||||
MarshallUtil.marshallString(obj.serverId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScopeRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ScopeRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ScopeRemovedEvent res = new ScopeRemovedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
res.name = MarshallUtil.unmarshallString(input);
|
||||
res.serverId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,18 @@ package org.keycloak.models.cache.infinispan.authorization.events;
|
|||
import org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager;
|
||||
import org.keycloak.models.cache.infinispan.events.InvalidationEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Set;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ScopeUpdatedEvent.ExternalizerImpl.class)
|
||||
public class ScopeUpdatedEvent extends InvalidationEvent implements AuthorizationCacheInvalidationEvent {
|
||||
|
||||
private String id;
|
||||
|
@ -53,4 +60,37 @@ public class ScopeUpdatedEvent extends InvalidationEvent implements Authorizatio
|
|||
public void addInvalidations(StoreFactoryCacheManager cache, Set<String> invalidations) {
|
||||
cache.scopeUpdated(id, name, serverId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ScopeUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ScopeUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.id, output);
|
||||
MarshallUtil.marshallString(obj.name, output);
|
||||
MarshallUtil.marshallString(obj.serverId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScopeUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ScopeUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ScopeUpdatedEvent res = new ScopeUpdatedEvent();
|
||||
res.id = MarshallUtil.unmarshallString(input);
|
||||
res.name = MarshallUtil.unmarshallString(input);
|
||||
res.serverId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,17 @@ import java.util.function.Predicate;
|
|||
|
||||
import org.keycloak.models.cache.infinispan.authorization.entities.InResource;
|
||||
import org.keycloak.models.cache.infinispan.entities.Revisioned;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
||||
*/
|
||||
@SerializeWith(InResourcePredicate.ExternalizerImpl.class)
|
||||
public class InResourcePredicate implements Predicate<Map.Entry<String, Revisioned>>, Serializable {
|
||||
|
||||
private String resourceId;
|
||||
|
@ -47,4 +54,33 @@ public class InResourcePredicate implements Predicate<Map.Entry<String, Revision
|
|||
|
||||
return resourceId.equals(((InResource)value).getResourceId());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<InResourcePredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, InResourcePredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.resourceId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InResourcePredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public InResourcePredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
InResourcePredicate res = new InResourcePredicate();
|
||||
res.resourceId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,21 @@ package org.keycloak.models.cache.infinispan.authorization.stream;
|
|||
import org.keycloak.models.cache.infinispan.authorization.entities.InResourceServer;
|
||||
import org.keycloak.models.cache.infinispan.entities.Revisioned;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@SerializeWith(InResourceServerPredicate.ExternalizerImpl.class)
|
||||
public class InResourceServerPredicate implements Predicate<Map.Entry<String, Revisioned>>, Serializable {
|
||||
private String serverId;
|
||||
|
||||
|
@ -31,4 +38,33 @@ public class InResourceServerPredicate implements Predicate<Map.Entry<String, Re
|
|||
|
||||
return serverId.equals(((InResourceServer)value).getResourceServerId());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<InResourceServerPredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, InResourceServerPredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.serverId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InResourceServerPredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public InResourceServerPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
InResourceServerPredicate res = new InResourceServerPredicate();
|
||||
res.serverId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,18 @@ import java.util.function.Predicate;
|
|||
|
||||
import org.keycloak.models.cache.infinispan.authorization.entities.InScope;
|
||||
import org.keycloak.models.cache.infinispan.entities.Revisioned;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@SerializeWith(InScopePredicate.ExternalizerImpl.class)
|
||||
public class InScopePredicate implements Predicate<Map.Entry<String, Revisioned>>, Serializable {
|
||||
private String scopeId;
|
||||
|
||||
|
@ -31,4 +38,33 @@ public class InScopePredicate implements Predicate<Map.Entry<String, Revisioned>
|
|||
|
||||
return scopeId.equals(((InScope)value).getScopeId());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<InScopePredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, InScopePredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.scopeId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InScopePredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public InScopePredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
InScopePredicate res = new InScopePredicate();
|
||||
res.scopeId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class AuthenticationSessionAuthNoteUpdateEvent implements ClusterEvent {
|
|||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, AuthenticationSessionAuthNoteUpdateEvent value) throws IOException {
|
||||
output.write(VERSION_1);
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(value.authSessionId, output);
|
||||
MarshallUtil.marshallMap(value.authNotesFragment, output);
|
||||
|
@ -89,7 +89,7 @@ public class AuthenticationSessionAuthNoteUpdateEvent implements ClusterEvent {
|
|||
public AuthenticationSessionAuthNoteUpdateEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
return create(
|
||||
MarshallUtil.unmarshallString(input),
|
||||
MarshallUtil.unmarshallMap(input, (size) -> new HashMap<>(size))
|
||||
MarshallUtil.unmarshallMap(input, HashMap::new)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ClientAddedEvent.ExternalizerImpl.class)
|
||||
public class ClientAddedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String clientUuid;
|
||||
|
@ -52,4 +59,37 @@ public class ClientAddedEvent extends InvalidationEvent implements RealmCacheInv
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.clientAdded(realmId, clientUuid, clientId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ClientAddedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ClientAddedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.clientUuid, output);
|
||||
MarshallUtil.marshallString(obj.clientId, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientAddedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ClientAddedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ClientAddedEvent res = new ClientAddedEvent();
|
||||
res.clientUuid = MarshallUtil.unmarshallString(input);
|
||||
res.clientId = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,19 @@ import java.util.Set;
|
|||
import org.keycloak.models.ClientModel;
|
||||
import org.keycloak.models.RoleModel;
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ClientRemovedEvent.ExternalizerImpl.class)
|
||||
public class ClientRemovedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String clientUuid;
|
||||
|
@ -71,4 +80,40 @@ public class ClientRemovedEvent extends InvalidationEvent implements RealmCacheI
|
|||
realmCache.roleRemoval(roleId, roleName, clientUuid, invalidations);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ClientRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ClientRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.clientUuid, output);
|
||||
MarshallUtil.marshallString(obj.clientId, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
KeycloakMarshallUtil.writeMap(obj.clientRoles, KeycloakMarshallUtil.STRING_EXT, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ClientRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ClientRemovedEvent res = new ClientRemovedEvent();
|
||||
res.clientUuid = MarshallUtil.unmarshallString(input);
|
||||
res.clientId = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
res.clientRoles = KeycloakMarshallUtil.readMap(input, KeycloakMarshallUtil.STRING_EXT, KeycloakMarshallUtil.STRING_EXT,
|
||||
size -> new ConcurrentHashMap<>(size));
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ClientTemplateEvent.ExternalizerImpl.class)
|
||||
public class ClientTemplateEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String clientTemplateId;
|
||||
|
@ -49,4 +56,33 @@ public class ClientTemplateEvent extends InvalidationEvent implements RealmCache
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
// Nothing. ID was already invalidated
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ClientTemplateEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ClientTemplateEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.clientTemplateId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientTemplateEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ClientTemplateEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ClientTemplateEvent res = new ClientTemplateEvent();
|
||||
res.clientTemplateId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ClientUpdatedEvent.ExternalizerImpl.class)
|
||||
public class ClientUpdatedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String clientUuid;
|
||||
|
@ -52,4 +59,37 @@ public class ClientUpdatedEvent extends InvalidationEvent implements RealmCacheI
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.clientUpdated(realmId, clientUuid, clientId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ClientUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ClientUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.clientUuid, output);
|
||||
MarshallUtil.marshallString(obj.clientId, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ClientUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ClientUpdatedEvent res = new ClientUpdatedEvent();
|
||||
res.clientUuid = MarshallUtil.unmarshallString(input);
|
||||
res.clientId = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,18 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(GroupAddedEvent.ExternalizerImpl.class)
|
||||
public class GroupAddedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String groupId;
|
||||
|
@ -51,4 +58,35 @@ public class GroupAddedEvent extends InvalidationEvent implements RealmCacheInva
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.groupQueriesInvalidations(realmId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<GroupAddedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, GroupAddedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.groupId, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupAddedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public GroupAddedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
GroupAddedEvent res = new GroupAddedEvent();
|
||||
res.groupId = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,17 @@ import java.util.Set;
|
|||
|
||||
import org.keycloak.models.GroupModel;
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(GroupMovedEvent.ExternalizerImpl.class)
|
||||
public class GroupMovedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String groupId;
|
||||
|
@ -61,4 +68,39 @@ public class GroupMovedEvent extends InvalidationEvent implements RealmCacheInva
|
|||
invalidations.add(oldParentId);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<GroupMovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, GroupMovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.groupId, output);
|
||||
MarshallUtil.marshallString(obj.newParentId, output);
|
||||
MarshallUtil.marshallString(obj.oldParentId, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupMovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public GroupMovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
GroupMovedEvent res = new GroupMovedEvent();
|
||||
res.groupId = MarshallUtil.unmarshallString(input);
|
||||
res.newParentId = MarshallUtil.unmarshallString(input);
|
||||
res.oldParentId = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,17 @@ import java.util.Set;
|
|||
|
||||
import org.keycloak.models.GroupModel;
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(GroupRemovedEvent.ExternalizerImpl.class)
|
||||
public class GroupRemovedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String groupId;
|
||||
|
@ -56,4 +63,37 @@ public class GroupRemovedEvent extends InvalidationEvent implements RealmCacheIn
|
|||
invalidations.add(parentId);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<GroupRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, GroupRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
MarshallUtil.marshallString(obj.groupId, output);
|
||||
MarshallUtil.marshallString(obj.parentId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public GroupRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
GroupRemovedEvent res = new GroupRemovedEvent();
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
res.groupId = MarshallUtil.unmarshallString(input);
|
||||
res.parentId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(GroupUpdatedEvent.ExternalizerImpl.class)
|
||||
public class GroupUpdatedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String groupId;
|
||||
|
@ -49,4 +56,33 @@ public class GroupUpdatedEvent extends InvalidationEvent implements RealmCacheIn
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
// Nothing. ID already invalidated
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<GroupUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, GroupUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.groupId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public GroupUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
GroupUpdatedEvent res = new GroupUpdatedEvent();
|
||||
res.groupId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RealmRemovedEvent.ExternalizerImpl.class)
|
||||
public class RealmRemovedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String realmId;
|
||||
|
@ -50,4 +57,35 @@ public class RealmRemovedEvent extends InvalidationEvent implements RealmCacheIn
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.realmRemoval(realmId, realmName, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RealmRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RealmRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
MarshallUtil.marshallString(obj.realmName, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RealmRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RealmRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RealmRemovedEvent res = new RealmRemovedEvent();
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
res.realmName = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RealmUpdatedEvent.ExternalizerImpl.class)
|
||||
public class RealmUpdatedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String realmId;
|
||||
|
@ -50,4 +57,35 @@ public class RealmUpdatedEvent extends InvalidationEvent implements RealmCacheIn
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.realmUpdated(realmId, realmName, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RealmUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RealmUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
MarshallUtil.marshallString(obj.realmName, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RealmUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RealmUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RealmUpdatedEvent res = new RealmUpdatedEvent();
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
res.realmName = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RoleAddedEvent.ExternalizerImpl.class)
|
||||
public class RoleAddedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String roleId;
|
||||
|
@ -50,4 +57,35 @@ public class RoleAddedEvent extends InvalidationEvent implements RealmCacheInval
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.roleAdded(containerId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RoleAddedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RoleAddedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.roleId, output);
|
||||
MarshallUtil.marshallString(obj.containerId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleAddedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RoleAddedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RoleAddedEvent res = new RoleAddedEvent();
|
||||
res.roleId = MarshallUtil.unmarshallString(input);
|
||||
res.containerId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RoleRemovedEvent.ExternalizerImpl.class)
|
||||
public class RoleRemovedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String roleId;
|
||||
|
@ -52,4 +59,37 @@ public class RoleRemovedEvent extends InvalidationEvent implements RealmCacheInv
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.roleRemoval(roleId, roleName, containerId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RoleRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RoleRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.roleId, output);
|
||||
MarshallUtil.marshallString(obj.roleName, output);
|
||||
MarshallUtil.marshallString(obj.containerId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RoleRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RoleRemovedEvent res = new RoleRemovedEvent();
|
||||
res.roleId = MarshallUtil.unmarshallString(input);
|
||||
res.roleName = MarshallUtil.unmarshallString(input);
|
||||
res.containerId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.RealmCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RoleUpdatedEvent.ExternalizerImpl.class)
|
||||
public class RoleUpdatedEvent extends InvalidationEvent implements RealmCacheInvalidationEvent {
|
||||
|
||||
private String roleId;
|
||||
|
@ -52,4 +59,37 @@ public class RoleUpdatedEvent extends InvalidationEvent implements RealmCacheInv
|
|||
public void addInvalidations(RealmCacheManager realmCache, Set<String> invalidations) {
|
||||
realmCache.roleUpdated(containerId, roleName, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RoleUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RoleUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.roleId, output);
|
||||
MarshallUtil.marshallString(obj.roleName, output);
|
||||
MarshallUtil.marshallString(obj.containerId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RoleUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RoleUpdatedEvent res = new RoleUpdatedEvent();
|
||||
res.roleId = MarshallUtil.unmarshallString(input);
|
||||
res.roleName = MarshallUtil.unmarshallString(input);
|
||||
res.containerId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.UserCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(UserCacheRealmInvalidationEvent.ExternalizerImpl.class)
|
||||
public class UserCacheRealmInvalidationEvent extends InvalidationEvent implements UserCacheInvalidationEvent {
|
||||
|
||||
private String realmId;
|
||||
|
@ -48,4 +55,33 @@ public class UserCacheRealmInvalidationEvent extends InvalidationEvent implemen
|
|||
public void addInvalidations(UserCacheManager userCache, Set<String> invalidations) {
|
||||
userCache.invalidateRealmUsers(realmId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserCacheRealmInvalidationEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserCacheRealmInvalidationEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserCacheRealmInvalidationEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserCacheRealmInvalidationEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserCacheRealmInvalidationEvent res = new UserCacheRealmInvalidationEvent();
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.UserCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(UserConsentsUpdatedEvent.ExternalizerImpl.class)
|
||||
public class UserConsentsUpdatedEvent extends InvalidationEvent implements UserCacheInvalidationEvent {
|
||||
|
||||
private String userId;
|
||||
|
@ -48,4 +55,33 @@ public class UserConsentsUpdatedEvent extends InvalidationEvent implements UserC
|
|||
public void addInvalidations(UserCacheManager userCache, Set<String> invalidations) {
|
||||
userCache.consentInvalidation(userId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserConsentsUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserConsentsUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.userId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserConsentsUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserConsentsUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserConsentsUpdatedEvent res = new UserConsentsUpdatedEvent();
|
||||
res.userId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,17 @@ import java.util.Set;
|
|||
|
||||
import org.keycloak.models.FederatedIdentityModel;
|
||||
import org.keycloak.models.cache.infinispan.UserCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(UserFederationLinkRemovedEvent.ExternalizerImpl.class)
|
||||
public class UserFederationLinkRemovedEvent extends InvalidationEvent implements UserCacheInvalidationEvent {
|
||||
|
||||
private String userId;
|
||||
|
@ -69,4 +76,39 @@ public class UserFederationLinkRemovedEvent extends InvalidationEvent implements
|
|||
public void addInvalidations(UserCacheManager userCache, Set<String> invalidations) {
|
||||
userCache.federatedIdentityLinkRemovedInvalidation(userId, realmId, identityProviderId, socialUserId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserFederationLinkRemovedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserFederationLinkRemovedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.userId, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
MarshallUtil.marshallString(obj.identityProviderId, output);
|
||||
MarshallUtil.marshallString(obj.socialUserId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFederationLinkRemovedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserFederationLinkRemovedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserFederationLinkRemovedEvent res = new UserFederationLinkRemovedEvent();
|
||||
res.userId = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
res.identityProviderId = MarshallUtil.unmarshallString(input);
|
||||
res.socialUserId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.UserCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(UserFederationLinkUpdatedEvent.ExternalizerImpl.class)
|
||||
public class UserFederationLinkUpdatedEvent extends InvalidationEvent implements UserCacheInvalidationEvent {
|
||||
|
||||
private String userId;
|
||||
|
@ -47,4 +54,33 @@ public class UserFederationLinkUpdatedEvent extends InvalidationEvent implements
|
|||
public void addInvalidations(UserCacheManager userCache, Set<String> invalidations) {
|
||||
userCache.federatedIdentityLinkUpdatedInvalidation(userId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserFederationLinkUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserFederationLinkUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.userId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFederationLinkUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserFederationLinkUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserFederationLinkUpdatedEvent res = new UserFederationLinkUpdatedEvent();
|
||||
res.userId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,12 +24,20 @@ import java.util.Set;
|
|||
|
||||
import org.keycloak.models.FederatedIdentityModel;
|
||||
import org.keycloak.models.cache.infinispan.UserCacheManager;
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* Used when user added/removed
|
||||
*
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(UserFullInvalidationEvent.ExternalizerImpl.class)
|
||||
public class UserFullInvalidationEvent extends InvalidationEvent implements UserCacheInvalidationEvent {
|
||||
|
||||
private String userId;
|
||||
|
@ -75,4 +83,43 @@ public class UserFullInvalidationEvent extends InvalidationEvent implements User
|
|||
public void addInvalidations(UserCacheManager userCache, Set<String> invalidations) {
|
||||
userCache.fullUserInvalidation(userId, username, email, realmId, identityFederationEnabled, federatedIdentities, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserFullInvalidationEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserFullInvalidationEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.userId, output);
|
||||
MarshallUtil.marshallString(obj.username, output);
|
||||
MarshallUtil.marshallString(obj.email, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
output.writeBoolean(obj.identityFederationEnabled);
|
||||
KeycloakMarshallUtil.writeMap(obj.federatedIdentities, KeycloakMarshallUtil.STRING_EXT, KeycloakMarshallUtil.STRING_EXT, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFullInvalidationEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserFullInvalidationEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserFullInvalidationEvent res = new UserFullInvalidationEvent();
|
||||
res.userId = MarshallUtil.unmarshallString(input);
|
||||
res.username = MarshallUtil.unmarshallString(input);
|
||||
res.email = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
res.identityFederationEnabled = input.readBoolean();
|
||||
res.federatedIdentities = KeycloakMarshallUtil.readMap(input, KeycloakMarshallUtil.STRING_EXT, KeycloakMarshallUtil.STRING_EXT, HashMap::new);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ package org.keycloak.models.cache.infinispan.events;
|
|||
import java.util.Set;
|
||||
|
||||
import org.keycloak.models.cache.infinispan.UserCacheManager;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(UserUpdatedEvent.ExternalizerImpl.class)
|
||||
public class UserUpdatedEvent extends InvalidationEvent implements UserCacheInvalidationEvent {
|
||||
|
||||
private String userId;
|
||||
|
@ -54,4 +61,39 @@ public class UserUpdatedEvent extends InvalidationEvent implements UserCacheInva
|
|||
public void addInvalidations(UserCacheManager userCache, Set<String> invalidations) {
|
||||
userCache.userUpdatedInvalidations(userId, username, email, realmId, invalidations);
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserUpdatedEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserUpdatedEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.userId, output);
|
||||
MarshallUtil.marshallString(obj.username, output);
|
||||
MarshallUtil.marshallString(obj.email, output);
|
||||
MarshallUtil.marshallString(obj.realmId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserUpdatedEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserUpdatedEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserUpdatedEvent res = new UserUpdatedEvent();
|
||||
res.userId = MarshallUtil.unmarshallString(input);
|
||||
res.username = MarshallUtil.unmarshallString(input);
|
||||
res.email = MarshallUtil.unmarshallString(input);
|
||||
res.realmId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,21 @@ package org.keycloak.models.cache.infinispan.stream;
|
|||
import org.keycloak.models.cache.infinispan.entities.GroupListQuery;
|
||||
import org.keycloak.models.cache.infinispan.entities.Revisioned;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@SerializeWith(GroupListPredicate.ExternalizerImpl.class)
|
||||
public class GroupListPredicate implements Predicate<Map.Entry<String, Revisioned>>, Serializable {
|
||||
private String realm;
|
||||
|
||||
|
@ -33,4 +40,33 @@ public class GroupListPredicate implements Predicate<Map.Entry<String, Revisione
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<GroupListPredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, GroupListPredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realm, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupListPredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public GroupListPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
GroupListPredicate res = new GroupListPredicate();
|
||||
res.realm = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,21 @@ import org.keycloak.models.cache.infinispan.entities.CachedRole;
|
|||
import org.keycloak.models.cache.infinispan.entities.Revisioned;
|
||||
import org.keycloak.models.cache.infinispan.entities.RoleQuery;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@SerializeWith(HasRolePredicate.ExternalizerImpl.class)
|
||||
public class HasRolePredicate implements Predicate<Map.Entry<String, Revisioned>>, Serializable {
|
||||
private String role;
|
||||
|
||||
|
@ -55,4 +62,33 @@ public class HasRolePredicate implements Predicate<Map.Entry<String, Revisioned>
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<HasRolePredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, HasRolePredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.role, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HasRolePredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public HasRolePredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
HasRolePredicate res = new HasRolePredicate();
|
||||
res.role = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,21 @@ package org.keycloak.models.cache.infinispan.stream;
|
|||
import org.keycloak.models.cache.infinispan.entities.InClient;
|
||||
import org.keycloak.models.cache.infinispan.entities.Revisioned;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@SerializeWith(InClientPredicate.ExternalizerImpl.class)
|
||||
public class InClientPredicate implements Predicate<Map.Entry<String, Revisioned>>, Serializable {
|
||||
private String clientId;
|
||||
|
||||
|
@ -31,4 +38,33 @@ public class InClientPredicate implements Predicate<Map.Entry<String, Revisioned
|
|||
|
||||
return clientId.equals(((InClient)value).getClientId());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<InClientPredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, InClientPredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.clientId, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InClientPredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public InClientPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
InClientPredicate res = new InClientPredicate();
|
||||
res.clientId = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,21 @@ package org.keycloak.models.cache.infinispan.stream;
|
|||
import org.keycloak.models.cache.infinispan.entities.InRealm;
|
||||
import org.keycloak.models.cache.infinispan.entities.Revisioned;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@SerializeWith(InRealmPredicate.ExternalizerImpl.class)
|
||||
public class InRealmPredicate implements Predicate<Map.Entry<String, Revisioned>>, Serializable {
|
||||
private String realm;
|
||||
|
||||
|
@ -31,4 +38,33 @@ public class InRealmPredicate implements Predicate<Map.Entry<String, Revisioned>
|
|||
|
||||
return realm.equals(((InRealm)value).getRealm());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<InRealmPredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, InRealmPredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realm, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InRealmPredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public InRealmPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
InRealmPredicate res = new InRealmPredicate();
|
||||
res.realm = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.infinispan.commons.marshall.Externalizer;
|
|||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
import org.keycloak.models.sessions.infinispan.entities.SessionEntity;
|
||||
import java.util.HashMap;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
|
@ -157,7 +158,7 @@ public class SessionEntityWrapper<S extends SessionEntity> {
|
|||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, SessionEntityWrapper obj) throws IOException {
|
||||
output.write(VERSION_1);
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
final boolean forTransport = obj.isForTransport();
|
||||
output.writeBoolean(forTransport);
|
||||
|
@ -187,7 +188,7 @@ public class SessionEntityWrapper<S extends SessionEntity> {
|
|||
return new SessionEntityWrapper(entity);
|
||||
} else {
|
||||
UUID sessionVersion = new UUID(input.readLong(), input.readLong());
|
||||
ConcurrentHashMap<String, String> map = MarshallUtil.unmarshallMap(input, (size) -> new ConcurrentHashMap<>(size));
|
||||
HashMap<String, String> map = MarshallUtil.unmarshallMap(input, HashMap::new);
|
||||
final SessionEntity entity = (SessionEntity) input.readObject();
|
||||
log.debugf("Found entity locally: %s", entity);
|
||||
return new SessionEntityWrapper(sessionVersion, map, entity);
|
||||
|
|
|
@ -18,10 +18,17 @@
|
|||
package org.keycloak.models.sessions.infinispan.events;
|
||||
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(ClientRemovedSessionEvent.ExternalizerImpl.class)
|
||||
public class ClientRemovedSessionEvent extends SessionClusterEvent {
|
||||
|
||||
private String clientUuid;
|
||||
|
@ -40,4 +47,34 @@ public class ClientRemovedSessionEvent extends SessionClusterEvent {
|
|||
public String getClientUuid() {
|
||||
return clientUuid;
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<ClientRemovedSessionEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, ClientRemovedSessionEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
obj.marshallTo(output);
|
||||
MarshallUtil.marshallString(obj.clientUuid, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientRemovedSessionEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public ClientRemovedSessionEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
ClientRemovedSessionEvent res = new ClientRemovedSessionEvent();
|
||||
res.unmarshallFrom(input);
|
||||
res.clientUuid = MarshallUtil.unmarshallString(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,45 @@
|
|||
|
||||
package org.keycloak.models.sessions.infinispan.events;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RealmRemovedSessionEvent.ExternalizerImpl.class)
|
||||
public class RealmRemovedSessionEvent extends SessionClusterEvent {
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RealmRemovedSessionEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RealmRemovedSessionEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
obj.marshallTo(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RealmRemovedSessionEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RealmRemovedSessionEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RealmRemovedSessionEvent res = new RealmRemovedSessionEvent();
|
||||
res.unmarshallFrom(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,45 @@
|
|||
|
||||
package org.keycloak.models.sessions.infinispan.events;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RemoveAllUserLoginFailuresEvent.ExternalizerImpl.class)
|
||||
public class RemoveAllUserLoginFailuresEvent extends SessionClusterEvent {
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RemoveAllUserLoginFailuresEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RemoveAllUserLoginFailuresEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
obj.marshallTo(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveAllUserLoginFailuresEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RemoveAllUserLoginFailuresEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RemoveAllUserLoginFailuresEvent res = new RemoveAllUserLoginFailuresEvent();
|
||||
res.unmarshallFrom(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,45 @@
|
|||
|
||||
package org.keycloak.models.sessions.infinispan.events;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
@SerializeWith(RemoveUserSessionsEvent.ExternalizerImpl.class)
|
||||
public class RemoveUserSessionsEvent extends SessionClusterEvent {
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<RemoveUserSessionsEvent> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, RemoveUserSessionsEvent obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
obj.marshallTo(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveUserSessionsEvent readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public RemoveUserSessionsEvent readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
RemoveUserSessionsEvent res = new RemoveUserSessionsEvent();
|
||||
res.unmarshallFrom(input);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@ package org.keycloak.models.sessions.infinispan.events;
|
|||
import org.keycloak.cluster.ClusterEvent;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.sessions.infinispan.util.InfinispanUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
|
@ -78,4 +82,40 @@ public abstract class SessionClusterEvent implements ClusterEvent {
|
|||
String simpleClassName = getClass().getSimpleName();
|
||||
return String.format("%s [ realmId=%s ]", simpleClassName, realmId);
|
||||
}
|
||||
|
||||
// Infinispan marshalling support for child classes
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
protected void marshallTo(ObjectOutput output) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(realmId, output);
|
||||
MarshallUtil.marshallString(eventKey, output);
|
||||
output.writeBoolean(resendingEvent);
|
||||
MarshallUtil.marshallString(siteId, output);
|
||||
MarshallUtil.marshallString(nodeId, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the properties of this object from the input stream.
|
||||
* @param input
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void unmarshallFrom(ObjectInput input) throws IOException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
unmarshallFromVersion1(input);
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
private void unmarshallFromVersion1(ObjectInput input) throws IOException {
|
||||
this.realmId = MarshallUtil.unmarshallString(input);
|
||||
this.eventKey = MarshallUtil.unmarshallString(input);
|
||||
this.resendingEvent = input.readBoolean();
|
||||
this.siteId = MarshallUtil.unmarshallString(input);
|
||||
this.nodeId = MarshallUtil.unmarshallString(input);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,18 +17,25 @@
|
|||
|
||||
package org.keycloak.models.sessions.infinispan.stream;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.keycloak.models.sessions.infinispan.entities.AuthenticationSessionEntity;
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
public class AuthenticationSessionPredicate implements Predicate<Map.Entry<String, AuthenticationSessionEntity>>, Serializable {
|
||||
@SerializeWith(AuthenticationSessionPredicate.ExternalizerImpl.class)
|
||||
public class AuthenticationSessionPredicate implements Predicate<Map.Entry<String, AuthenticationSessionEntity>> {
|
||||
|
||||
private String realm;
|
||||
private final String realm;
|
||||
|
||||
private String client;
|
||||
|
||||
|
@ -102,4 +109,38 @@ public class AuthenticationSessionPredicate implements Predicate<Map.Entry<Strin
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<AuthenticationSessionPredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, AuthenticationSessionPredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realm, output);
|
||||
MarshallUtil.marshallString(obj.user, output);
|
||||
MarshallUtil.marshallString(obj.client, output);
|
||||
KeycloakMarshallUtil.marshall(obj.expired, output);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationSessionPredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public AuthenticationSessionPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
AuthenticationSessionPredicate res = new AuthenticationSessionPredicate(MarshallUtil.unmarshallString(input));
|
||||
res.user(MarshallUtil.unmarshallString(input));
|
||||
res.client(MarshallUtil.unmarshallString(input));
|
||||
res.expired(KeycloakMarshallUtil.unmarshallInteger(input));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,16 +20,22 @@ package org.keycloak.models.sessions.infinispan.stream;
|
|||
import org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper;
|
||||
import org.keycloak.models.sessions.infinispan.entities.SessionEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
*/
|
||||
public class SessionPredicate<S extends SessionEntity> implements Predicate<Map.Entry<String, SessionEntityWrapper<S>>>, Serializable {
|
||||
@SerializeWith(SessionPredicate.ExternalizerImpl.class)
|
||||
public class SessionPredicate<S extends SessionEntity> implements Predicate<Map.Entry<String, SessionEntityWrapper<S>>> {
|
||||
|
||||
private String realm;
|
||||
private final String realm;
|
||||
|
||||
private SessionPredicate(String realm) {
|
||||
this.realm = realm;
|
||||
|
@ -44,4 +50,31 @@ public class SessionPredicate<S extends SessionEntity> implements Predicate<Map.
|
|||
return realm.equals(entry.getValue().getEntity().getRealmId());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<SessionPredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, SessionPredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realm, output);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionPredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public SessionPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
SessionPredicate res = new SessionPredicate(MarshallUtil.unmarshallString(input));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,16 +21,22 @@ import org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper;
|
|||
import org.keycloak.models.sessions.infinispan.entities.LoginFailureEntity;
|
||||
import org.keycloak.models.sessions.infinispan.entities.LoginFailureKey;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
*/
|
||||
public class UserLoginFailurePredicate implements Predicate<Map.Entry<LoginFailureKey, SessionEntityWrapper<LoginFailureEntity>>>, Serializable {
|
||||
@SerializeWith(UserLoginFailurePredicate.ExternalizerImpl.class)
|
||||
public class UserLoginFailurePredicate implements Predicate<Map.Entry<LoginFailureKey, SessionEntityWrapper<LoginFailureEntity>>> {
|
||||
|
||||
private String realm;
|
||||
private final String realm;
|
||||
|
||||
private UserLoginFailurePredicate(String realm) {
|
||||
this.realm = realm;
|
||||
|
@ -46,4 +52,31 @@ public class UserLoginFailurePredicate implements Predicate<Map.Entry<LoginFailu
|
|||
return realm.equals(e.getRealmId());
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserLoginFailurePredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserLoginFailurePredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realm, output);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserLoginFailurePredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserLoginFailurePredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserLoginFailurePredicate res = new UserLoginFailurePredicate(MarshallUtil.unmarshallString(input));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,16 +21,23 @@ import org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper;
|
|||
import org.keycloak.models.sessions.infinispan.entities.SessionEntity;
|
||||
import org.keycloak.models.sessions.infinispan.entities.UserSessionEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.keycloak.models.sessions.infinispan.util.KeycloakMarshallUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import org.infinispan.commons.marshall.Externalizer;
|
||||
import org.infinispan.commons.marshall.MarshallUtil;
|
||||
import org.infinispan.commons.marshall.SerializeWith;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
*/
|
||||
public class UserSessionPredicate implements Predicate<Map.Entry<String, SessionEntityWrapper<UserSessionEntity>>>, Serializable {
|
||||
@SerializeWith(UserSessionPredicate.ExternalizerImpl.class)
|
||||
public class UserSessionPredicate implements Predicate<Map.Entry<String, SessionEntityWrapper<UserSessionEntity>>> {
|
||||
|
||||
private String realm;
|
||||
private final String realm;
|
||||
|
||||
private String user;
|
||||
|
||||
|
@ -113,4 +120,43 @@ public class UserSessionPredicate implements Predicate<Map.Entry<String, Session
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class ExternalizerImpl implements Externalizer<UserSessionPredicate> {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
|
||||
@Override
|
||||
public void writeObject(ObjectOutput output, UserSessionPredicate obj) throws IOException {
|
||||
output.writeByte(VERSION_1);
|
||||
|
||||
MarshallUtil.marshallString(obj.realm, output);
|
||||
MarshallUtil.marshallString(obj.user, output);
|
||||
MarshallUtil.marshallString(obj.client, output);
|
||||
KeycloakMarshallUtil.marshall(obj.expired, output);
|
||||
KeycloakMarshallUtil.marshall(obj.expiredRefresh, output);
|
||||
MarshallUtil.marshallString(obj.brokerSessionId, output);
|
||||
MarshallUtil.marshallString(obj.brokerUserId, output);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserSessionPredicate readObject(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
switch (input.readByte()) {
|
||||
case VERSION_1:
|
||||
return readObjectVersion1(input);
|
||||
default:
|
||||
throw new IOException("Unknown version");
|
||||
}
|
||||
}
|
||||
|
||||
public UserSessionPredicate readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException {
|
||||
UserSessionPredicate res = new UserSessionPredicate(MarshallUtil.unmarshallString(input));
|
||||
res.user(MarshallUtil.unmarshallString(input));
|
||||
res.client(MarshallUtil.unmarshallString(input));
|
||||
res.expired(KeycloakMarshallUtil.unmarshallInteger(input), KeycloakMarshallUtil.unmarshallInteger(input));
|
||||
res.brokerSessionId(MarshallUtil.unmarshallString(input));
|
||||
res.brokerUserId(MarshallUtil.unmarshallString(input));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,31 @@ public class KeycloakMarshallUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshalls the given object with support of {@code null} values.
|
||||
* @param obj Object to marshall (can be {@code null})
|
||||
* @param output Output stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void marshall(Integer obj, ObjectOutput output) throws IOException {
|
||||
if (obj == null) {
|
||||
output.writeBoolean(false);
|
||||
} else {
|
||||
output.writeBoolean(true);
|
||||
output.writeInt(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshals the given object into {@code Integer} instance.
|
||||
* @param input Input stream
|
||||
* @return Unmarshalled value (can be {@code null})
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Integer unmarshallInteger(ObjectInput input) throws IOException {
|
||||
boolean isSet = input.readBoolean();
|
||||
return isSet ? input.readInt() : null;
|
||||
}
|
||||
|
||||
|
||||
public static class ConcurrentHashMapBuilder<K, V> implements MarshallUtil.MapBuilder<K, V, ConcurrentHashMap<K, V>> {
|
||||
|
|
Loading…
Reference in a new issue