3 Replies Latest reply on Oct 9, 2007 2:34 AM by mindgame

    Seam and custom JAAS problem

    mindgame

      Dear all,

      I have a problem (2 days old and counting...) with Seam and custom JAAS. I have written a custom JAAS login module to handle user login activity. The module is declare in component.xml,

      <security:identity jaas-config-name="jaasLogin" />


      A simple login page is used to obtain username and password as shown in the Seam references in Chapter 13,

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


      With the above setup, there is NO problem when the user provide the correct username and password. But the problem is when the user provide a wrong username or password, the login module get invokes twice. The custom login module throw javax.security.auth.login.FailedLoginException when the login has failed. I can understand the #{identity.login} action fire the login module the first time, but have no idea what causes the login module to fire the second time immediately after the first execution and before JSF render response phase?

      In addition, when I hit refresh at the login page after a failed login attempt, the login module get call each time the refresh button is hit. Is this behavior somehow related to the conversation context with respect to the login page and/or the Identity seam component?

      Does anyone have any idea and insight as what is happening behind the scene?

      Many thanks.

        • 1. Re: Seam and custom JAAS problem
          mindgame

          I am using Seam 2.0 CR2 with JBoss 4.2.1.GA.

          • 2. Re: Seam and custom JAAS problem
            shane.bryzak

            You probably have an s:hasRole or other security check somewhere in your page - Seam Security will attempt to perform a silent login if the user's credentials are available but the user hasn't been authenticated yet.

            • 3. Re: Seam and custom JAAS problem
              mindgame

              Thanks for the hint. I tried to look around my codes for hidden/implicit security check but no luck. Even created a bare bone test and still no luck. So after 3 days of debugging, I have decided to 'hack' my login module to avoid certain actions in the second time the login module is invoked. This is definitely not a clean solution :(

              Thanks.