6 Replies Latest reply on Mar 5, 2010 11:27 AM by rajasundaram

    Setting the session variables after successfull login

    tridib197779

      Hi All,

      I want to set some values in session after successfull login in the portal.

      Can you suggest me which is the place that i can do.

      Or

      Which action class is called after succesfull login, so that I can add my own custom code over there to set the session variable

       

      Thanks

      Tridib

        • 1. Re: Setting the session variables after successfull login
          rajasundaram
          Can you give some more information.
          • 2. Re: Setting the session variables after successfull login
            tridib197779

            Hi Raja,

            I have the login.jsp in \server\default\deploy\jboss-portal.sar\portal-server.war.

            Inside that the action path is "j_security_check". After hitting the login button, probably it is going to some action mapping and action class, there I want to set some values in the session.

            I want to know the the particular action class or .java file.

            Or you can suggest me any other way to set up session variable after only successfull login.

             

            Thanks

            Tridib

            • 3. Re: Setting the session variables after successfull login
              jssteux

              Hi,

               

              We have implemented specific fonctions at login (customization of dashboards) by implementing a specific LoginModule (declaration in conf/login-config.xml).

               

              This LoginModule calls our methods which are implemented in a .sar file that we have have also developped .

               

              JS Steux
              • 4. Re: Setting the session variables after successfull login
                tridib197779

                Hi Steux,

                Thanks for your reply.can you be more specific in your point.can you send any sample implementation of the Login module.

                After compilation where actually the loginmodule will go and sit in the server side(where inside the jboss-portal.sar).

                 

                Thanks

                Tridib

                • 5. Re: Setting the session variables after successfull login
                  jssteux

                   

                  public class DashboardLoginModule extends org.jboss.security.auth.spi.UsernamePasswordLoginModule{

                   

                  ...

                      public boolean commit() throws LoginException {

                   

                          // Stockage d'un attribut login en cours
                          try {
                                 
                              performSynchronization(getUsername(), getUsersPassword());
                          } catch (Exception e) {
                              log.error(this, e);
                              throw new RuntimeException(e);
                          }

                   

                          return super.commit();
                      }

                  ...
                  }

                   

                  then copy the jar into server/default/lib (shoud work in jboss-portal.sar)

                  • 6. Re: Setting the session variables after successfull login
                    rajasundaram

                    you can get the httpsession by using the following code.

                     

                    HttpServletRequest httpReq =

                    null;

                     

                    try {

                    httpReq = (HttpServletRequest) PolicyContext.getContext(

                    "javax.servlet.http.HttpServletRequest");

                    }

                    catch(Exception e) {

                    e.printStackTrace(System.

                    out);

                    }

                     

                    session=httpReq.getSession(

                    false);

                     

                    Best way is your CustomLoginModule.