0 Replies Latest reply on Aug 11, 2015 10:21 AM by Varun Thadaka

    Can I use custom login module without extending any predefined login modules in WildFly SSO?

    Varun Thadaka Newbie




      I'm trying to implement SSO in WildFly-8.2.0.Final.

      In most of the documents provided related to WildFly SSO, they have given login module examples for UsersRoles, Database or custom login modules.

      In custom login-module, is it required my login class(login manager for my application) to extend some predefined classes like 'UsernamePasswordLoginModule"?

      Because I already have a login mechanism using seam security Identity for authentication. Can I use my login mechanism without extending UsernamePasswordLoginModule. If it is possible can anyone give example how it works?



      In standalone.xml - security domain configuration is like:


      <security-domain name="sso" cache-type="default">


              <login-module code="com.company.LoginAction" flag="required">






      Below is my LoginAction class:


      package com.company;

      import java.util.List;


      import javax.ejb.Stateless;

      import javax.faces.application.FacesMessage;

      import javax.faces.context.FacesContext;

      import javax.persistence.EntityManager;

      import javax.persistence.PersistenceContext;



      import org.jboss.seam.ScopeType;

      import org.jboss.seam.security.Identity;

      import org.jboss.seam.annotations.In;

      import org.jboss.seam.annotations.JndiName;

      import org.jboss.seam.annotations.Name;

      import org.jboss.seam.annotations.Out;

      import org.jboss.seam.contexts.Context;

      import org.jboss.seam.ejb.SeamInterceptor;






      public class LoginAction implements Login



         Identity identity;



         private BookingUser user;



         private EntityManager em;



         private transient Context sessionContext;


         private transient FacesContext facesContext;


         public boolean login()


            List<BookingUser> results = em.createQuery("select u from BookingUser u where username=:username and password=:password")

                  .setParameter("username", identity.getUsername())

                  .setParameter("password", identity.getPassword())



            if ( results.size()==0 )


               facesContext.addMessage(null, new FacesMessage("Invalid login"));

               return false;




               user = results.get(0);

               return true;