0 Replies Latest reply on May 6, 2010 3:29 AM by leandro godoy

    Jboss-JAS-SEAM PROBLEM

    leandro godoy Apprentice

      Hello everybody

      I have a problem and would like to share with the group. It is this:

      Today we have some projects that use authentication via a LoginModule (JAAS) in AD all using the JSF. Well, everything functioned perfectly. However, this week I came across a certain problem:

      I was creating a way to customize authentication, how? The programmer can create a form and a ManageBean receiving a logiN and password and it authenticates to the LoginModule. Blz .. everything right so far ... but in tests realizandos happens that ... authentication is done with JBoss, so he DOES Authentication in JBoss, but when he returns to the JSF application the user is not authenticated.

      How so?
      If I use the default implementation of JAAS with JSF and run the following line:
      plaincopy clipboardprint to view?

         1. FacesContext fc  FacesContext.getCurrentInstance ();
         2. fc.getExternalContext (). isUserInRole (signed);

      FacesContext fc  FacesContext.getCurrentInstance (); fc.getExternalContext (). IsUserInRole (signed);
      .. the result is TRUE, ie the user is authenticated and has the roles signed.

      With CustomImplementation, running the same line:
      plaincopy clipboardprint to view?

         1. FacesContext fc  FacesContext.getCurrentInstance ();
         2. fc.getExternalContext (). isUserInRole (signed);

      FacesContext fc  FacesContext.getCurrentInstance (); fc.getExternalContext (). IsUserInRole (signed);
      .. the result is FALSE or the JSF does not know who the user is authenticated, is.

      In JAAS, has what is called a Subject object that encapsulates the Principal and Roles. Using the class of the JBoss,
      SecurityAssociation, is to force a change in the Subject JBOSS ... Good, but I do not know how
      this in JSF.

      FOR JSF, I can check the main object in this way:
      plaincopy clipboardprint to view?

         1. FacesContext fc  FacesContext.getCurrentInstance ();
         2. fc.getExternalContext (). getUserPrincipal ();

      FacesContext fc  FacesContext.getCurrentInstance (); fc.getExternalContext (). GetUserPrincipal ();
      .. but how to modify the Main JSF? And if I manipulate the object ExternalContext until I could do it .. but I can not set this object in the FacesContext.

      Good. this situation is complex ...
      any ideas, suggestions, etc ... are welcome!

      Thanks!