0 Replies Latest reply on Feb 21, 2013 10:45 PM by shenlanemo

    how to get AuthenticationStatus in a jsp page?

    shenlanemo

      i use jsp page,not jsf.

       

      i want to know AuthenticationStatus in a jsp page.

       

      for example, i inject HttpSession session into Authenticator Class.

      ---------------------------------------------------

      public class SimpleAuthenticator extends BaseAuthenticator implements Authenticator {

         @Inject Credentials credentials;

         @Inject HttpSession session;

         @Override

         public void authenticate() {

            if ("demo".equals(credentials.getUsername()) &&

                  credentials.getCredential() instanceof PasswordCredential &&

                  "demo".equals(((PasswordCredential) credentials.getCredential()).getValue()))  {

               setStatus(AuthenticationStatus.SUCCESS);

               setUser(new SimpleUser("demo"));

               System.out.println("SUCCESS.");

               ********************************************

               session.setAttribute("islogin", "YES");// i keep islogin status in session

               ********************************************

            }else{

                setStatus(AuthenticationStatus.FAILURE);

                System.out.println("FAILURE.");

                session.setAttribute("islogin", "NO");

            }

         }

      }

      ---------------------------------------------------

      my question is:

      after user login succeed and before session timeout,

      if AuthenticationStatus is same width session("islogin")?