Examples of Identity


Examples of org.olat.core.id.Identity

   * node2 catches the sign on event and invalidates the user on node2 "silently", e.g.
   * without firing an event.
   */
  private void signOffAndClearWithout(){
    Tracing.logDebug("signOffAndClearWithout() START", getClass());
    final Identity ident = identityEnvironment.getIdentity();
    //System.out.println("signOffAndClearWithout, ident="+ident+", hash="+this.hashCode()+", identityenv "+identityEnvironment.hashCode());
    // handle safely
    boolean isDebug = Tracing.isDebugEnabled(UserSession.class);
    if (isDebug) {
      Tracing.logDebug("UserSession:::logging off: " + sessionInfo, this.getClass());
    }

    /**
     * use not RunnableWithException, as exceptionHandlng is inside the run
     */
    Runnable run = new Runnable() {
      public void run() {
        Object obj = null;
        try {
         
          // do logging
          if (ident != null) {
            ThreadLocalUserActivityLogger.log(OlatLoggingAction.OLAT_LOGOUT, UserSession.class, CoreLoggingResourceable.wrap(ident));
          } else {
            //System.out.println("identity is null!!!!!!!!!!!!!!!!!!!!!");
          }
          // notify all variables in the store (the values) about the disposal
          // if
          // Disposable

          for (Iterator it_storevals = new ArrayList(store.values()).iterator(); it_storevals.hasNext();) {
            obj = it_storevals.next();
            if (obj instanceof Disposable) {
              // synchronous, since triggered by tomcat session timeout or user
              // click and
              // asynchronous, if kicked out by administrator.
              // we assume synchronous
              // !!!!
              // As a reminder, this .dispose() calls dispose on
              // DefaultController which is synchronized.
              // (Windows/WindowManagerImpl/WindowBackOfficeImpl/BaseChiefController/../
              // dispose()
              // !!!! was important for bug OLAT-3390

              ((Disposable) obj).dispose();
            }
          }
        } catch (Exception e) {

          String objtostr = "n/a";
          try {
            objtostr = obj.toString();
          } catch (Exception ee) {
            // ignore
          }
          Tracing.logError("exception in signOffAndClear: while disposing object:" + objtostr, e, UserSession.class);
        }
      }
    };

    ThreadLocalUserActivityLoggerInstaller.runWithUserActivityLogger(run, UserActivityLoggerImpl.newLoggerForValueUnbound(this));

    synchronized (authUserSessions) {  //o_clusterOK by:fj
      if(authUserSessions.remove(this)){
        //remove only from identityEnvironment if found in sessions.
        //see also SIDEEFFECT!! line in signOn(..)
        Identity previousSignedOn = identityEnvironment.getIdentity();
        if (previousSignedOn != null) {
          Tracing.logDebug("signOffAndClearWithout() removing from userNameToIdentity: "+previousSignedOn.getName().toLowerCase(), getClass());
          userNameToIdentity.remove(previousSignedOn.getName().toLowerCase());
        }
      }else{
        if (isDebug) {
          Tracing.logInfo("UserSession already removed! for ["+ident+"]", UserSession.class);
        }     
View Full Code Here

Examples of org.olat.core.id.Identity

    //
    signOffAndClearWithout();
    // handle safely
    try {
      if (isAuthenticated()) {
        Identity identity = identityEnvironment.getIdentity();
        Tracing.logAudit("Logged off: " + sessionInfo, this.getClass());
        CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new SignOnOffEvent(identity, false), ORES_USERSESSION);
        Tracing.logDebug("signOffAndClear() deregistering usersession from eventbus, id="+sessionInfo, getClass());
        CoordinatorManager.getCoordinator().getEventBus().deregisterFor(this, ORES_USERSESSION);
        registeredWithBus = false;
View Full Code Here

Examples of org.olat.core.id.Identity

  public synchronized void signOn() {
    //   ^^^^^^^^^^^^ Added synchronized to be symmetric with sign off and to
    //                fix a possible dead-lock see also OLAT-3390
    Tracing.logDebug("signOn() START", getClass());
    if (isAuthenticated()) throw new AssertException("sign on: already signed on!");
    Identity identity = identityEnvironment.getIdentity();
    if (identity == null) throw new AssertException("identity is null in identityEnvironment!");
    if (sessionInfo == null) throw new AssertException("sessionInfo was null for identity " + identity);
    //String login = identity.getName();
    authenticated = true;

    if (sessionInfo.isWebDAV()) {
      // load user prefs
      guiPreferences = PreferencesFactory.getInstance().getPreferencesFor(identity, identityEnvironment.getRoles().isGuestOnly());

      synchronized (authUserSessions) {  //o_clusterOK by:se
        // we're only adding this webdav session to the authUserSessions - not to the userNameToIdentity.
        // userNameToIdentity is only needed for IM which can't do anything with a webdav session
        authUserSessions.add(this);
      }
      Tracing.logAudit("Logged on [via webdav]: " + sessionInfo.toString(), this.getClass());
      return;
    }
   
    Tracing.logDebug("signOn() authUsersNamesOtherNodes.contains "+identity.getName()+": "+authUsersNamesOtherNodes.contains(identity.getName()), getClass());
   
    UserSession invalidatedSession = null;
    synchronized (authUserSessions) {  //o_clusterOK by:fj
        // check if allready a session exist for this user
        if ( (userNameToIdentity.containsKey(identity.getName().toLowerCase()) || authUsersNamesOtherNodes.contains(identity.getName()) )
             && !sessionInfo.isWebDAV() && !this.getRoles().isGuestOnly()) {
            Tracing.logInfo("Loggin-process II: User has already a session => signOffAndClear existing session", this.getClass());
           
            invalidatedSession = getUserSessionFor(identity.getName().toLowerCase());
            //remove session to be invalidated
            //SIDEEFFECT!! to signOffAndClear
            //if invalidatedSession is removed from authUserSessions
            //signOffAndClear does not remove the identity.getName().toLowerCase() from the userNameToIdentity
            //
            authUserSessions.remove(invalidatedSession);
        }
        authUserSessions.add(this);
      // user can choose upercase letters in identity name, but this has no effect on the
      // database queries, the login form or the IM account. IM works only with lowercase
      // characters -> map stores values as such
      Tracing.logDebug("signOn() adding to userNameToIdentity: "+identity.getName().toLowerCase(), getClass());
      userNameToIdentity.put(identity.getName().toLowerCase(), identity);
    }
    // load user prefs
    guiPreferences = PreferencesFactory.getInstance().getPreferencesFor(identity, identityEnvironment.getRoles().isGuestOnly());

    if (!registeredWithBus) {
      // OLAT-3706
      CoordinatorManager.getCoordinator().getEventBus().registerFor(this, null, ORES_USERSESSION);
    }

    Tracing.logAudit("Logged on: " + sessionInfo.toString(), this.getClass());
    CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new SignOnOffEvent(identity, true), ORES_USERSESSION);
   
   
    // THE FOLLOWING CHECK MUST BE PLACED HERE NOT TO PRODUCE A DEAD-LOCK WITH SIGNOFFANDCLEAR
    // check if a session from any browser was invalidated (IE has a cookie set per Browserinstance!!)
    if (invalidatedSession != null || authUsersNamesOtherNodes.contains(identity.getName())) {
      // put flag killed-existing-session into session-store to show info-message 'only one session for each user' on user-home screen
      this.putEntry(STORE_KEY_KILLED_EXISTING_SESSION, Boolean.TRUE);
      Tracing.logDebug("signOn() removing from authUsersNamesOtherNodes: "+identity.getName(), getClass());
      authUsersNamesOtherNodes.remove(identity.getName());
      //OLAT-3381 & OLAT-3382
      if(invalidatedSession != null) invalidatedSession.signOffAndClear();
    }
   
    Tracing.logDebug("signOn() END", getClass());
View Full Code Here

Examples of org.olat.core.id.Identity

    sb.append("</td><td>");
   
    //locked
    if(metaInfo != null) {
      if(metaInfo.isLocked()) {
        Identity lockedBy = identityMap.get(metaInfo.getLockedBy());
        if(lockedBy == null) {
          lockedBy = metaInfo.getLockedByIdentity();
          if(lockedBy != null) {
            identityMap.put(lockedBy.getKey(), lockedBy);
          }
        }
       
        sb.append("<span class=\"b_small_icon b_briefcase_locked_file_icon\" ext:qtip=\"");
        if(lockedBy != null) {
          String firstName = lockedBy.getUser().getProperty(UserConstants.FIRSTNAME, translator.getLocale());
          String lastName = lockedBy.getUser().getProperty(UserConstants.LASTNAME, translator.getLocale());
          String date = "";
          if(metaInfo.getLockedDate() != null) {
            date = fc.getDateTimeFormat().format(metaInfo.getLockedDate());
          }
          sb.append(translator.translate("Locked", new String[]{firstName, lastName, date}));
View Full Code Here

Examples of org.olat.core.id.Identity

      msg.contextPut("debug", Boolean.FALSE);     
    }
    msg.contextPut("listenerInfo", Formatter.escWithBR(componentListenerInfo).toString());     
    msg.contextPut("stacktrace", OLATRuntimeException.throwableToHtml(th));     
   
    Identity curIdent = ureq.getIdentity();
    msg.contextPut("username", curIdent == null? "n/a" : curIdent.getName());
    msg.contextPut("allowBackButton", Boolean.valueOf(allowBackButton));
    msg.contextPut("detailedmessage", detailedmessage);
    // Cluster NodeId + E-Nr
    msg.contextPut("errnum", "N" + CoordinatorManager.getCoordinator().getNodeId() + "-E"+ refNum);
    msg.contextPut("supportaddress", WebappHelper.getMailConfig("mailSupport"));
View Full Code Here

Examples of org.olat.core.id.Identity

    String feedback = request.getParameter("textarea");
    String errorNr = feedback.substring(0, feedback.indexOf("\n") - 1);
    String username = request.getParameter("username");
    try {
            IdentityManager im = (IdentityManager)CoreSpringFactory.getBean("core.id.IdentityManager");
      Identity ident = im.findIdentityByName(username);
      //if null, user may crashed befor getting a valid session, try with guest user instead
      if (ident == null) ident = im.findIdentityByName("guest");
      Emailer emailer = new Emailer(ident, true);
      LogFile lf = new LogFile();
      Date d = new Date();
View Full Code Here

Examples of org.olat.core.id.Identity

  private Address[] createAddressesFromIdentities(List<Identity> recipients, MailerResult result) {
    Address[] addresses = null;
    if (recipients != null && recipients.size() > 0) {
      List<Address> validRecipients = new ArrayList<Address>();
      for (int i = 0; i < recipients.size(); i++) {
        Identity identity = recipients.get(i);
        try {
          validRecipients.add(new InternetAddress(identity.getUser().getProperty(UserConstants.EMAIL, null)));
        } catch (AddressException e) {
          result.addFailedIdentites(identity);
        }
      }
      addresses = validRecipients.toArray(new Address[validRecipients.size()]);
View Full Code Here

Examples of org.olat.core.id.Identity

      //e.g. a worker thread like in Search or UpdateEfficiency worker
      //TODO:pb:check if this was also a problem with IM threads.
      ureq = tld.getHttpServletRequest();
    }
    UserSession usess = null;
    Identity identity = null;
    String remoteIp = null;
    String userAgent = null;
    String referer = null;
    if (ureq != null) {
      usess = UserSession.getUserSessionIfAlreadySet(ureq);
      if (usess != null) {
        identity = usess.getIdentity();
        remoteIp = ureq.getRemoteAddr();
        userAgent = ureq.getHeader("User-Agent");
        referer = ureq.getHeader("Referer");
      }
    }

    StringBuilder sb = new StringBuilder();
    if (!Settings.isDebuging()) {
      sb.append(PREFIX);
      sb.append(category);
      sb.append(SEPARATOR);
      try {
        // Node-Id + Error number e.g. N1-E17
        sb.append("N");
        //FIXME:gs remove access to coordinator: gs accessing coordinator here loads the corespring factory. This means we cannot do unit testing without olat
        // as the first log call will start the whole OLAT stuff.
        sb.append(CoordinatorManager.getCoordinator().getNodeId());
        sb.append("-");
      } catch (Throwable th) {
        //ok
        sb.append(N_A);
      }
       
      sb.append(prefix);
      sb.append(refNum);
      sb.append(SEPARATOR);
      sb.append(callingClass == null ? N_A : callingClass.getPackage().getName());
      sb.append(SEPARATOR);
      sb.append(identity == null ? N_A : identity.getName());
      sb.append(SEPARATOR);
      sb.append(remoteIp == null ? N_A : remoteIp);
      sb.append(SEPARATOR);
      sb.append(referer == null ? N_A : referer);
      sb.append(SEPARATOR);
View Full Code Here

Examples of org.olat.core.id.Identity

      //e.g. a worker thread like in Search or UpdateEfficiency worker
      //TODO:pb:check if this was also a problem with IM threads.
      ureq = tld.getHttpServletRequest();
    }
    UserSession usess = null;
    Identity identity = null;
    String remoteIp = null;
    String userAgent = null;
    String referer = null;
    if (ureq != null) {
      usess = UserSession.getUserSession(ureq);
      identity = usess.getIdentity();
      remoteIp = ureq.getRemoteAddr();
      userAgent = ureq.getHeader("User-Agent");
      referer = ureq.getHeader("Referer");
    }

    StringBuilder sb = new StringBuilder();
    if (!Settings.isDebuging()) {
      sb.append(PREFIX);
      sb.append(category);
      sb.append(SEPARATOR);
      try {
        // Node-Id + Error number e.g. N1-E17
        sb.append("N");
        //FIXME:gs remove access to coordinator: gs accessing coordinator here loads the corespring factory. This means we cannot do unit testing without olat
        // as the first log call will start the whole OLAT stuff.
        sb.append(CoordinatorManager.getCoordinator().getNodeId());
        sb.append("-");
      } catch (Throwable th) {
        //ok
        sb.append(N_A);
      }
      sb.append(prefix);
      sb.append(refNum);
      sb.append(SEPARATOR);
      sb.append(callingClass == null ? N_A : callingClass.getPackage().getName());
      sb.append(SEPARATOR);
      sb.append(identity == null ? N_A : identity.getName());
      sb.append(SEPARATOR);
      sb.append(remoteIp == null ? N_A : remoteIp);
      sb.append(SEPARATOR);
      sb.append(referer == null ? N_A : referer);
      sb.append(SEPARATOR);
View Full Code Here

Examples of org.olat.core.id.Identity

      return;
    }
    Boolean usessReplayUrls = (Boolean)ureq.getUserSession().getEntry(REPLAY_URL);
    //param not found in the session
    if(usessReplayUrls == null){
      Identity changeableIdentity = ureq.getIdentity();
      if(changeableIdentity != null){
        //only hit the Database if an identity is found!
        //see also OLAT-2790
        usessReplayUrls = (Boolean) ureq.getUserSession().getGuiPreferences().get(WindowManager.class, REPLAY_URL);
      } else {
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.