12 Replies Latest reply on Feb 22, 2007 4:29 PM by mikedougherty

    Setting a

    mikedougherty

      Good afternoon,

      I have an Authenticator that connects to the company's LDAP to authenticate. Which is working perfectly. In the LDAP there is a "Display Name" for the user. I think it would be nice to show this in the loginout.xhtml page rather than the username. Currently I am doing this via the following code:

      org.jboss.seam.contexts.Contexts.getSessionContext().set("userDisplayName", displayName);
      


      By think it might be cleaner to have something like:

       Identity.instance().setName(displayName);
      


      Or something similar. Is this possible at this point?

      Thanks.

        • 1. Re: Setting a
          fernando_jmt

          Currently Seam Identity class does not have a "Name" property. It coud be nice if Seam guys add this property in the future. I think sometimes we need to display the user who is logged in, currently I can only show the username, but it would be better display the full name.


          At this time the only way you can do this is extending the Identity class (adding the name property) in your application, and configure that identity class instead of default Seam one.

          HTH.

          • 2. Re: Setting a
            pmuir

            The message can be overridden in your resource bundle with the property key org.jboss.seam.loginSuccessful.

            • 3. Re: Setting a
              shane.bryzak

              Just override the login message. I've even updated the seamspace example to show how to do this.

              • 4. Re: Setting a
                fernando_jmt

                Well, I think overwriting the login message will work only to display the message immediately the user has logged in.

                But by instance I wanna display the user full name in the top of the page all the time the user is working in its session. ¿What to do in this case?

                • 5. Re: Setting a
                  fernando_jmt

                  Well, I think overwriting the login message will work only to display the message immediately the user has logged in.

                  But by instance I wanna display the user full name in the top of the page all the time the user is working in its session. ¿What to do in this case?

                  • 6. Re: Setting a
                    fernando_jmt

                    I know, I can add the full name in a separately session variable, but this will not part of the identity as well.

                    • 7. Re: Setting a
                      shane.bryzak

                      Identity is the wrong place for this, it is purely concerned with authentication and only contains principals it needs to authenticate. Using a session-scoped component is perfectly valid for displaying the user's full name.

                      • 8. Re: Setting a
                        mikedougherty

                         

                        "shane.bryzak@jboss.com" wrote:
                        Identity is the wrong place for this, it is purely concerned with authentication and only contains principals it needs to authenticate. Using a session-scoped component is perfectly valid for displaying the user's full name.


                        The authenticator is what is concerned about authentication, and I would agree that the authenticator should only have authentication code in it. At least this is the direction Seam appears to be taking. (Note: that I said "appears" because I have not read the road map and am not 100% sure about that).

                        But isn't the Identity object used to identify the user who has been authenticated? If this is true, then the attributes that "identify" a user could differ greatly based on the application. In normal cases the default Identity object might suffice. But it would be nice to be able to define a custom (subclass) Identity object where I can add attributes based on what my application needs.

                        Anyway, I'm still just getting my feet wet with Seam, so take my thoughts as just that thoughts (and if you feel like it, suggestions).


                        Thanks for the info.

                        • 9. Re: Setting a
                          christian.bauer

                          Everbody has different requirements what "currently logged in user" means in their application. The Seam identity component handles two very well defined concerns: principal and subjects.

                          If you want a "displayName", and I want a "my.User" available after login, we should outject it into the SESSION scope from your authenticate() method in the authenticator. That is clean and nothing could be easier than an additional line of code in a method.

                          • 10. Re: Setting a
                            mikedougherty

                            I'm sort of new here and still getting a feel for the community, and really do not know how open this community is to debate (especially from new-comers). So I'll make one last comment and let it go at that.

                            I'm not saying outjecting a User session object is hard, or wrong. It is what I am doing, albeit the hard way. From what I've seen so far Seam provides user configurability in just about every area, with this one exception.

                            Also, you are right about the Principal and Subjects. However, the Identity object does allow me to set a Principal. I can add one to the list in Subjects. But then finding the right one in the JSF might be a bit more trouble than it's worth.

                            Anyway, thanks again for the info, and the correction to my code.

                            • 11. Re: Setting a
                              pmuir

                              So I think the thing is here that unless Seam actually started providing a basic User class (which would be a bad thing as this is domain model specific) there is no sensible way to store any information about the user on Identity. FWIW I just extend Identity and add get/setUser methods to it (where User is an entity I've defined).

                              @Name("org.jboss.seam.security.identity")
                              public class Identity extends org.jboss.seam.security.Identity {


                              • 12. Re: Setting a
                                mikedougherty

                                 

                                "petemuir" wrote:
                                So I think the thing is here that unless Seam actually started providing a basic User class (which would be a bad thing as this is domain model specific) there is no sensible way to store any information about the user on Identity. FWIW I just extend Identity and add get/setUser methods to it (where User is an entity I've defined).

                                @Name("org.jboss.seam.security.identity")
                                public class Identity extends org.jboss.seam.security.Identity {


                                Thanks petemuir, that's exactly the kind of info, and solution I was looking for. Did I miss that in the docs somewhere?

                                Thanks!