private SessionsVO getSessionsVO() { SessionsVO vo = new SessionsVO(); SessionStatsManager sessionStatsManager = CoreSpringFactory.getImpl(SessionStatsManager.class); UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class); vo.setCount(sessionManager.getUserSessionsCnt()); Set<UserSession> userSessions = sessionManager.getAuthenticatedUserSessions(); int webdavcount = 0; int secureWebdavCount = 0; int authenticatedcount = 0; int secureAuthenticatedCount = 0; int restCount = 0; int secureRestCount = 0; for (UserSession usess : userSessions) { SessionInfo sessInfo = usess.getSessionInfo(); if (sessInfo.isWebDAV()) { webdavcount++; if (sessInfo.isSecure()) { secureWebdavCount++; } } else if (sessInfo.isREST()) { restCount++; if (sessInfo.isSecure()) { secureRestCount++; } } else { authenticatedcount++; if (sessInfo.isSecure()) { secureAuthenticatedCount++; } } } vo.setAuthenticatedCount(authenticatedcount); vo.setSecureAuthenticatedCount(secureAuthenticatedCount); vo.setWebdavCount(webdavcount); vo.setSecureWebdavCount(secureWebdavCount); vo.setRestCount(restCount); vo.setSecureRestCount(secureRestCount); // Instant messaging vo.setInstantMessagingCount(-1); SessionsStats statsLastMinute = sessionStatsManager.getSessionsStatsLast(60); SessionsStats statsLast5Minutes = sessionStatsManager.getSessionsStatsLast(300); vo.setAuthenticatedClickCountLastMinute(statsLastMinute.getAuthenticatedClickCalls()); vo.setAuthenticatedClickCountLastFiveMinutes(statsLast5Minutes.getAuthenticatedPollerCalls()); vo.setAuthenticatedPollCountLastMinute(statsLastMinute.getAuthenticatedPollerCalls()); vo.setAuthenticatedPollCountLastFiveMinutes(statsLast5Minutes.getAuthenticatedPollerCalls()); vo.setRequestLastMinute(statsLastMinute.getRequests()); vo.setRequestLastFiveMinutes(statsLast5Minutes.getRequests()); vo.setConcurrentDispatchThreads(sessionStatsManager.getConcurrentCounter()); return vo; }
private UserSession afterAuthorization(Identity identity, HttpServletRequest request) { UserSession usess = sessionManager.getUserSession(request); synchronized (usess) { // double check to prevent severals concurrent login if (usess.isAuthenticated()) { return usess; } sessionManager.signOffAndClear(usess); usess.setIdentity(identity); UserDeletionManager.getInstance().setIdentityAsActiv(identity); // set the roles (admin, author, guest) Roles roles = BaseSecurityManager.getInstance().getRoles(identity); usess.setRoles(roles); // set session info SessionInfo sinfo = new SessionInfo(identity.getKey(), identity.getName(), request.getSession()); User usr = identity.getUser(); sinfo.setFirstname(usr.getProperty(UserConstants.FIRSTNAME, null)); sinfo.setLastname(usr.getProperty(UserConstants.LASTNAME, null)); String remoteAddr = request.getRemoteAddr(); sinfo.setFromIP(remoteAddr); sinfo.setFromFQN(remoteAddr); try { InetAddress[] iaddr = InetAddress.getAllByName(request.getRemoteAddr()); if (iaddr.length > 0) sinfo.setFromFQN(iaddr[0].getHostName()); } catch (UnknownHostException e) { // ok, already set IP as FQDN } sinfo.setAuthProvider(BaseSecurityModule.getDefaultAuthProviderIdentifier()); sinfo.setUserAgent(request.getHeader("User-Agent")); sinfo.setSecure(request.isSecure()); sinfo.setWebDAV(true); sinfo.setWebModeFromUreq(null); // set session info for this session usess.setSessionInfo(sinfo); // sessionManager.signOn(usess); return usess; } }
/** * @see * org.olat.core.commons.services.webdav.WebDAVManager#handleAuthentication(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public boolean handleAuthentication(HttpServletRequest req, HttpServletResponse resp) { UserSession usess = sessionManager.getUserSession(req); if (usess != null && usess.isAuthenticated()) { req.setAttribute(REQUEST_USERSESSION_KEY, usess); return true; } usess = doAuthentication(req, resp); if (usess == null) { return false; } // register usersession in REQUEST, not session !! // see SecureWebDAVServlet.setAuthor() and checkQuota() req.setAttribute(REQUEST_USERSESSION_KEY, usess); return true; }