Bonsoir,


J'aimerai savoir comment je dois configurer le fichier xml spring security pour avoir plusieurs types d'authentification (2 dans mon cas).

En effet, dans notre application, il y a deux types d'utilisateurs (professionnel &client)j'ai 2 tables utilisateur(client) et professionnel ,l'authentification pour le client marche bien,c'est selon le rôle de celui qui tend à se connecter que la page s'affiche," rôle" est un champs dans chacune des tables ,
voici mon fichier Spring .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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	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-2.5.xsd
              		http://www.springframework.org/schema/security 
              		http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
 
    <!--  Déclaration du PropertyPlaceholderConfigurer -->
 
	<bean
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:/db.properties</value>
			</list>
		</property>
	</bean>
<!--  Déclaration de la DATASOURCE -->
 
	<bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="${db.driver}" />
		<property name="url" value="${db.url}" />
		<property name="username" value="${db.username}" />
		<property name="password" value="${db.password}" />
	</bean>
 
 
	<!-- Stratégie de Sécurité : ressources et Remember me -->
	<security:http auto-config="true">
	    <security:intercept-url pattern="/inscriptionUti.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY" />
	    <security:intercept-url pattern="/inscriptionpro.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY" />	    
		<security:intercept-url pattern="/login.jsp*" filters="none"/> 
		<security:intercept-url pattern="/logo*" filters="none"/>  
		<security:intercept-url pattern="/objis.css" filters="none"/>  
		<security:intercept-url pattern="/**" access="ROLE_PROFESSIONNEL,ROLE_CLIENT"/>
	  	<security:form-login login-page='/login.jsp'/>	
 
	</security:http>
 
 
<security:authentication-provider user-service-ref='myUserDetailsService' />
 
<bean id="myUserDetailsService" class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl">
  <property name="dataSource" ref="dataSource"/>
  <property name="usersByUsernameQuery" value="SELECT login as username, password, enabled , nom, prenom
                                                 FROM utilisateur WHERE login = ?"/>
  <property name="authoritiesByUsernameQuery" value="SELECT login as username, role 
                                                       FROM utilisateur WHERE login = ?"/>
 
</bean>  
 
 
</beans>
merci pour votre aide .