Package org.keycloak.models.sessions.infinispan.entities

Examples of org.keycloak.models.sessions.infinispan.entities.UserSessionEntity


    public void map(String key, SessionEntity e, Collector collector) {
        if (!(e instanceof UserSessionEntity)) {
            return;
        }

        UserSessionEntity entity = (UserSessionEntity) e;

        if (!realm.equals(entity.getRealm())) {
            return;
        }

        if (user != null && !entity.getUser().equals(user)) {
            return;
        }

        if (expired != null && expiredRefresh != null && entity.getStarted() > expired && entity.getLastSessionRefresh() > expiredRefresh) {
            return;
        }

        switch (emit) {
            case KEY:
View Full Code Here


    @Override
    public UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe) {
        String id = KeycloakModelUtils.generateId();

        UserSessionEntity entity = new UserSessionEntity();
        entity.setId(id);
        entity.setRealm(realm.getId());
        entity.setUser(user.getId());
        entity.setLoginUsername(loginUsername);
        entity.setIpAddress(ipAddress);
        entity.setAuthMethod(authMethod);
        entity.setRememberMe(rememberMe);

        int currentTime = Time.currentTime();

        entity.setStarted(currentTime);
        entity.setLastSessionRefresh(currentTime);

        tx.put(sessionCache, id, entity);

        return wrap(realm, entity);
    }
View Full Code Here

        return null;
    }

    @Override
    public UserSessionModel getUserSession(RealmModel realm, String id) {
        UserSessionEntity entity = (UserSessionEntity) sessionCache.get(id);
        return wrap(realm, entity);
    }
View Full Code Here

            sessionTimestamps = sessionTimestamps.subList(firstResult, toIndex);
        }

        List<UserSessionModel> userSessions = new LinkedList<UserSessionModel>();
        for (Map.Entry<String, Integer> e : sessionTimestamps) {
            UserSessionEntity userSessionEntity = (UserSessionEntity) sessionCache.get(e.getKey());
            if (userSessionEntity != null) {
                userSessions.add(wrap(realm, userSessionEntity));
            }
        }
View Full Code Here

    @Override
    public void close() {
    }

    void attachSession(UserSessionModel userSession, ClientSessionModel clientSession) {
        UserSessionEntity entity = ((UserSessionAdapter) userSession).getEntity();
        String clientSessionId = clientSession.getId();
        if (entity.getClientSessions() == null) {
            entity.setClientSessions(new HashSet<String>());
        }
        if (!entity.getClientSessions().contains(clientSessionId)) {
            entity.getClientSessions().add(clientSessionId);
            tx.replace(sessionCache, entity.getId(), entity);
        }
    }
View Full Code Here

            tx.replace(sessionCache, entity.getId(), entity);
        }
    }

    void dettachSession(UserSessionModel userSession, ClientSessionModel clientSession) {
        UserSessionEntity entity = ((UserSessionAdapter) userSession).getEntity();
        String clientSessionId = clientSession.getId();
        if (entity.getClientSessions() != null && entity.getClientSessions().contains(clientSessionId)) {
            entity.getClientSessions().remove(clientSessionId);
            if (entity.getClientSessions().isEmpty()) {
                entity.setClientSessions(null);
            }
            tx.replace(sessionCache, entity.getId(), entity);
        }
    }
View Full Code Here

TOP

Related Classes of org.keycloak.models.sessions.infinispan.entities.UserSessionEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.