9 Replies Latest reply on Feb 8, 2005 4:17 PM by bamajob.nl

    principal=null even if request.getUserPrincipal() does not r

    surak

      I have a struts action which is supposed to use an EJB to get some data. But when calling the create()-method on the home I get an Exception because principal=null.

      The thing is that the principal is not null. I´m using the j_security_check-thingie to log in users and after applying the patch to jboss4 this succeeds nicely. Calling getUserPrincipal and isUserInRole in the Action gives me the expected result.

      Code from StrutsAction

      System.out.println(request.getUserPrincipal()); // Prints the name of the user
      MailAccountController controller = home.create(); // Throws exception due to principal=null
      


      I have looked around on this forum but no one seems to have problem with this part. Am I
      missing something obvious?

      My xdoclet-part of the EJB in question looks like this:
      /**
       * Class MailAccountControllerEJB
       * @ejb.bean
       * name="MailAccountController"
       * jndi-name="ejb/campaign/MailAccountController"
       * type="Stateless"
       *
       * @ejb.security-identity
       * use-caller-identity="true"
       *
       * @ejb.permission
       * role-name="User"
       */
      


        • 1. Re: How to enable HTTPS?
          starksm64

          Thanks!

          I got it working!

          But there is a tiny problem...

          Am trying to connect to my servlet using https and apache XML RPC which uses URLConnection but I get an exception look below...

          What I want to do is write a service that will use apache XML rpc, which essentially uses URLConnection...

          I also wrote a temporary servlet and hosted it on the same JBoss server.
          I have the service connect to localhost which works fine... But I want to use https. Eventually the service will connect externally...

          So how can I get the URLConnection used by apache XML RPC to trust the self signed certificate?

          Thanks

          12:03:23,421 INFO [STDOUT] java.io.IOException: sun.security.validator.ValidatorException: No trusted certificate found
          12:03:23,421 INFO [STDOUT] at org.apache.xmlrpc.XmlRpcClient$Worker.execute
          (XmlRpcClient.java:444)
          12:03:23,421 INFO [STDOUT] at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpc
          Client.java:163)
          12:03:23,421 INFO [STDOUT] at org.tmi.TestService.startService(TestService.
          java:50)
          12:03:23,421 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInt
          ernalStart(ServiceMBeanSupport.java:271)
          12:03:23,421 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInt
          ernalLifecycle(ServiceMBeanSupport.java:221)
          12:03:23,421 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor2.invoke(U
          nknown Source)
          12:03:23,421 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
          ke(DelegatingMethodAccessorImpl.java:25)
          12:03:23,421 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
          24)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
          invoke(ReflectedDispatcher.java:141)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
          ation.java:80)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.interceptor.AbstractInterceptor.
          invoke(AbstractInterceptor.java:119)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
          ion.java:74)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.interceptor.ModelMBeanOperationI
          nterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
          ion.java:74)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
          ke(AbstractMBeanInvoker.java:242)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
          eanServerImpl.java:642)
          12:03:23,421 INFO [STDOUT] at org.jboss.system.ServiceController$ServicePro
          xy.invoke(ServiceController.java:891)
          12:03:23,421 INFO [STDOUT] at $Proxy0.start(Unknown Source)
          12:03:23,421 INFO [STDOUT] at org.jboss.system.ServiceController.start(Serv
          iceController.java:416)
          12:03:23,421 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor6.invoke(U
          nknown Source)
          12:03:23,421 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
          ke(DelegatingMethodAccessorImpl.java:25)
          12:03:23,421 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
          24)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
          invoke(ReflectedDispatcher.java:141)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
          ation.java:80)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
          ion.java:72)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
          ke(AbstractMBeanInvoker.java:242)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
          eanServerImpl.java:642)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
          roxyExt.java:176)
          12:03:23,421 INFO [STDOUT] at $Proxy4.start(Unknown Source)
          12:03:23,421 INFO [STDOUT] at org.jboss.deployment.SARDeployer.start(SARDep
          loyer.java:261)
          12:03:23,421 INFO [STDOUT] at org.jboss.deployment.MainDeployer.start(MainD
          eployer.java:935)
          12:03:23,421 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(Main
          Deployer.java:746)
          12:03:23,421 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(Main
          Deployer.java:709)
          12:03:23,421 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor30.invoke(
          Unknown Source)
          12:03:23,421 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
          ke(DelegatingMethodAccessorImpl.java:25)
          12:03:23,421 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3
          24)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.
          invoke(ReflectedDispatcher.java:141)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc
          ation.java:80)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.interceptor.AbstractInterceptor.
          invoke(AbstractInterceptor.java:119)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
          ion.java:74)
          12:03:23,421 INFO [STDOUT] at org.jboss.mx.interceptor.ModelMBeanOperationI
          nterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
          12:03:23,437 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat
          ion.java:74)
          12:03:23,437 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo
          ke(AbstractMBeanInvoker.java:242)
          12:03:23,452 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB
          eanServerImpl.java:642)
          12:03:23,452 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanP
          roxyExt.java:176)
          12:03:23,452 INFO [STDOUT] at $Proxy8.deploy(Unknown Source)
          12:03:23,452 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentSca
          nner.deploy(URLDeploymentScanner.java:305)
          12:03:23,452 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentSca
          nner.scan(URLDeploymentScanner.java:481)
          12:03:23,452 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeployme
          ntScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
          12:03:23,452 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeployme
          ntScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
          12:03:23,452 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeployme
          ntScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)

          • 2. Re: principal=null even if request.getUserPrincipal() does n
            tschraepen

            Hi Surak,

            I've been trolling through several posts lately to find a solution to another problem and your problem rung a bell.
            I suggest you take a look at this topic then: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=38229.

            Hope that works out for you as well.

            • 3. Re: principal=null even if request.getUserPrincipal() does n
              surak

              Hi tschraepen,

              Thanks for the link, but I´m afraid it did not help me this time (had been helped by it before when I hadn´t specified the ClientLoginModule in my security-domain.)

              But now I´m using the same domain from the weblayer as I have been using in my EJBs and MBeans. And if I do a similar "manual" aas-login in the StrutsAction as I do in my MBeans and thereafter try to create and use the EJB from the StrutsAction it works like a charm.

              So what is the difference if I´m logged in manually and if I´m logged in using the magic servlet j_security_check-thingie?

              • 4. Re: principal=null even if request.getUserPrincipal() does n
                surak

                If I reload the page it seems like everything works fine. So it is only the first time when
                I try to access a resource without being logged in that the Exception occurs.

                When already being logged in I can load the page without any problems what so ever as many times as I want.

                Quite weird, has anyone encountered this before?

                • 5. Re: principal=null even if request.getUserPrincipal() does n
                  j_ri

                  Hi Surak,

                  I have exactly the same problem. It would be great if you found a solution and can tell me how it works.

                  It is very strange that I am able to create an ejb after I click refresh on the browser when I get the security exception?!

                  Thanks

                  • 6. Re: principal=null even if request.getUserPrincipal() does n
                    pytaghoras

                    I have the some problem. Can somebody tell me what is the solution?

                    Thank you!

                    • 7. Re: principal=null even if request.getUserPrincipal() does n
                      j_ri

                      yes, the solution is quite easy;-)

                      just update your JBoss version from 4.0.0 to 4.0.1.....

                      I hope this solves your problem, too

                      regards
                      jochen

                      • 8. Re: principal=null even if request.getUserPrincipal() does n
                        pytaghoras

                        Hello j_ri,

                        I use jboss-4.0.1RC1. I still have the some problem. Do you know how i can solve the problem?

                        Regards,

                        Pyta.

                        • 9. Re: principal=null even if request.getUserPrincipal() does n
                          bamajob.nl

                          I think it is a bug in Jboss. I have the someproblem. After authentication IsUserInRole always returns false.