Examples of UserSession


Examples of org.olat.core.util.UserSession

  /**
   * @param ureq
   * @return the Windows for this user
   */
  public static Windows getWindows(UserRequest ureq) {
    UserSession us = ureq.getUserSession();
    return getWindows(us);
  }
View Full Code Here

Examples of org.olat.core.util.UserSession

      // try to get cached dir context
      if (webDAVManager == null) {
        // not initialized properly
        return null;
      }
      UserSession usess = webDAVManager.getUserSession(hreq);
      if (usess == null) return null;
      try{
        usess.getSessionInfo().setLastClickTime();
      }catch(Throwable th){
          Tracing.logError("getResource failure: ", th, SecureWebdavServlet.class);
      }
      VFSDirContext fdc = (VFSDirContext)usess.getEntry("_DIRCTX");
      if (fdc != null) {
        fdc.setUserSession(usess);
        return fdc;
      }
     
      Identity identity = usess.getIdentity();
      // we need an identity...
      if (identity == null) return null;


      fdc = new VFSDirContext();
      fdc.setIdentity(identity);
      fdc.setUserSession(usess);
      fdc.setVirtualDocBase(WebDAVProviderFactory.getInstance().getMountableRoot(identity));
      fdc.setBuffer(super.input); // take inBuffer from DefaultServlet (configured via web.xml)
      // do not cache while debugging
      if (!Settings.isDebuging()) {
        usess.putEntry("_DIRCTX", fdc);
      }
     
      // OLAT-5243 related: sending back the reply can take arbitrary long,
      // considering slow end-user connections for example - or a sudden death of the connection
      // on the client-side which remains unnoticed (network partitioning)
View Full Code Here

Examples of org.olat.core.util.UserSession

    Map<String, Long> lastActivity = new HashMap<String, Long>();
    Set<String> usernames = InstantMessagingModule.getAdapter().getUsernamesFromConnectedUsers();
    List<UserSession> authSessions = new ArrayList(UserSession.getAuthenticatedUserSessions());
   
    for (Iterator<UserSession> iter = authSessions.iterator(); iter.hasNext();) {
      UserSession userSession = iter.next();
      long lastAccTime = 0;
      try {
        lastAccTime = userSession.getSessionInfo().getSession().getLastAccessedTime();
        lastActivity.put(userSession.getIdentity().getName(), Long.valueOf(lastAccTime));
      } catch (RuntimeException e) {
        //getAuthenticatedUserSessions delivers sessions that are sometimes already invalid.
        log.warn("Tried to get LastAccessTime from session that became in the meantime invalid", null);
      }
View Full Code Here

Examples of org.olat.core.util.UserSession

    Long timeNow = System.currentTimeMillis();

    List<UserSession> authUserSessions = new ArrayList<UserSession>(UserSession.getAuthenticatedUserSessions());

    for (Iterator<UserSession> iter = authUserSessions.iterator(); iter.hasNext();) {
      UserSession session = iter.next();
      long lastAccessTime = 0;
      String username = null;
      InstantMessagingClient client = null;
      boolean isWebDav = false;
      try {
        lastAccessTime = session.getSessionInfo().getLastClickTime();
        username = session.getIdentity().getName();
        isWebDav = session.getSessionInfo().isWebDAV();
      } catch (Exception e) {
        log.info("Tried to get LastAccessTime from session that became in the meantime invalid", e.toString());
      }
      if (!isWebDav) { // leave webdav sessions untouched

        if (InstantMessagingModule.isEnabled()) {
          // avoid reconnection of dead or duplicate sessions
          ClientManager mgr = InstantMessagingModule.getAdapter().getClientManager();
          if (username != null && mgr.hasActiveInstantMessagingClient(username)) client = mgr.getInstantMessagingClient(username);
          if (log.isDebug()) {
            if (client != null) log.debug("Fetched im client via mangager. Connections status is - connected=" + client.isConnected()
                + " for user: " + client.getUsername());
            else log.debug("Could not fetch IM client for user: " + username);
          }
        }
       
        if (session != null) {
          if ((timeNow - lastAccessTime) > autoLogOutCutTime) {
            try {
              // brasato:::: since tomcat doesn't do this in its normal
                // session invalidation process,
                // (since polling), we must do it manually.
                // But: it does not belong here (must work also without IM, but
                // with polling)
                // brasato:: alternative: instead of a job, generate a timer
                // which rechecks if clicked within 5 mins ??

                // TODO: that presence change stuff should also be moved to the
                // IMManager...
                // invalidation triggers dispose of controller chain and closes
                // IM
                // and removes IM client
              try {
                SessionInfo sessionInfo = session.getSessionInfo();
                if (sessionInfo!=null) {
                  HttpSession session2 = sessionInfo.getSession();
                  if (session2!=null) {
                    session2.invalidate();
                  }
View Full Code Here

Examples of org.olat.core.util.UserSession

    Set usesss = UserSession.getAuthenticatedUserSessions();
    int contcnt = DefaultController.getControllerCount();
    sb.append("total usersessions (auth and non auth): "+ucCnt+"<br />auth usersessions: "+usesss.size()+"<br />Total Controllers (active, not disposed) of all users:"+contcnt+"<br /><br />");
    Formatter f = Formatter.getInstance(ureq.getLocale());
    for (Iterator iter = usesss.iterator(); iter.hasNext();) {
      UserSession usess = (UserSession) iter.next();
      Identity iden = usess.getIdentity();
      sb.append("authusersession (").append(usess.hashCode()).append(") of ");
      if (iden != null) {
        sb.append(iden.getName()).append(" ").append(iden.getKey());
      }
      else {
        sb.append(" - ");
View Full Code Here

Examples of org.olat.core.util.UserSession

   * @param request
   * @param response
   * @param uriPrefix
   */
  public void execute(HttpServletRequest request, HttpServletResponse response, String uriPrefix) {
    UserSession usess = UserSession.getUserSession(request);
    UserRequest ureq = null;
    try{
      //upon creation URL is checked for
      ureq = new UserRequest(uriPrefix, request, response);
    } catch(NumberFormatException nfe) {
      //MODE could not be decoded
      //typically if robots with wrong urls hit the system
      //or user have bookmarks
      //or authors copy-pasted links to the content.
      //showing redscreens for non valid URL is wrong instead
      //a 404 message must be shown -> e.g. robots correct their links.
      if(Tracing.isDebugEnabled(AuthenticatedDispatcher.class)){
        Tracing.logDebug("Bad Request "+request.getPathInfo(), this.getClass());
      }
      DispatcherAction.sendBadRequest(request.getPathInfo(), response);
      return;
    }
    GUIInterna.setLoadPerformanceMode(ureq);   
   
    boolean auth = usess.isAuthenticated();

    if (!auth) {
      if (!ureq.isValidDispatchURI()) {
        // might be a direct jump request -> remember it if not logged in yet
        String reqUri = request.getRequestURI();
        String query = request.getQueryString();
        String allGet = reqUri + QUESTIONMARK + query;
        usess.putEntryInNonClearedStore(AUTHDISPATCHER_ENTRYURL, allGet);
      }
      String guestAccess = ureq.getParameter(GUEST);
      if (guestAccess == null || !LoginModule.isGuestLoginLinksEnabled()) {
        DispatcherAction.redirectToDefaultDispatcher(response);
        return;
      } else if (guestAccess.equals(TRUE)) {
        // try to log in as anonymous
        // use the language from the lang paramter if available, otherwhise use the system default locale
        String guestLang = ureq.getParameter("lang");
        Locale guestLoc;
        if (guestLang == null) {
          guestLoc = I18nModule.getDefaultLocale();
        } else {
          guestLoc = I18nManager.getInstance().getLocaleOrDefault(guestLang);
        }
        int loginStatus = AuthHelper.doAnonymousLogin(ureq, guestLoc);
        if ( loginStatus != AuthHelper.LOGIN_OK) {
          if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
            DispatcherAction.redirectToServiceNotAvailable(response);
          }
          DispatcherAction.redirectToDefaultDispatcher(response); // error, redirect to login screen
          return;
        }
        // else now logged in as anonymous user, continue
      }
    }

    // authenticated!
    try {
     
      //kill session if not secured via SSL
      if (forceSecureAccessOnly && !request.isSecure()) {
        SessionInfo sessionInfo = usess.getSessionInfo();
        if (sessionInfo!=null) {
          HttpSession session = sessionInfo.getSession();
          if (session!=null) {
            try{
              session.invalidate();
            } catch(IllegalStateException ise) {
              // thrown when session already invalidated. fine. ignore.
            }
          }
        }
        DispatcherAction.redirectToDefaultDispatcher(response);
        return;
      }
     
      SessionInfo sessionInfo = usess.getSessionInfo();
      if (sessionInfo==null) {
        DispatcherAction.redirectToDefaultDispatcher(response);
        return;
      }
     
      UserBasedLogLevelManager.activateUsernameBasedLogLevel(sessionInfo.getLogin());
     
      sessionInfo.setLastClickTime();
      String origUrl = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_ENTRYURL);
      if (origUrl != null) {
        // we had a direct jump request
        // to avoid a endless redirect, remove the guest parameter if any
        // this can happen if a guest has cookies disabled
        String url = new URIHelper(origUrl).removeParameter(GUEST).toString();
        DispatcherAction.redirectTo(response, url);
        return;
      }
      String businessPath = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_BUSINESSPATH);
      if (businessPath != null) {
        BusinessControl bc = BusinessControlFactory.getInstance().createFromString(businessPath);
        ChiefController cc = (ChiefController) Windows.getWindows(usess).getAttribute("AUTHCHIEFCONTROLLER");

        WindowControl wControl = cc.getWindowControl();
View Full Code Here

Examples of org.olat.core.util.UserSession

    }
   
    //
    // create the olat ureq and get an associated main window to spawn the "tab"
    //
    UserSession usess = UserSession.getUserSession(request);
    UserRequest ureq = null;
    try {
      //upon creation URL is checked for
      ureq = new UserRequest(uriPrefix, request, response);
    } catch(NumberFormatException nfe) {
      //MODE could not be decoded
      //typically if robots with wrong urls hit the system
      //or user have bookmarks
      //or authors copy-pasted links to the content.
      //showing redscreens for non valid URL is wrong instead
      //a 404 message must be shown -> e.g. robots correct their links.
      if(log.isDebug()){
        log.debug("Bad Request "+request.getPathInfo());
      }
      DispatcherAction.sendBadRequest(request.getPathInfo(), response);
      return;
    }
    GUIInterna.setLoadPerformanceMode(ureq);   
   
    boolean auth = usess.isAuthenticated();
    if (auth) {
      usess.putEntryInNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_BUSINESSPATH, businessPath);
     
      String url = getRedirectToURL(usess);
      DispatcherAction.redirectTo(response, url);
    } else {
      //prepare for redirect
      usess.putEntryInNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_BUSINESSPATH, businessPath);

      String guestAccess = ureq.getParameter(AuthenticatedDispatcher.GUEST);
      if (guestAccess == null || !LoginModule.isGuestLoginLinksEnabled()) {
        DispatcherAction.redirectToDefaultDispatcher(response);
        return;
View Full Code Here

Examples of org.olat.core.util.UserSession

   * @param request
   * @param response
   * @param uriPrefix
   */
  public void execute(HttpServletRequest request, HttpServletResponse response, String uriPrefix) {
    UserSession usess = UserSession.getUserSession(request);
    UserRequest ureq = null;

    try {
      ureq = new UserRequest(uriPrefix, request, response);
      boolean auth = usess.isAuthenticated();

      if (!auth ||   !ureq.isValidDispatchURI()) {
        // String lang =
        // I18nManager.getInstance().getDefaultLocale().toString();
        Identity ident = ManagerFactory.getManager().findIdentityByName("administrator");

        usess.signOffAndClear();
        usess.setIdentity(ident);
        usess.setRoles(new Roles(true, true, true, true, false, true));
        usess.setLocale(I18nManager.getInstance().getLocaleOrDefault(ident.getUser().getPreferences().getLanguage()));

        // brasato:: was
        // Windows.getWindows(ureq).getWindowManager().getGlobalSettings().setFontSize(
        // identity.getUser().getPreferences().getFontsize() );
        Windows.getWindows(ureq).setAttribute("fontsize", ident.getUser().getPreferences().getFontsize());

        AuthHelper.setSessionInfoFor(ident, OLATAuthenticationController.PROVIDER_OLAT, ureq);
        // put users personal rss token into session
        RSSUtil.putPersonalRssTokenInSession(ureq);
        // confirm signedOn
        usess.signOn();

        //
        Windows.getWindows(ureq).getWindowManager().setAjaxWanted(ureq, true);

        // successfull login, reregister window
View Full Code Here

Examples of org.olat.core.util.UserSession

   
  /**
   * @see org.olat.core.dispatcher.Dispatcher#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
   */
  public void execute(HttpServletRequest request, HttpServletResponse response, String uriPrefix) {
    UserSession usess = UserSession.getUserSession(request);
    UserRequest ureq = null;
    try{
      //upon creation URL is checked for
      ureq = new UserRequest(uriPrefix, request, response);
    }catch(NumberFormatException nfe){
View Full Code Here

Examples of org.olat.core.util.UserSession

    }
   
    UserRequest ureq = new UserRequest(uriPrefix, request, response);
    //String sessionId = request.getRequestedSessionId();
    try {
      UserSession usess = ureq.getUserSession();
      Windows ws = Windows.getWindows(usess);
      synchronized (ws) {  //o_clusterOK by:fj

        Window window;
        boolean windowHere = ws.isExisting(ureq.getWindowID());
        boolean validDispatchUri = ureq.isValidDispatchURI();
        if (validDispatchUri && !windowHere) {
          // probably valid framework link from previous user && new Session(no window):
          // when a previous user logged off, and 30min later (when the httpsession is invalidated), the next user clicks e.g. on
          // the log-in link in the -same- browser window ->
          // -> there is no window -> create a new one
          window = null;
          usess.signOffAndClear();
          // request new windows since it is a new usersession, the old one was purged
          ws = Windows.getWindows(usess);
        } else {
          if (validDispatchUri) {
            window = ws.getWindow(ureq);
          } else {
            // e.g. /dmz/ -> start screen, clear previous session data
            window = null;
            usess.signOffAndClear();
            // request new windows since it is a new usersession, the old one was purged
            ws = Windows.getWindows(usess);
          }
        }
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.