Package org.olat.core.util

Examples of org.olat.core.util.UserSession


    sinfo.setAuthProvider(authProvider);
    sinfo.setUserAgent(ureq.getHttpReq().getHeader("User-Agent"));
    sinfo.setSecure(ureq.getHttpReq().isSecure());
    sinfo.setLastClickTime();
    // set session info for this session
    UserSession usess = ureq.getUserSession();
    usess.setSessionInfo(sinfo);
    // For Usertracking, let the User object know about some desired/specified infos from the sessioninfo
    Map<String,String> sessionInfoForUsertracking = new HashMap<String, String>();
    sessionInfoForUsertracking.put("language", usess.getLocale().toString());
    sessionInfoForUsertracking.put("authprovider", authProvider);
    sessionInfoForUsertracking.put("iswebdav", String.valueOf(sinfo.isWebDAV()));
    usess.getIdentityEnvironment().setAttributes(sessionInfoForUsertracking);
   
  }
View Full Code Here


          sub = pathInfo;
        }
        // chief controller creator for sub path, e.g.
        subPathccc = dmzServicesByPath.get(sub);
       
        UserSession usess = ureq.getUserSession();
        Windows ws = Windows.getWindows(usess);
        synchronized (ws) { //o_clusterOK by:fj per user session
          ChiefController occ;
          if(subPathccc != null){
            occ = subPathccc.createChiefController(ureq);
            Window window = occ.getWindow();
            window.setUriPrefix(uriPrefix);
            ws.registerWindow(window);
           
            window.dispatchRequest(ureq, true);
            return;
          }         
        }
      }//else a /olat/dmz/ request
      /*
       * create content as it is defined in config.xml in he dmzbean
       */

      /*
       * solve this with a predispatcher action
       */
     
//      // convenience method to jump immediatly to AAI (Shibboleth) home
//      // organisation for login without selecting home organisation manually
//      if (ShibbolethModule.isEnableShibbolethLogins()) {
//        String preSelIdp = request.getParameter("preselection");
//        String redirect = request.getParameter("redirect");
//        if (preSelIdp != null && redirect != null && redirect.equalsIgnoreCase("true")) {
//          preSelIdp = preSelIdp.toLowerCase();
//          Collection sites = IdPSite.getIdPSites(ShibbolethModule.getMetadata());
//          for (Iterator iter = sites.iterator(); iter.hasNext();) {
//            IdPSite site = (IdPSite) iter.next();
//            if (site.getName().toLowerCase().indexOf(preSelIdp) > -1) {
//              response.sendRedirect(AssertionConsumerService.buildRequest(request.getLocale(), site));
//              break;
//            }
//          }
//        }
//      }

      UserSession usess = ureq.getUserSession();
      Windows ws = Windows.getWindows(usess);
      synchronized (ws) { //o_clusterOK by:fj per user session

        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();
          usess.setLocale(LocaleNegotiator.getPreferedLocale(ureq));
          // 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();
            usess.setLocale(LocaleNegotiator.getPreferedLocale(ureq));
            // request new windows since it is a new usersession, the old one was purged
            ws = Windows.getWindows(usess);
          }
        }
       
View Full Code Here

  /**
   * @see org.olat.commons.servlets.WebDAVManager#handleAuthentication(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  protected boolean handleAuthentication(HttpServletRequest req, HttpServletResponse resp) {
    UserSession usess = handleBasicAuthentication(req, resp);
    if (usess == null) return false;

    // register usersession in REQUEST, not session !!
    // see SecureWebDAVServlet.setAuthor() and checkQuota()
    req.setAttribute(SecureWebdavServlet.REQUEST_USERSESSION_KEY, usess);
View Full Code Here

  private UserSession handleBasicAuthentication(HttpServletRequest request, HttpServletResponse response) {
    // Get the Authorization header, if one was supplied
    String authHeader = request.getHeader("Authorization");
    if (authHeader != null) {
      // fetch user session from a previous authentication
      UserSession usess = (UserSession)timedSessionCache.get(authHeader);
      if (usess != null && usess.isAuthenticated()) return usess;
     
      StringTokenizer st = new StringTokenizer(authHeader);
      if (st.hasMoreTokens()) {
        String basic = st.nextToken();

        // We only handle HTTP Basic authentication
        if (basic.equalsIgnoreCase("Basic")) {
          String credentials = st.nextToken();

          // This example uses sun.misc.* classes.
          // You will need to provide your own
          // if you are not comfortable with that.
          String userPass = Base64Decoder.decode(credentials);

          // The decoded string is in the form
          // "userID:password".
          int p = userPass.indexOf(":");
          if (p != -1) {
            String userID = userPass.substring(0, p);
            String password = userPass.substring(p + 1);
           
            // Validate user ID and password
            // and set valid true if valid.
            // In this example, we simply check
            // that neither field is blank
            Identity identity = WebDAVAuthManager.authenticate(userID, password);
            if (identity != null) {
              usess = UserSession.getUserSession(request);
              usess.signOffAndClear();
              usess.setIdentity(identity);
              UserDeletionManager.getInstance().setIdentityAsActiv(identity);
              // set the roles (admin, author, guest)
              Roles roles = ManagerFactory.getManager().getRoles(identity);
              usess.setRoles(roles);
              // set authprovider
              //usess.getIdentityEnvironment().setAuthProvider(OLATAuthenticationController.PROVIDER_OLAT);
           
              // set session info
              SessionInfo sinfo = new SessionInfo(identity.getName(), request.getSession());
              User usr = identity.getUser();
              sinfo.setFirstname(usr.getProperty(UserConstants.FIRSTNAME, null));
              sinfo.setLastname(usr.getProperty(UserConstants.LASTNAME, null));
              sinfo.setFromIP(request.getRemoteAddr());
              sinfo.setFromFQN(request.getRemoteAddr());
              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(OLATAuthenticationController.PROVIDER_OLAT);
              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);
              //
              usess.signOn();
              timedSessionCache.put(authHeader, usess);
              return usess;
            }
          }
        }
View Full Code Here

TOP

Related Classes of org.olat.core.util.UserSession

Copyright © 2018 www.massapicom. 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.