/** * @see org.opencms.main.I_CmsSessionStorageProvider#put(org.opencms.main.CmsSessionInfo) */ public CmsSessionInfo put(CmsSessionInfo sessionInfo) { return (CmsSessionInfo)m_sessions.put(sessionInfo.getSessionId(), sessionInfo); }
/** * @see org.opencms.main.I_CmsSessionStorageProvider#put(org.opencms.main.CmsSessionInfo) */ public CmsSessionInfo put(CmsSessionInfo sessionInfo) { return (CmsSessionInfo)m_sessions.put(sessionInfo.getSessionId(), sessionInfo); }
/** * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer output = new StringBuffer(); Iterator<CmsSessionInfo> i = m_sessionStorageProvider.getAll().iterator(); output.append("[CmsSessions]:\n"); while (i.hasNext()) { CmsSessionInfo sessionInfo = i.next(); output.append(sessionInfo.getSessionId().toString()); output.append(" : "); output.append(sessionInfo.getUserId().toString()); output.append('\n'); } return output.toString(); }
/** * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer output = new StringBuffer(); Iterator i = m_sessionStorageProvider.getAll().iterator(); output.append("[CmsSessions]:\n"); while (i.hasNext()) { CmsSessionInfo sessionInfo = (CmsSessionInfo)i.next(); output.append(sessionInfo.getSessionId().toString()); output.append(" : "); output.append(sessionInfo.getUserId().toString()); output.append('\n'); } return output.toString(); }
/** * 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 (sessionInfo != null) { userId = sessionInfo.getUserId(); m_sessionStorageProvider.remove(sessionInfo.getSessionId());
if (sessionInfo != null) { userId = sessionInfo.getUserId(); m_sessionStorageProvider.remove(sessionInfo.getSessionId());
/** * Sends a broadcast to all sessions of all currently authenticated users.<p> * * @param cms the OpenCms user context of the user sending the broadcast * * @param message the message to broadcast */ public void sendBroadcast(CmsObject cms, String message) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(cms.getRequestContext().currentUser(), message); // send the broadcast to all authenticated sessions Iterator i = m_sessionStorageProvider.getAll().iterator(); while (i.hasNext()) { CmsSessionInfo sessionInfo = (CmsSessionInfo)i.next(); if (m_sessionStorageProvider.get(sessionInfo.getSessionId()) != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(broadcast); } } }
continue; ids.add(sessionInfo.getSessionId().toString());
/** * 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); } } }
/** * 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); } } }
return null; String sessionId = sessionInfo.getSessionId().toString(); Buffer messageQueue = OpenCms.getSessionManager().getBroadcastQueue(sessionId); if (!messageQueue.isEmpty()) {
/** * Sends a broadcast to all sessions of all currently authenticated users.<p> * * @param cms the OpenCms user context of the user sending the broadcast * * @param message the message to broadcast */ public void sendBroadcast(CmsObject cms, String message) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(cms.getRequestContext().getCurrentUser(), message); // send the broadcast to all authenticated sessions Iterator<CmsSessionInfo> i = m_sessionStorageProvider.getAll().iterator(); 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()); } }
return null; String sessionId = sessionInfo.getSessionId().toString(); Buffer messageQueue = OpenCms.getSessionManager().getBroadcastQueue(sessionId); if (!messageQueue.isEmpty()) {
session.getMaxInactiveInterval()); session.setAttribute(CmsSessionInfo.ATTRIBUTE_SESSION_ID, sessionInfo.getSessionId().clone());
session.getMaxInactiveInterval()); session.setAttribute(CmsSessionInfo.ATTRIBUTE_SESSION_ID, sessionInfo.getSessionId().clone());
while (itSessions.hasNext()) { CmsSessionInfo sessionInfo = itSessions.next(); CmsListItem item = getList().newItem(sessionInfo.getSessionId().toString()); CmsUser user = getCms().readUser(sessionInfo.getUserId()); CmsOrganizationalUnit userOu = OpenCms.getOrgUnitManager().readOrganizationalUnit(
return null; String sessionId = sessionInfo.getSessionId().toString(); Buffer messageQueue = OpenCms.getSessionManager().getBroadcastQueue(sessionId); if (!messageQueue.isEmpty()) {
session.getMaxInactiveInterval()); session.setAttribute(CmsSessionInfo.ATTRIBUTE_SESSION_ID, sessionInfo.getSessionId().clone());