7 Replies Latest reply on Oct 1, 2011 2:24 PM by rlperry

    Authentication using Seam Remoting

    sendtopms.senthilkumar.peelikkampatti.bnsf.com

      I am facing issues while authenticating user through Seam Remoting.
      Here is the scenario,
      I have a popup widget, which will obtain user/password from the user and onclick of login button it invokes SLSB and Identity.login and hence registered authenticator would be called from Seam. But it is not happening.
      Here is Components.xml code

          <security:identity authenticate-method="#{serviceAuthenticator.authenticate}"/> 
      


      Here is web.xml
      <ejb-local-ref>
              <ejb-ref-name>evolve/EvolveAuthBean/local</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <local>evolve.user.ejb.EvolveAuthLocal</local>
              <ejb-link>EvolveAuthBean</ejb-link>
          </ejb-local-ref>
          <ejb-local-ref>
              <ejb-ref-name>evolve/AjaxLoginBeanBean/local</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <local>evolve.user.ejb.AjaxLoginBeanLocal</local>
              <ejb-link>AjaxLoginBeanBean</ejb-link>
          </ejb-local-ref>




      Here is the Code for serviceAuthenticator, it is taken from seam booking example,

       
      @Stateless
      @Name("serviceAuthenticator")
      public class EvolveAuthBean implements EvolveAuthLocal {
          @In
          Identity identity;
         public boolean authenticate() {
              this.loggedInUser = new User(identity.getUsername(), identity.getPassword(), identity.getUsername());
              return true;
          }
      }
      


      One more SLSB to do remoting and authentication,
      Here is the code,
      @Name("AjaxLogin")
      @Stateless
      public class AjaxLoginBeanBean implements AjaxLoginBeanLocal {
          @In (create=true)
          Identity identity;
          
          @WebRemote
          public User login(String userName, String password) {
              identity.setUsername(userName);
              identity.setPassword(password);
                String loggedIn = identity.login();
                return user;
          }
      }
      




      I got below errors,


      15:21:57,923 ERROR [SeamLoginModule] Error invoking login method
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: serviceAuthenticator
              at org.jboss.seam.Component.newInstance(Component.java:1970)
              at org.jboss.seam.Component.getInstance(Component.java:1873)
              at org.jboss.seam.Component.getInstance(Component.java:1840)
              at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
      .
      .
      .
      Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/evolve/EvolveAuthBean/local
              at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:834)
              at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
              at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)
              at javax.naming.InitialContext.lookup(InitialContext.java:392)
              at org.jboss.seam.Component.instantiateSessionBean(Component.java:1287)
              at org.jboss.seam.Component.instantiate(Component.java:1273)
              at org.jboss.seam.Component.newInstance(Component.java:1966)
              ... 130 more
      15:21:57,923 DEBUG [Identity] Login failed for: function () {
          var newArgs = [];
          for (var x = 0; x < args.length; ++x) {
              newArgs.push(args[x]);
          }
          for (var x = 0; x < arguments.length; ++x) {
              newArgs.push(arguments[x]);
          }
          return fcn.apply(thisPtr, newArgs);
      }
      javax.security.auth.login.LoginException: Could not instantiate Seam component: serviceAuthenticator
              at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:113)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
              at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
              at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
              at java.security.AccessController.doPrivileged(Native Method)
              at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
              at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
              at org.jboss.seam.security.Identity.authenticate(Identity.java:259)
              at org.jboss.seam.security.Identity.authenticate(Identity.java:248)
              at org.jboss.seam.security.Identity.login(Identity.java:205)
              at evolve.user.ejb.AjaxLoginBeanBean.login(AjaxLoginBeanBean.java:35)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      
      



      But when I invoke login through JSF page, it is working without any issue.
      Here is JSF working code,

                                   <h:panelGrid columns="2" border="0" >
                                          <h:outputLabel for="name" value="Username"/>
                                          <h:inputText id="name" value="#{identity.username}"/>
                                          <h:outputLabel for="password" value="Password"/>
                                          <h:inputSecret id="password" value="#{identity.password}"/>
                                      </h:panelGrid>
                                       <div align="center">
                                          <h:commandButton value="Login" action="#{identity.login}"/>
                                </div>
         
      



      Please help me how to invoke login or authentication through seam remoting.