Examples of MongoUserSessionEntity


Examples of org.keycloak.models.sessions.mongo.entities.MongoUserSessionEntity

    }


    @Override
    public UserSessionModel createUserSession(RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe) {
        MongoUserSessionEntity entity = new MongoUserSessionEntity();
        entity.setRealmId(realm.getId());
        entity.setUser(user.getId());
        entity.setLoginUsername(loginUsername);
        entity.setIpAddress(ipAddress);
        entity.setAuthMethod(authMethod);
        entity.setRememberMe(rememberMe);
        entity.setRealmId(realm.getId());

        int currentTime = Time.currentTime();

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

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

Examples of org.keycloak.models.sessions.mongo.entities.MongoUserSessionEntity

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

    @Override
    public UserSessionModel getUserSession(RealmModel realm, String id) {
        MongoUserSessionEntity entity = getUserSessionEntity(realm, id);
        if (entity == null) {
            return null;
        } else {
            return new UserSessionAdapter(session, this, entity, realm, invocationContext);
        }
View Full Code Here

Examples of org.keycloak.models.sessions.mongo.entities.MongoUserSessionEntity

        DBObject sort = new BasicDBObject("timestamp", 1).append("id", 1);

        List<MongoClientSessionEntity> clientSessions = mongoStore.loadEntities(MongoClientSessionEntity.class, query, sort, firstResult, maxResults, invocationContext);
        List<UserSessionModel> result = new LinkedList<UserSessionModel>();
        for (MongoClientSessionEntity clientSession : clientSessions) {
            MongoUserSessionEntity userSession = mongoStore.loadEntity(MongoUserSessionEntity.class, clientSession.getSessionId(), invocationContext);
            result.add(new UserSessionAdapter(session, this, userSession, realm, invocationContext));
        }
        return result;
    }
View Full Code Here

Examples of org.keycloak.models.sessions.mongo.entities.MongoUserSessionEntity

                .get();
        DBObject sort = new BasicDBObject("timestamp", 1).append("id", 1);

        List<MongoClientSessionEntity> clientSessions = mongoStore.loadEntities(MongoClientSessionEntity.class, query, sort, -1, -1, invocationContext);
        for (MongoClientSessionEntity clientSession : clientSessions) {
            MongoUserSessionEntity userSession = mongoStore.loadEntity(MongoUserSessionEntity.class, clientSession.getSessionId(), invocationContext);
            getMongoStore().pullItemFromList(userSession, "clientSessions", clientSession.getId(), invocationContext);
            mongoStore.removeEntity(clientSession, invocationContext);
        }
    }
View Full Code Here

Examples of org.keycloak.models.sessions.mongo.entities.MongoUserSessionEntity

        return provider.getUserSession(realm, entity.getSessionId());
    }

    @Override
    public void setUserSession(UserSessionModel userSession) {
        MongoUserSessionEntity userSessionEntity = provider.getUserSessionEntity(realm, userSession.getId());
        entity.setSessionId(userSessionEntity.getId());
        updateMongoEntity();

        provider.getMongoStore().pushItemToList(userSessionEntity, "clientSessions", entity.getId(), true, invocationContext);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.