6 Replies Latest reply on Aug 4, 2009 6:59 PM by lesquivel

    JBoss API Question

    lesquivel

      Hello,

      I am trying to find the API that would aid in the following:

      - Trying to find the JBoss servlet session to retrieve information such as which .war or servlet context the current code is running. Like getWebAppByName() sort of thing.

      - Get current servlet users where is would return an authenticated Principal object.

      - How to stop the server from code.

      -LDAP Authentication (NTAuth) - api to get users from a group etc...


      I have been looking at lots of code trying to find the right packages that would help with this sort of things but it is all a bit overwhelming since I am so new to JBoss. Any help will be greatly appreciated.

      Thank you.

        • 1. Re: JBoss API Question
          peterj

          (You should have numbered you questions... I will assume you did.)

          1) Should be contained in HTTPServletRequest.getRequestURL() or HTTPServletRequest.getRequestURI()

          2) HTTPServletRequest.getUserPrincipal()

          3) Obtain the "jboss:type=Server" MBean and invoke the shutdown() operation.

          4) There are two very different questions here. Are you wanting to know how to use LDAP for authentication? Or do you want to know how to make calls into LDAP to find out which users are in a group?

          • 2. Re: JBoss API Question
            peterj

            Oops, typo - the MBean name is "jboss.system:type=Server"

            • 3. Re: JBoss API Question
              lesquivel

              Hello Peter,

              Thank you for your response. I just got a copy of your book and I am looking forward to learn from it!!

              Ok, yes I should have numbered them. Next time :)

              I am going to comment on your numbered responses.

              1) and 2) : What if the HTTPServletRequest isn't available? i.e I am in an MBean and need to get the current server session info that contains that information provided by HTTPServletRequest and Session. Is there an JBoss component (MBean) I can access to get that?

              3) Thank you. Can you point me to an example on how to access an MBean such as jboss.system:type=Server?

              4) I think the how to use LDAP for authentication is done with the Login-config.xml file. How about accessing the information and making calls to the LDAP to find out which users are in a group?

              Thank you again for your help.

              Luis

              • 4. Re: JBoss API Question
                lesquivel

                Peter, I assume this is what you mean by accessing the MBean?

                Context ctx = new InitialContext();
                MBeanServerConnection mconn = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");
                ObjectName name = new ObjectName("jboss.system:type=Server");

                Thanks.

                • 5. Re: JBoss API Question
                  peterj

                  Yes, and look at the methods on MBeanServerConnection for things you can do (get/set attributes, invoke methods).

                  Re #1 & #2: from an mbean? I have no idea. How to get the Principal depends on the technology (and your have to read the JSR for the tech to find out). However, I think that the Principal is stored in the thread-local storage (no I don't know offhand how to get it from there).

                  Re #4: There is no JBoss API for accessing LDAP. JBoss AS uses the JNDI API to do its JNDI work. I have also seen other LDAP APIs for Java (a google should turn them up)

                  • 6. Re: JBoss API Question
                    lesquivel

                    Ok! This is good info. Looking into the Twiddle for accessing the MBeans. (Tip from your book).

                    I need to look into the LDAP lookup stuff.

                    Thanks for your help!