Package org.keycloak.models.sessions.mem.entities

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


    }

    @Override
    public void setUserSession(UserSessionModel userSession) {
        UserSessionAdapter adapter = (UserSessionAdapter)userSession;
        UserSessionEntity userSessionEntity = adapter.getEntity();
        entity.setSession(userSessionEntity);
        userSessionEntity.getClientSessions().add(entity);
    }
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);

        userSessions.put(id, entity);

        return new UserSessionAdapter(session, this, realm, entity);
    }
View Full Code Here

        return new UserSessionAdapter(session, this, realm, entity);
    }

    @Override
    public UserSessionModel getUserSession(RealmModel realm, String id) {
        UserSessionEntity entity = getUserSessionEntity(realm, id);
        return entity != null ? new UserSessionAdapter(session, this, realm, entity) : null;
    }
View Full Code Here

        UserSessionEntity entity = getUserSessionEntity(realm, id);
        return entity != null ? new UserSessionAdapter(session, this, realm, entity) : null;
    }

    UserSessionEntity getUserSessionEntity(RealmModel realm, String id) {
        UserSessionEntity entity = userSessions.get(id);
        if (entity != null && entity.getRealm().equals(realm.getId())) {
            return entity;
        }
        return null;
    }
View Full Code Here

        return getUserSessions(realm, client).size();
    }

    @Override
    public void removeUserSession(RealmModel realm, UserSessionModel session) {
        UserSessionEntity entity = getUserSessionEntity(realm, session.getId());
        if (entity != null) {
            userSessions.remove(entity.getId());
            for (ClientSessionEntity clientSession : entity.getClientSessions()) {
                clientSessions.remove(clientSession.getId());
            }
        }
    }
View Full Code Here

    @Override
    public void removeUserSessions(RealmModel realm, UserModel user) {
        Iterator<UserSessionEntity> itr = userSessions.values().iterator();
        while (itr.hasNext()) {
            UserSessionEntity s = itr.next();
            if (s.getRealm().equals(realm.getId()) && s.getUser().equals(user.getId())) {
                itr.remove();

                for (ClientSessionEntity clientSession : s.getClientSessions()) {
                    clientSessions.remove(clientSession.getId());
                }
            }
        }
    }
View Full Code Here

    @Override
    public void removeExpiredUserSessions(RealmModel realm) {
        Iterator<UserSessionEntity> itr = userSessions.values().iterator();
        while (itr.hasNext()) {
            UserSessionEntity s = itr.next();
            if (s.getRealm().equals(realm.getId()) && (s.getLastSessionRefresh() < Time.currentTime() - realm.getSsoSessionIdleTimeout() || s.getStarted() < Time.currentTime() - realm.getSsoSessionMaxLifespan())) {
                itr.remove();

                for (ClientSessionEntity clientSession : s.getClientSessions()) {
                    clientSessions.remove(clientSession.getId());
                }
            }
        }
        Iterator<ClientSessionEntity> citr = clientSessions.values().iterator();
View Full Code Here

    @Override
    public void removeUserSessions(RealmModel realm) {
        Iterator<UserSessionEntity> itr = userSessions.values().iterator();
        while (itr.hasNext()) {
            UserSessionEntity s = itr.next();
            if (s.getRealm().equals(realm.getId())) {
                itr.remove();

                for (ClientSessionEntity clientSession : s.getClientSessions()) {
                    clientSessions.remove(clientSession.getId());
                }
            }
        }
        Iterator<ClientSessionEntity> citr = clientSessions.values().iterator();
View Full Code Here

TOP

Related Classes of org.keycloak.models.sessions.mem.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.