当前位置: 首页 > 知识库问答 >
问题:

身份验证失败:密码与spring security 3.2中的存储值不匹配

殳凯捷
2023-03-14

我使用的是spring Security3.2,我的代码是

<beans:beans xmlns="http://www.springframework.org/schema/security"
 xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/security
 http://www.springframework.org/schema/security/spring-security-3.2.xsd">

 <http auto-config="true">
  <access-denied-handler error-page="/403page" />
  <intercept-url pattern="/user**" access="ROLE_USER" />
  <intercept-url pattern="/admin**" access="ROLE_ADMIN" />
  <form-login login-page='/login' username-parameter="username"
   password-parameter="password" default-target-url="/user"
   authentication-failure-url="/login?authfailed" />
  <logout logout-success-url="/login?logout" />
 </http>

 <!-- <authentication-manager> <authentication-provider> <user-service> <user 
  name="user" password="user@123" authorities="ROLE_ADMIN" /> </user-service> 
  </authentication-provider> </authentication-manager> -->

 <authentication-manager>
  <authentication-provider>
   <jdbc-user-service data-source-ref="dataSource"
    users-by-username-query="select username,password,enabled from qforma_users where username=?"
    authorities-by-username-query="select username, role from qforma_roles where username =?  " />
  </authentication-provider>
 </authentication-manager>

</beans:beans>

// and login.jsp page is 

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Login Form | www.beingjavaguys.com</title>
</head>
<body>
 <center>




  <h2>Login Here</h2>


  <div style="text-align: center; padding: 30px;border: 1px solid green;width: 250px;">
   <form method="post" action="<c:url value='j_spring_security_check' />">

    <table>
     <tr>
      <td colspan="2" style="color: red">${message}</td>

     </tr>
     <tr>
      <td>User Name:</td>
      <td><input type="text" name="username" />
      </td>
     </tr>
     <tr>
      <td>Password:</td>
      <td><input type="password" name="password" />
      </td>
     </tr>
     <tr>
      <td> </td>
      <td><input type="submit" value="Login" />
      </td>

     </tr>
    </table>
   </form>
  </div>
 </center>
</body>
</html>

我得到的错误是

DEBUG o.s.JDBC.DataSource.datasourceutils-返回到数据源的JDBC连接16:41:52.273[http-nio-8080-exec-7]DEBUG o.s.s.a.daoauthenticationprovider-身份验证失败:密码与存储值不匹配16:41:52.273[http-nio-8080-exec-7]DEBUG o.s.s.wa.usernamePasswordauthenticationfilter-身份验证请求失败:org.springframework.security.authenticationfilter-错误凭据16:41:52.273[http-nio-8080-exec-7]DEBUG o.s.s.wa.usernamePasswordauthenticationfilter-更新到包含空身份验证

请帮帮我

我给出了正确的用户名和密码,但它显示身份验证失败:密码不匹配存储值

共有1个答案

董飞航
2023-03-14
//I have solved the issue actually I have used by putting trim(password) .i //am using postgres sql character (100) and it was occupying all the spaces even //though my password length is 4 characters .
<authentication-manager>
  <authentication-provider>
   <jdbc-user-service data-source-ref="dataSource"
    users-by-username-query="select username,trim(password),enabled from qforma_users where username=?"
    authorities-by-username-query="select username, role from qforma_roles where username =?  " />
  </authentication-provider>
 </authentication-manager> 
 类似资料:
  • 当我运行应用程序并尝试在其中登录时,系统返回到登录页面,即使使用正确的登录密码(我确信)。 谁都能看出这里出了什么问题? 更新

  • 我制作了一个PDB,我可以通过sys作为sysdba连接到这个PDB,但是我不能连接我自己的普通用户或本地用户。 原因是ORA-01017:密码错误。 在sqlnet.ora中设置之后: 密码以quation标记开始结束,然后生效。 创建用户和登录用户的命令: 为什么?如何将SQLNET.ALLOWED\u LOGON\u VERSION\u SERVER升级到12。我可以设置没有引号的密码吗?

  • 我们正在配置spring云配置服务器,下面是我的应用程序属性的外观: 我可以登录到github url,即https://github.com/myorganization/config-store.git使用用户名MyUser和密码MyPassword作为上述属性,但当我试图启动我的配置服务器使用:./mvnw sping-boot: run我得到以下错误: 我已经尝试了很多东西,但现在没有任何

  • Tweepy API请求twitter return me Twitter错误响应:状态代码=401。 这是我的实际代码: 我曾试图用tweepy软件包删除推文,并获得了所有必需的密钥。镊子包装不起作用吗?有人能帮我解决这个问题吗。

  • 我的keytab由以下命令生成: SPN信息 看起来我的keytab没问题。

  • 问题内容: 尝试使用JavaMail中的NTLM连接到Exchange服务器。我可以连接到SMTP,但不能连接到IMAP。我还可以使用相同的主机/用户名/密码通过OS X Mail.app应用程序进行身份验证,帐户类型=“ IMAP”,端口143,ssl = false,authentication = NTLM,域名=“。 连接代码: 输出: 我尝试通过http://www.oracle.com