[ 
https://jira.duraspace.org/browse/DS-1376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ivan Masár updated DS-1376:
---------------------------

    Labels: has-patch  (was: )
    
> Suggestion for update last_active database field on logon
> ---------------------------------------------------------
>
>                 Key: DS-1376
>                 URL: https://jira.duraspace.org/browse/DS-1376
>             Project: DSpace
>          Issue Type: Improvement
>          Components: DSpace API
>    Affects Versions: 3.0
>            Reporter: Onivaldo Rosa Junior
>              Labels: has-patch
>
> 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;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to