title: Login failure: javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
body: <p>I got a problem with authentication and JBoss AS 7.1.1.Final "Brontes" and JSF 2.0</p>
  
  <p>jboss-web.xml</p>
  
  <pre><code>&lt;jboss-web&gt;
      &lt;security-domain&gt;testRealm&lt;/security-domain&gt;
  &lt;/jboss-web&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;security-constraint&gt;
          &lt;display-name&gt;login_web_displayname&lt;/display-name&gt;
          &lt;web-resource-collection&gt;
              &lt;web-resource-name&gt;web_main&lt;/web-resource-name&gt;
              &lt;url-pattern&gt;/web/*&lt;/url-pattern&gt;
              &lt;http-method&gt;TRACE&lt;/http-method&gt;
              &lt;http-method&gt;OPTIONS&lt;/http-method&gt;
              &lt;http-method&gt;HEAD&lt;/http-method&gt;
              &lt;http-method&gt;DELETE&lt;/http-method&gt;
              &lt;http-method&gt;PUT&lt;/http-method&gt;
              &lt;http-method&gt;POST&lt;/http-method&gt;
              &lt;http-method&gt;GET&lt;/http-method&gt;
          &lt;/web-resource-collection&gt;
          &lt;auth-constraint&gt;
              &lt;role-name&gt;login_web&lt;/role-name&gt;
          &lt;/auth-constraint&gt;
      &lt;/security-constraint&gt;
      &lt;login-config&gt;
          &lt;auth-method&gt;FORM&lt;/auth-method&gt;
          &lt;realm-name&gt;testRealm&lt;/realm-name&gt;
          &lt;form-login-config&gt;
              &lt;form-login-page&gt;/security/login.xhtml&lt;/form-login-page&gt;
              &lt;form-error-page&gt;/security/loginerror.xhtml&lt;/form-error-page&gt;
          &lt;/form-login-config&gt;
      &lt;/login-config&gt;
      &lt;security-role&gt;
          &lt;role-name&gt;login_web&lt;/role-name&gt;
      &lt;/security-role&gt;
  </code></pre>
  
  <p>login.xml</p>
  
  <pre><code>&lt;h:form id="j_login"&gt;
          &lt;p:panel style="width: 600px; margin: auto"&gt;
              &lt;f:facet name="header"&gt;
                  &lt;h:outputLabel value="Authentifizierung" /&gt;
              &lt;/f:facet&gt;
              &lt;h:panelGrid columns="3"&gt;
                  &lt;h:column&gt;
                      &lt;h:outputLabel value="Benutzername:" for="username" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;h:inputText size="30" id="username" required="true"
                          requiredMessage="Bitte Benutzernamen eingeben!"
                          value="#{webBean.username}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;h:message for="username" style="FONT-SIZE: small;" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;h:outputLabel for="password" value="Passwort:" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;h:inputSecret size="30" id="password" required="true"
                          requiredMessage="Bitte Passwort eingeben!"
                          value="#{webBean.passwort}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;h:message for="password" style="FONT-SIZE: small;" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;h:commandButton id="loginbtn" action="#{webBean.submitLogin}"
                          value="Anmelden" /&gt;
                  &lt;/h:column&gt;
              &lt;/h:panelGrid&gt;
          &lt;/p:panel&gt;
      &lt;/h:form&gt;
  </code></pre>
  
  <p>JBoss standalone.xml</p>
  
  <pre><code> &lt;security-domain name="testRealm" cache-type="default"&gt;
                      &lt;authentication&gt;
                          &lt;login-module code="Database" flag="required"&gt;
                              &lt;module-option name="dsJndiName" value="java:jboss/datasources/jbossauth"/&gt;
                              &lt;module-option name="principalsQuery" value="select password from users where name=?"/&gt;
                              &lt;module-option name="hashAlgorithm" value="MD5"/&gt;
                              &lt;module-option name="hashEncoding" value="base64"/&gt;
                              &lt;module-option name="hashCharset" value="UTF-8"/&gt;
                              &lt;module-option name="unauthenticatedIdentity" value="guest"/&gt;
                          &lt;/login-module&gt;
                      &lt;/authentication&gt;
                  &lt;/security-domain&gt;
  </code></pre>
  
  <p>I get always the exception:</p>
  
  <p>Login failure: javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
      at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:270) [picketbox-4.0.7.Final.jar:4.0.7.Final]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_65]</p>
  
  <p>Full stacktrace:</p>
  
  <pre><code>18:15:22,445 ERROR [org.jboss.security.authentication.JBossCachedAuthenticationManager] (http-bn-ws0044.bva.de-10.12.1.52-8080-1) Login failure: javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
      at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:270) [picketbox-4.0.7.Final.jar:4.0.7.Final]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_65]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_65]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_65]
      at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_65]
      at javax.security.auth.login.LoginContext.invoke(LoginContext.java:762) [rt.jar:1.7.0_65]
      at javax.security.auth.login.LoginContext.access$000(LoginContext.java:203) [rt.jar:1.7.0_65]
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:690) [rt.jar:1.7.0_65]
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:688) [rt.jar:1.7.0_65]
      at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_65]
      at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:687) [rt.jar:1.7.0_65]
      at javax.security.auth.login.LoginContext.login(LoginContext.java:595) [rt.jar:1.7.0_65]
      at org.jboss.security.authentication.JBossCachedAuthenticationManager.defaultLogin(JBossCachedAuthenticationManager.java:449) [picketbox-infinispan-4.0.7.Final.jar:4.0.7.Final]
      at org.jboss.security.authentication.JBossCachedAuthenticationManager.proceedWithJaasLogin(JBossCachedAuthenticationManager.java:383) [picketbox-infinispan-4.0.7.Final.jar:4.0.7.Final]
      at org.jboss.security.authentication.JBossCachedAuthenticationManager.authenticate(JBossCachedAuthenticationManager.java:371) [picketbox-infinispan-4.0.7.Final.jar:4.0.7.Final]
      at org.jboss.security.authentication.JBossCachedAuthenticationManager.isValid(JBossCachedAuthenticationManager.java:160) [picketbox-infinispan-4.0.7.Final.jar:4.0.7.Final]
      at org.jboss.as.web.security.JBossWebRealm.authenticate(JBossWebRealm.java:214) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
      at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:280) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:381) [jbossweb-7.0.13.Final.jar:]
      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
      at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]
  </code></pre>
  
  <p>The Passwort is right ("wurst" aka "i6RvA50nWSDriR8f9kXwWQ==" </p>
  
  <p>created with linux "echo -n wurst | openssl dgst -MD5 -binary | openssl base64") </p>
  
  <p>I can see in the SQL Profiler that the Databaseconnection is working, 
  ...I tried plain text, still the same error</p>
  
  <p>Any help would be very appreciated!</p>