3 Replies Latest reply on Sep 24, 2013 12:18 PM by henrikdeluxe

    Jboss 7: where to store client user data ?

    eurtn

      Hi,

      I'm trying to migrate my application from Jboss 4.2 to Jboss 7.1.1 final.

      I have a custom principal where I keep a couple of custom values like the locale and the name of the company;

      I implemented a callbackhandler to access the new values, but I found out that the custom principal is not propagated in the security context in Jboss 7.1.1.

      (I already tried to create a SimpleGroup("CallerPrincipal"), following the instructions in other posts of this forum)

       

      How can I proceed ?

      Is there a reccomanded solution to implement my use case ?

      Where can I store my extra informations about the user in the ejb context ?

       

      Thank You

        • 1. Re: Jboss 7: where to store client user data ?
          gerry.matte

          You can try out the jdf GreeterQuickstart which uses CDI + JPA + EJB + JTA + JSF at http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/guide/GreeterQuickstart/

          but I think the simplest and best documented quickstart that's relevant to your question is at https://docs.jboss.org/author/display/AS7/Login+quickstart

          You will want to add your custom user data to the User.java bean.  There is already a non standard property called userName that seems to be available throughout the webapp so I don't expect adding other properties would be a problem.

           

           

          Oddly, the Login Quckstart is not included in the list of jdf quickstarts for jboss 7.

           

          I find the quickstarts extremely helpful to quickly setup a working tested implementation of the technology I wish to try out.  It does take a bit of mental effort and time to study the quickstart in enough detail to understand the critical settings and techniques.

          • 2. Re: Jboss 7: where to store client user data ?
            eurtn

            Hi,

            thanks for the quick answer, but unfortunatly my use case is different;

             

            I explain it better.

            We don't have a web application; we use JAAS and so we need to login a user (username, password, company name and locale) via login module (with a callbackhandler).

            In our EJB we need to retrieve the informations about the user.

             

            In Jboss 4 we implemented a custom Principal to do so, but in Jboss 7 the custom principal is

            not propagated in the ejb context, so when we retrieve it we don't have our company name and locale anymore.

             

            is there a best practice or another good way to implement this case ?

            Any advice is welcome!

             

            Thank You

            • 3. Re: Re: Jboss 7: where to store client user data ?
              henrikdeluxe

              Same Problem here - what is the correct way to propagate an custom principal for jaas authentification?

               

              In older Versions it was possible to propagate the principal on clienside as follows:

              final MyAppPrincipal customPrincipal = new MyAppPrincipal("username", "myLocale"); // implements Principal
              final SecurityClient client = SecurityClientFactory.getSecurityClient(JBossSecurityClient.class);
              client.setVmwideAssociation(true);
              client.setSimple(customPrincipal, plainPassword);
              client.login();
              

               

               

              Then in my LoginModule i could get this principal on serverside:

              private MyAppPrincipal getClientPrincipal()
              {
                  final SecurityAssociationCallback callback = new SecurityAssociationCallback();
                  final Callback[] callbacks =
                  { callback };
                  try
                  {
                      callbackHandler.handle(callbacks);
                      final Principal principal = callback.getPrincipal();
                      if(principal instanceof MyAppPrincipal)
                      {
                          return (MyAppPrincipal) principal;
                      }
                  }
                  catch(final IOException e)
                  {
                      LOGGER.error("couldn't get custom principal", e);
                  }
                      catch(final UnsupportedCallbackException e)
                  {
                      LOGGER.error("couldn't get custom principal", e);
                  }
                  return null;
              }
              

               

               

              With AS 7.2 i only get SimplePrincipal on serverside