0 Replies Latest reply on Feb 25, 2014 7:48 AM by morellik

    Authentication problem

    morellik

      I following the WildFly Guide to migrate a Glasshfish application to WildFly 8. After a lot of troubles something starts to works thanks to your help.

       

      Now I've trouble with authentication. I receive the login page but after enter valid credential nothing happen, no message, no error reported by log. I stay ever in the login page.

       

      Follow the login page:

       

        <h:form>
              <h:outputLabel for="email" value="Email" />
              <h:inputText id="email" value="#{auth.email}" required="true" />
              <h:message for="email" />
               <br />
               <h:outputLabel for="password" value="Password" />
              <h:inputSecret id="password" value="#{auth.password}" required="true" />
               <h:message for="password" />
                <br />
              <h:commandButton value="Login" action="#{auth.login}" />
              <h:messages globalOnly="true" />
           </h:form>
      

       

      The Auth bean:

       

       

      public class Auth implements Serializable {
      
          /**
           * Creates a new instance of Auth
           */
          public Auth() {
          }
          private static final long serialVersionUID = 1L;
          @Inject
          private ParticipantDAO userService;
          private String email;
          private String password;
          private String originalURL;
      
          @PostConstruct
          public void init() {
              ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
              originalURL = (String) externalContext.getRequestMap().get(RequestDispatcher.FORWARD_REQUEST_URI);
      
              if (originalURL == null) {
                  originalURL = externalContext.getRequestContextPath() + "/secure/index.xhtml";
              } else {
                  String originalQuery = (String) externalContext.getRequestMap().get(RequestDispatcher.FORWARD_QUERY_STRING);
      
                  if (originalQuery != null) {
                      originalURL += "?" + originalQuery;
                  }
              }
          }
      
          public void login() throws IOException, ServletException {
              FacesContext context = FacesContext.getCurrentInstance();
              ExternalContext externalContext = context.getExternalContext();
              HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
      
              try {
                  request.login(email, password);
                  Participant user = userService.findUser(email, password);
                  externalContext.getSessionMap().put("user", user);
                  externalContext.redirect(originalURL);
              } catch (ServletException e) {
                  // Handle unknown username/password in request.login().
                  context.addMessage(null, new FacesMessage("Unknown login or wrong password"));
              }
          }
      
          public void logout() throws IOException {
              ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
              externalContext.invalidateSession();
              externalContext.redirect(externalContext.getRequestContextPath() + "/secure/login.xhtml");
          }
      
          public String getEmail() {
              return email;
          }
      
          public void setEmail(String email) {
              this.email = email;
          }
      
          public String getPassword() {
              return password;
          }
      
          public void setPassword(String password) {
              this.password = password;
          }
      }
      

       

      jboss-web.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
        <context-root>/IDPbyNMRWF</context-root>
        <security-domain>app</security-domain>
      </jboss-web>
      

       

       

      What can I do to check where is the problem?