/** * Updates all session info objects, so that invalid projects * are replaced by the Online project.<p> * * @param cms the cms context */ public void updateSessionInfos(CmsObject cms) { // get all sessions List<CmsSessionInfo> userSessions = getSessionInfos(); Iterator<CmsSessionInfo> i = userSessions.iterator(); while (i.hasNext()) { CmsSessionInfo sessionInfo = i.next(); // check is the project stored in this session is not existing anymore // if so, set it to the online project CmsUUID projectId = sessionInfo.getProject(); try { cms.readProject(projectId); } catch (CmsException e) { // the project does not longer exist, update the project information with the online project sessionInfo.setProject(CmsProject.ONLINE_PROJECT_ID); addSessionInfo(sessionInfo); } } }
/** * Updates all session info objects, so that invalid projects * are replaced by the Online project.<p> * * @param cms the cms context */ public void updateSessionInfos(CmsObject cms) { // get all sessions List userSessions = getSessionInfos(); Iterator i = userSessions.iterator(); while (i.hasNext()) { CmsSessionInfo sessionInfo = (CmsSessionInfo)i.next(); // check is the project stored in this session is not existing anymore // if so, set it to the online project CmsUUID projectId = sessionInfo.getProject(); try { cms.readProject(projectId); } catch (CmsException e) { // the project does not longer exist, update the project information with the online project sessionInfo.setProject(CmsProject.ONLINE_PROJECT_ID); addSessionInfo(sessionInfo); } } }
while (itUsers.hasNext()) { CmsUser user = itUsers.next(); if (OpenCms.getSessionManager().getSessionInfos(user.getId()).isEmpty()) { continue;
/** * Checks whether a new session can be created for the user, and throws an exception if not.<p> * * @param user the user to check * @throws CmsException if no new session for the user can't be created */ public void checkCreateSessionForUser(CmsUser user) throws CmsException { if (getUserSessionMode() == UserSessionMode.single) { List<CmsSessionInfo> infos = getSessionInfos(user.getId()); if (!infos.isEmpty()) { throw new CmsCustomLoginException( org.opencms.security.Messages.get().container( org.opencms.security.Messages.ERR_ALREADY_LOGGED_IN_0)); } } }
/** * Adds a new session info into the session storage.<p> * * @param sessionInfo the session info to store for the id */ protected void addSessionInfo(CmsSessionInfo sessionInfo) { if (getUserSessionMode() == UserSessionMode.standard) { m_sessionStorageProvider.put(sessionInfo); } else if (getUserSessionMode() == UserSessionMode.single) { CmsUUID userId = sessionInfo.getUserId(); List<CmsSessionInfo> infos = getSessionInfos(userId); if (infos.isEmpty() || ((infos.size() == 1) && infos.get(0).getSessionId().equals(sessionInfo.getSessionId()))) { m_sessionStorageProvider.put(sessionInfo); } else { throw new RuntimeException("Can't create another session for the same user."); } } }
if ((userId != null) && (getSessionInfos(userId).size() == 0)) {
if ((userId != null) && (getSessionInfos(userId).size() == 0)) {
/** * Sends a broadcast to all sessions of a given user.<p> * * The user sending the message may be a real user like * <code>cms.getRequestContext().currentUser()</code> or * <code>null</code> for a system message.<p> * * @param fromUser the user sending the broadcast * @param message the message to broadcast * @param toUser the target (receiver) of the broadcast */ public void sendBroadcast(CmsUser fromUser, String message, CmsUser toUser) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(fromUser, message); List userSessions = getSessionInfos(toUser.getId()); Iterator i = userSessions.iterator(); // send the broadcast to all sessions of the selected user while (i.hasNext()) { CmsSessionInfo sessionInfo = (CmsSessionInfo)i.next(); if (m_sessionStorageProvider.get(sessionInfo.getSessionId()) != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(broadcast); } } }
Iterator<CmsSessionInfo> itSessions = OpenCms.getSessionManager().getSessionInfos().iterator(); while (itSessions.hasNext()) { CmsSessionInfo sessionInfo = itSessions.next();
/** * Sends a broadcast to all sessions of a given user.<p> * * The user sending the message may be a real user like * <code>cms.getRequestContext().currentUser()</code> or * <code>null</code> for a system message.<p> * * @param fromUser the user sending the broadcast * @param message the message to broadcast * @param toUser the target (receiver) of the broadcast */ public void sendBroadcast(CmsUser fromUser, String message, CmsUser toUser) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(fromUser, message); List<CmsSessionInfo> userSessions = getSessionInfos(toUser.getId()); Iterator<CmsSessionInfo> i = userSessions.iterator(); // send the broadcast to all sessions of the selected user while (i.hasNext()) { CmsSessionInfo sessionInfo = i.next(); if (m_sessionStorageProvider.get(sessionInfo.getSessionId()) != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(broadcast); } } }
/** * Kills all sessions for the given user.<p> * * @param cms the current CMS context * @param user the user for whom the sessions should be killed * * @throws CmsException if something goes wrong */ public void killSession(CmsObject cms, CmsUser user) throws CmsException { OpenCms.getRoleManager().checkRole(cms, CmsRole.ACCOUNT_MANAGER); List<CmsSessionInfo> infos = getSessionInfos(user.getId()); for (CmsSessionInfo info : infos) { m_sessionStorageProvider.remove(info.getSessionId()); } }
CmsUser user = itUsers.next(); if (!isEmail) { if (!OpenCms.getSessionManager().getSessionInfos(user.getId()).isEmpty()) { hasUser = true;
List<CmsSessionInfo> sessionInfos = OpenCms.getSessionManager().getSessionInfos(); Iterator<CmsSessionInfo> itSessions = sessionInfos.iterator(); List<CmsOrganizationalUnit> manageableOus = OpenCms.getRoleManager().getManageableOrgUnits(