Package org.olat.core.util

Examples of org.olat.core.util.SessionInfo


                // 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();
                  }
                }
              } catch (IllegalStateException ise) {
View Full Code Here


              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);
View Full Code Here

    // 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
View Full Code Here

   
    assertTrue("isactivated", DBModule.isActivated());
   
    User user = UserManager.getInstance().createAndPersistUser("foo","bar","foo@bar.goo");
    Identity identity = ManagerFactory.getManager().createAndPersistIdentity("foo", user, "me", "foo", "bar");
    userSession.setSessionInfo(new SessionInfo("user", session));
    userSession.setIdentity(identity);
    ual.frameworkSetSession(userSession);
    System.out.println("********************************************************");
    System.out.println("Starting ReproduceCompilerFreakout Test... Runs Forever!");
    System.out.println("********************************************************");
 
View Full Code Here

    if (command.equals("users")) { // get user stats of (authenticated) usersessions
      Set userSessions = UserSession.getAuthenticatedUserSessions();
      for (Iterator it_usess = userSessions.iterator(); it_usess.hasNext();) {
        UserSession usess = (UserSession) it_usess.next();
        activeSessionCnt++;
        SessionInfo sessInfo = usess.getSessionInfo();
        if (sessInfo.isSecure()) httpsCount++;
      }
      result.append(activeSessionCnt); // active authenticated sessions
      result.append("\n");
      result.append(httpsCount); // ,,, of which are secure
      result.append("\n0\n");
      result.append(instanceId);
    } else if (command.equals("webdav")) { // get webdav stats of (authenticated) usersessions
      Set userSessions = UserSession.getAuthenticatedUserSessions();
      int webdavcount = 0;
      int securewebdavcount = 0;
      for (Iterator it_usess = userSessions.iterator(); it_usess.hasNext();) {
        UserSession usess = (UserSession) it_usess.next();
        SessionInfo sessInfo = usess.getSessionInfo();
        if (sessInfo.isWebDAV()) {
          webdavcount++;
          if (sessInfo.isSecure()) securewebdavcount++;
        }
      }
      result.append(webdavcount); // webdav sessions
      result.append("\n");
      result.append(securewebdavcount); // ,,, of which are secure
View Full Code Here

  /**
   * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int)
   */
  public Object getValueAt(int row, int col) {
    UserSession usess = (UserSession)getObject(row);
    SessionInfo sessInfo = usess.getSessionInfo();
    if (usess.isAuthenticated()) {
      switch (col) {
        case 0: return sessInfo.getLastname();
        case 1: return sessInfo.getFirstname();
        case 2: return sessInfo.getLogin();
        case 3: return sessInfo.getAuthProvider();
        case 4: return sessInfo.getFromFQN();
        case 5: try {
          //from nano to milli!!
          return new Date(sessInfo.getLastClickTime());
          //return new Date(sessInfo.getSession().getLastAccessedTime());
        } catch (Exception ise) {
          return null; // "Invalidated"; but need to return a date or null
        }
        case 6: try {
          return sessInfo.getSessionDuration()/1000;
        }catch (Exception ise){
          return -1;
        }
        case 7:
          boolean ajaxOn = Windows.getWindows(usess).getWindowManager().isAjaxEnabled();
View Full Code Here

   */
  public void event(UserRequest ureq, Controller source, Event event) {
    if (source == dialogController) {
      if (DialogBoxUIFactory.isYesEvent(event)) {
        UserSession usess = (UserSession) usessTableModel.getObject(selRow);
        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() );
        }
        reset();
      }
    }
    else if (source == tableCtr) {
      if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
        TableEvent te = (TableEvent) event;
        selRow = te.getRowId();
        // session info (we only have authenticated sessions here
        UserSession usess = (UserSession) usessTableModel.getObject(selRow);
        //if (!usess.isAuthenticated()) throw new AssertException("usersession was not authenticated!?");
        myContent.setPage(VELOCITY_ROOT + "/sessionDetails.html");
        myContent.contextPut("us", usess);
        SessionInfo sessInfo = usess.getSessionInfo();
        myContent.contextPut("si", sessInfo);
        boolean isAuth = usess.isAuthenticated();
        myContent.contextPut("isauth", isAuth? "yes" : "-- NOT AUTHENTICATED!");

        long creatTime = -1;
        long lastAccessTime = -1;
       
        boolean success = false;
        if (isAuth) {
          try {
            HttpSession se = sessInfo.getSession();
            creatTime = se.getCreationTime();
            lastAccessTime = se.getLastAccessedTime();
            success = true;
          } catch (Exception ise) {
            // nothing to do
          }
        }
       
        if (success) {
          myContent.contextPut("created", f.formatDateAndTime(new Date(creatTime)));
          myContent.contextPut("lastaccess", f.formatDateAndTime(new Date(lastAccessTime)));
        } else {
          myContent.contextPut("created", " -- this session has been invalidated --");
          myContent.contextPut("lastaccess", " -- this session has been invalidated --");
        }
       
        if (success) {
          // lock information
          String username = sessInfo.getLogin();
          ArrayList lockList = new ArrayList();
          List<LockEntry> locks = CoordinatorManager.getCoordinator().getLocker().adminOnlyGetLockEntries();
          Formatter f = Formatter.getInstance(ureq.getLocale());
          for (LockEntry entry : locks) {
            if (entry.getOwner().getName().equals(username)) {
View Full Code Here

    // 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.
View Full Code Here

   * @param authProvider
   * @param ureq
   */
  public static void setSessionInfoFor(Identity identity, String authProvider, UserRequest ureq) {
    HttpSession session = ureq.getHttpReq().getSession();
    SessionInfo sinfo = new SessionInfo(identity.getName(), session);
    sinfo.setFirstname(identity.getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale()));
    sinfo.setLastname(identity.getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale()));
    sinfo.setFromIP(ureq.getHttpReq().getRemoteAddr());
    sinfo.setFromFQN(ureq.getHttpReq().getRemoteAddr());
    try {
      InetAddress[] iaddr = InetAddress.getAllByName(ureq.getHttpReq().getRemoteAddr());
      if (iaddr.length > 0) sinfo.setFromFQN(iaddr[0].getHostName());
    } catch (UnknownHostException e) {
      //       ok, already set IP as FQDN
    }
    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

TOP

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

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.