Search in sources :

Example 1 with UserSessionDAOImpl

use of org.wso2.carbon.identity.application.authentication.framework.dao.impl.UserSessionDAOImpl in project carbon-identity-framework by wso2.

the class UserSessionManagementServiceImpl method getActiveSessionList.

/**
 * Returns the active sessions from given list of session IDs.
 *
 * @param sessionIdList list of sessionIds
 * @return list of user sessions
 * @throws SessionManagementServerException if an error occurs when retrieving the UserSessions.
 */
private List<UserSession> getActiveSessionList(List<String> sessionIdList) throws SessionManagementServerException {
    List<UserSession> sessionsList = new ArrayList<>();
    for (String sessionId : sessionIdList) {
        if (sessionId != null) {
            SessionContext sessionContext = FrameworkUtils.getSessionContextFromCache(sessionId, FrameworkUtils.getLoginTenantDomainFromContext());
            if (sessionContext != null) {
                UserSessionDAO userSessionDTO = new UserSessionDAOImpl();
                UserSession userSession = userSessionDTO.getSession(sessionId);
                if (userSession != null) {
                    sessionsList.add(userSession);
                }
            }
        }
    }
    return sessionsList;
}
Also used : UserSession(org.wso2.carbon.identity.application.authentication.framework.model.UserSession) ArrayList(java.util.ArrayList) UserSessionDAOImpl(org.wso2.carbon.identity.application.authentication.framework.dao.impl.UserSessionDAOImpl) SessionContext(org.wso2.carbon.identity.application.authentication.framework.context.SessionContext) UserSessionDAO(org.wso2.carbon.identity.application.authentication.framework.dao.UserSessionDAO)

Aggregations

ArrayList (java.util.ArrayList)1 SessionContext (org.wso2.carbon.identity.application.authentication.framework.context.SessionContext)1 UserSessionDAO (org.wso2.carbon.identity.application.authentication.framework.dao.UserSessionDAO)1 UserSessionDAOImpl (org.wso2.carbon.identity.application.authentication.framework.dao.impl.UserSessionDAOImpl)1 UserSession (org.wso2.carbon.identity.application.authentication.framework.model.UserSession)1