Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-2257

Raise a session expired and new session event on occurence

    Details

    • Type: Feature Request
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0.GA
    • Fix Version/s: The future
    • Component/s: Security
    • Labels:

      Description

      You have to make some assumptions here, but you can basically notify the user when the server session has ended with the following in a PhaseListener:

      Code:

      @Observer("org.jboss.seam.beforePhase")
      public void beforePhase(PhaseEvent event)
      {
      if(event.getPhaseId() == PhaseId.RESTORE_VIEW)
      {
      HttpServletRequest request =
      (HttpServletRequest) FacesContext.getCurrentInstance()
      .getExternalContext().getRequest();

      if(request.getRequestedSessionId() != null
      && request.getSession().isNew())
      Events.instance().raiseEvent("org.jboss.seam.sessionExpired");
      ...

      Based on general cookie settings this will raise the event when the user still has the browser window open, the http session expired, and the user tries to access the app. If the user closes and reopens the browser to start the application, the event will not be raised. This of course makes the assumption that cookies expire when the browser session is ended (which is generally the case).

      The org.jboss.seam.newSession event would simply change the condition to:

      if(request.getRequestedSessionId() == null
      && request.getSession().isNew())
      Events.instance().raiseEvent("org.jboss.seam.newSession");

      This is generally useful for user notification on the login screen. Please see the forum reference for more information. Thanks.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jacob.orshalick Jacob Orshalick
                  Reporter:
                  jacob.orshalick Jacob Orshalick
                • Votes:
                  26 Vote for this issue
                  Watchers:
                  18 Start watching this issue

                  Dates

                  • Created:
                    Updated: