Bonjour,
Je travaille sur une application avec hibernate, spring, struts2 et je souhaite intégrer spring security.
voila mon springSecurity.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
    <security:http auto-config="true" use-expressions="true">
        <security:intercept-url pattern="/welcome"
            access="permitAll" />
        <security:form-login login-page="/login/formLogin"
            default-target-url="/login/welcome"
            authentication-failure-url="/login/formLogin?login_error=1"
            username-parameter="username"
            password-parameter="password" />
        <security:logout />
    </security:http>
 
    <security:authentication-manager alias="authenticationManager">
        <security:authentication-provider>
            <security:jdbc-user-service data-source-ref="datasource"
             users-by-username-query=
            "select id, Rol_id, email, motDePasse from user u where u.email=?"
             authorities-by-username-query=
            "select u.email,r.role from user u, role r where u.Rol_id=r.id and u.email=?"
            />
        </security:authentication-provider>
    </security:authentication-manager>
 
</beans>
les deux tables user et role sont définit de la façon suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
CREATE TABLE IF NOT EXISTS `role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role` varchar(254) DEFAULT NULL,
  `description` varchar(254) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
CREATE TABLE IF NOT EXISTS `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Rol_id` int(11) NOT NULL,
  `email` varchar(254) DEFAULT NULL,
  `motDePasse` varchar(254) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_Association_user_role` (`Rol_id`),
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
login.jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
<form name='loginForm'
        action="${pageContext.request.contextPath}/j_spring_security_check"
        method='POST'>
 
        <table>
            <tr>
                <td>User:</td>
                <td><input type='text' name='username' value=''></td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><input type='password' name='password' /></td>
            </tr>
            <tr>
                <td><input name="submit" type="submit" value="submit" /></td>
            </tr>
        </table>
 
        <input type="hidden" name="${_csrf.parameterName}"
            value="${_csrf.token}" />
 
    </form>
Le problème est le suivant:

même si je fournis le bon username et mot de passe, j'obtiens "Bad credentials."

merci de m'aider!