Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-1376

Suggestion for update last_active database field on logon

    XMLWordPrintable

    Details

    • Attachments:
      0
    • Comments:
      1
    • Documentation Status:
      In Description

      Description

      Suggestion for update last_active database field on logon

      Affect file AuthenticationManager.java (+ = add lines)

      + import java.util.Date;
      + import org.apache.log4j.Logger;
      + import org.dspace.authorize.AuthorizeException;

      public class AuthenticationManager
      {
      /** List of authentication methods, highest precedence first. */
      private static AuthenticationMethod methodStack[] =
      (AuthenticationMethod[])PluginManager.getPluginSequence("authentication", AuthenticationMethod.class);

      + /** log4j logger */
      + private static Logger log = Logger.getLogger(EPerson.class);

      /**

      • Test credentials for authenticity.
        ....
        ....

      private static int authenticateInternal(Context context,
      String username,
      String password,
      String realm,
      HttpServletRequest request,
      boolean implicitOnly)
      {
      // better is lowest, so start with the highest.
      int bestRet = AuthenticationMethod.BAD_ARGS;

      // return on first success, otherwise "best" outcome.
      for (int i = 0; i < methodStack.length; ++i)
      {
      if (!implicitOnly || methodStack[i].isImplicit())
      {
      int ret = 0;
      try

      { ret = methodStack[i].authenticate(context, username, password, realm, request); }

      catch (SQLException e)

      { ret = AuthenticationMethod.NO_SUCH_USER; }

      if (ret == AuthenticationMethod.SUCCESS)
      {
      + EPerson me = context.getCurrentUser();
      + me.setLastActive(new Date());
      + try
      +

      { + me.update(); + }

      catch (SQLException ex)
      +

      { + log.error("Could not update last-active timestamp", ex); + } catch (AuthorizeException ex)
      + {+ log.error("Could not update last-active timestamp", ex);+ }

      return ret;
      }
      if (ret < bestRet)

      { bestRet = ret; }

      }
      }
      return bestRet;
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              onivaldo Onivaldo Rosa Junior
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: