0 Replies Latest reply on Aug 29, 2011 10:37 AM by Daniel Ch

    Perform Jaas login from ejb

    Daniel Ch Newbie

      Hey guys,

       

      I want to create a jaas login from my ejb application (named "client ejb") to another ejb application. They are hosted on the same jboss 6 as.

      The client ejb app contains a "login.config" with the following content:

       

      tsu {
                org.jboss.security.ClientLoginModule required;
      };
      

       

      Next, I will create a LoginContext with the specified configuration:

       

       

              @EJB(mappedName = "jndi")
              private RemoteEjb remoteEjb;
      
      ...
      
              System.setProperty("java.security.auth.login.config", LoginTestEjb.class.getResource("/META-INF/login.config").toString());
              LoginContext loginContext = null;
      
              CallbackHandler callbackHandler = new UsernamePasswordHandler("testUser", "testPassword".toCharArray());
              loginContext = new LoginContext("tsu", callbackHandler);
      
              loginContext.login();
              System.out.println(remoteEjb.loginSuccessful());
              loginContext.logout();
      

       

      It works on a standalone client but it fails on jboss with the following stacktrace:

       

      javax.ejb.EJBAccessException: Invalid User
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:161) [:1.7.17]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41) [:1.7.17]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67) [:1.7.17]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.7.17]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86) [:1.7.17]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:392) [:1.7.17]
              at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:88) [:1.7.17]
              at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:75) [:1.7.17]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.ejb3.async.impl.interceptor.AsynchronousClientInterceptor.invoke(AsynchronousClientInterceptor.java:143) [:1.7.17]
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
              at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62) [:1.0.1.GA]
              at $Proxy444.invoke(Unknown Source)     at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocatio
      nHandlerBase.java:185) [:1.0.11]
              at $Proxy445.loginSuccessful(Unknown Source) 
      
      

       

      Could not find any documentation concerning this use case.

       

      Thanks!