Search in sources :

Example 1 with CrossDCLastSessionRefreshChecker

use of org.keycloak.models.sessions.infinispan.changes.sessions.CrossDCLastSessionRefreshChecker in project keycloak by keycloak.

the class UserSessionAdapter method setLastSessionRefresh.

public void setLastSessionRefresh(int lastSessionRefresh) {
    if (offline) {
        // Received the message from the other DC that we should update the lastSessionRefresh in local cluster. Don't update DB in that case.
        // The other DC already did.
        Boolean ignoreRemoteCacheUpdate = (Boolean) session.getAttribute(CrossDCLastSessionRefreshListener.IGNORE_REMOTE_CACHE_UPDATE);
        if (ignoreRemoteCacheUpdate == null || !ignoreRemoteCacheUpdate) {
            provider.getPersisterLastSessionRefreshStore().putLastSessionRefresh(session, entity.getId(), realm.getId(), lastSessionRefresh);
        }
    }
    UserSessionUpdateTask task = new UserSessionUpdateTask() {

        @Override
        public void runUpdate(UserSessionEntity entity) {
            entity.setLastSessionRefresh(lastSessionRefresh);
        }

        @Override
        public CrossDCMessageStatus getCrossDCMessageStatus(SessionEntityWrapper<UserSessionEntity> sessionWrapper) {
            return new CrossDCLastSessionRefreshChecker(provider.getLastSessionRefreshStore(), provider.getOfflineLastSessionRefreshStore()).shouldSaveUserSessionToRemoteCache(UserSessionAdapter.this.session, UserSessionAdapter.this.realm, sessionWrapper, offline, lastSessionRefresh);
        }

        @Override
        public String toString() {
            return "setLastSessionRefresh(" + lastSessionRefresh + ')';
        }
    };
    update(task);
}
Also used : UserSessionUpdateTask(org.keycloak.models.sessions.infinispan.changes.UserSessionUpdateTask) SessionEntityWrapper(org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper) CrossDCLastSessionRefreshChecker(org.keycloak.models.sessions.infinispan.changes.sessions.CrossDCLastSessionRefreshChecker) UserSessionEntity(org.keycloak.models.sessions.infinispan.entities.UserSessionEntity)

Example 2 with CrossDCLastSessionRefreshChecker

use of org.keycloak.models.sessions.infinispan.changes.sessions.CrossDCLastSessionRefreshChecker in project keycloak by keycloak.

the class AuthenticatedClientSessionAdapter method setTimestamp.

@Override
public void setTimestamp(int timestamp) {
    ClientSessionUpdateTask task = new ClientSessionUpdateTask() {

        @Override
        public void runUpdate(AuthenticatedClientSessionEntity entity) {
            entity.setTimestamp(timestamp);
        }

        @Override
        public CrossDCMessageStatus getCrossDCMessageStatus(SessionEntityWrapper<AuthenticatedClientSessionEntity> sessionWrapper) {
            return new CrossDCLastSessionRefreshChecker(provider.getLastSessionRefreshStore(), provider.getOfflineLastSessionRefreshStore()).shouldSaveClientSessionToRemoteCache(kcSession, client.getRealm(), sessionWrapper, userSession, offline, timestamp);
        }

        @Override
        public String toString() {
            return "setTimestamp(" + timestamp + ')';
        }
    };
    update(task);
}
Also used : AuthenticatedClientSessionEntity(org.keycloak.models.sessions.infinispan.entities.AuthenticatedClientSessionEntity) ClientSessionUpdateTask(org.keycloak.models.sessions.infinispan.changes.ClientSessionUpdateTask) SessionEntityWrapper(org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper) CrossDCLastSessionRefreshChecker(org.keycloak.models.sessions.infinispan.changes.sessions.CrossDCLastSessionRefreshChecker)

Aggregations

SessionEntityWrapper (org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)2 CrossDCLastSessionRefreshChecker (org.keycloak.models.sessions.infinispan.changes.sessions.CrossDCLastSessionRefreshChecker)2 ClientSessionUpdateTask (org.keycloak.models.sessions.infinispan.changes.ClientSessionUpdateTask)1 UserSessionUpdateTask (org.keycloak.models.sessions.infinispan.changes.UserSessionUpdateTask)1 AuthenticatedClientSessionEntity (org.keycloak.models.sessions.infinispan.entities.AuthenticatedClientSessionEntity)1 UserSessionEntity (org.keycloak.models.sessions.infinispan.entities.UserSessionEntity)1