4 Replies Latest reply on Dec 19, 2002 12:31 PM by annapurna

    Getting the caller from the context

    annapurna Newbie

      Hi ,

      I have no idea how to work with security. I need to get the caller's (users) name in a session/entity bean. Can someone give me a detailed example about how to do get the users name.I am working with jboss3.0.3

      Thanks,
      Anna

        • 1. Re: Getting the caller from the context
          annapurna Newbie

          Hi I figured how to make this from the command line. It does work from a HTML/Structs client. I get a *UNABLE TO FIND LOGINMODULE* exception.Can someone help.

          Thanks in advance

          • 2. Re: Getting the caller from the context
            srinivas Newbie

            Hi AnnaPurna,
            This is Srini,Coming to your problem if ur working with EJBSecurity and wnat to do it programatically there are methods in EJBContext Interface with name getCallerprincipal() whcih will give u the caller in role.just go throgh the methods isCallerInRole() and getCallerPrincipal() for programatic security.
            For declarative security of beans u can mention in ejb-jar.xml file for secutiy-role giving rolename and method-permissions.just go through wrox J2ee server programming u 'll get the information.for any doubts get back
            bye
            Srini

            • 3. Re: Getting the caller from the context
              srinivas Newbie

              Hi AnnaPurna,
              This is Srini,Coming to your problem if ur working with EJBSecurity and wnat to do it programatically there are methods in EJBContext Interface with name getCallerprincipal() whcih will give u the caller in role.just go throgh the methods isCallerInRole() and getCallerPrincipal() for programatic security.
              For declarative security of beans u can mention in ejb-jar.xml file for secutiy-role giving rolename and method-permissions.just go through wrox J2ee server programming u 'll get the information.for any doubts get back
              bye
              Srini

              • 4. Re: Getting the caller from the context
                annapurna Newbie

                Hi Srini,

                Thanks for the information. I think I have half the problem solved. Let me explain to you the rest of the problem.

                I am doing a LoginContext using the following code.
                AppCallbackHandler handler = new AppCallbackHandler(login, password.toCharArray());

                //a default login module in jboss
                LoginContext lc = new LoginContext("client-login", handler);
                lc.login();

                So that any user can logon to Jboss. It works well for one user but when I have multiple users there are problems.

                In my stateful session bean the callerprincipal becomes the last logged in user when there are multiple clients.

                The session context and the session id of the stateful session bean are different to both the clients. But the callerprinciapal is always the last logged on user.

                Can someone help me how to get this working.

                Thanks,
                Annapurna