use of org.olat.core.util.SessionInfo in project openolat by klemens.
the class UserSessionDetailsController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == dialogController) {
if (DialogBoxUIFactory.isYesEvent(event)) {
SessionInfo sessInfo = usess.getSessionInfo();
if (usess.isAuthenticated()) {
HttpSession session = sessInfo.getSession();
if (session != null) {
try {
session.invalidate();
} catch (IllegalStateException ise) {
// thrown when session already invalidated. fine. ignore.
}
}
showInfo("sess.kill.done", sessInfo.getLogin());
}
}
}
}
use of org.olat.core.util.SessionInfo in project OpenOLAT by OpenOLAT.
the class RestApiLoginFilter method upgradeIpAuthentication.
private void upgradeIpAuthentication(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
UserSessionManager sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
UserSession usess = sessionManager.getUserSessionIfAlreadySet(request);
if (usess == null) {
usess = sessionManager.getUserSession(request.getSession(true));
}
if (usess.getIdentity() == null) {
usess.setRoles(new Roles(false, false, false, false, false, false, false));
String remoteAddr = request.getRemoteAddr();
SessionInfo sinfo = new SessionInfo(new Long(-1), "REST", request.getSession());
sinfo.setFirstname("REST");
sinfo.setLastname(remoteAddr);
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("IP");
sinfo.setUserAgent(request.getHeader("User-Agent"));
sinfo.setSecure(request.isSecure());
sinfo.setREST(true);
sinfo.setWebModeFromUreq(null);
// set session info for this session
usess.setSessionInfo(sinfo);
}
UserRequest ureq = null;
try {
// upon creation URL is checked for
String requestURI = request.getRequestURI();
ureq = new UserRequestImpl(requestURI, request, response);
ureq.getUserSession().putEntryInNonClearedStore(RestSecurityHelper.SYSTEM_MARKER, Boolean.TRUE);
} catch (NumberFormatException nfe) {
response.sendError(401);
return;
}
request.setAttribute(RestSecurityHelper.SEC_USER_REQUEST, ureq);
}
use of org.olat.core.util.SessionInfo in project OpenOLAT by OpenOLAT.
the class OpenOLATStatisticsWebService method getSessionsVO.
protected 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;
}
use of org.olat.core.util.SessionInfo in project OpenOLAT by OpenOLAT.
the class MapperServiceTest method createUserSession.
private UserSession createUserSession() {
HttpSession httpSession = new MockHttpSession();
UserSession userSession = sessionManager.getUserSession(httpSession);
SessionInfo infos = new SessionInfo(CodeHelper.getRAMUniqueID(), UUID.randomUUID().toString(), httpSession);
userSession.setSessionInfo(infos);
// check if our mocked HTTP session makes what we want
Assert.assertNotNull(userSession.getSessionInfo());
Assert.assertNotNull(userSession.getSessionInfo().getSession());
Assert.assertNotNull(userSession.getSessionInfo().getSession().getId());
return userSession;
}
use of org.olat.core.util.SessionInfo in project OpenOLAT by OpenOLAT.
the class WebDAVManagerImpl method afterAuthorization.
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;
}
}
Aggregations