4 Replies Latest reply on Sep 5, 2008 3:38 PM by bashan

    Autologin support

    bashan

      As far as I understand Seam still doesn't support autologin. Is there some example how can it be sone with Seam?


      Thanks.

        • 1. Re: Autologin support
          mteichmann.mark.teichmann.info-ag.de

          If you are using Windows than this page will show you the solution:
          Windows SSO with JBOSS Seam

          • 2. Re: Autologin support
            bashan

            Thanks, but this is not what I meant.


            I meant autologin like in facebook/gmail or any other pupular internet website existing today...

            • 3. Re: Autologin support
              andre.eugenio

              First you should read http://blog.hibernate.org/3266.lace


              Then you should know that Seam 2.1 will support autologin.


              To implement this now i stored custom cookie when the user log in, and my secured pages try to restore the cookie if he is not logged in.


              Look the code below in my pages.xml


                   <page view-id="/auth/*">
              #0          <navigation from-action="#{identity.logout}">
                             <raise-event type="removeLogonCookie" />
                             <redirect view-id="/logon.xhtml" />
                        </navigation>
              #1          <action execute="#{autoLogon.checkLogonCookie}" if="#{!identity.loggedIn}" />
                        <navigation>
              #2               <rule if-outcome="noSessionAvailable">
                                  <redirect view-id="/logon.xhtml" />
                             </rule>
                        </navigation>
                   </page>
              



              #0 If he logged out i have to remove the cookie


              #1 If he is not logged in i try to check the cookie and restore the session


              #2 If no cookie available i redirect to logon page.


                   public String checkLogonCookie() {
                        try {
                             FacesContext context = FacesContext.getCurrentInstance();
                             log.info("Check Cookie from view #0", context.getViewRoot().getViewId());
                             Cookie []cookies = ((HttpServletRequest)context.getExternalContext().getRequest()).getCookies();
                             if(cookies != null) {
                                  for (Cookie cookie : cookies) {
                                       if(cookie.getName().equals("myUserCookie") && cookie.getValue() != null 
                                                 && !cookie.getValue().equals("null")
                                                 && cookie.getValue().length() > 0) {
                                            
                                            String values = CipherUtil.decrypt(cookie.getValue());
                                            log.info("User reconnect by cookie - value: #0", values);
              
                                            Identity.instance().login();
                                            
                                            return "sessionRestored";
                                       }
                                  }
                             }
                        }
                        catch (Exception msg) {
                             log.error("Error trying to restore Cookie Credentials, msg: #0, trace #1", msg.getMessage(), StringUtil.printTrace(msg.getStackTrace()));
                        }
                        
                        Redirect.instance().captureCurrentView();          
                        return "noSessionAvailable";
                   }
              



              Hope this help.


              Cheers, Andre.

              • 4. Re: Autologin support
                bashan

                Thanks!


                Is there already a preview of Seam 2.1?