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
|
<!-- ContextSource pour l'accès à l'annuaire LDAP -->
<beans:bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<beans:constructor-arg index="0" value="${ldap.cnx.url}" />
<beans:property name="userDn" value="${ldap.cnx.userDn}" />
<beans:property name="password" value="${ldap.cnx.password}" />
</beans:bean>
<!-- Bean de recherche dans le LDAP -->
<beans:bean id="ldapUserSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<beans:constructor-arg index="0" value="${ldap.search.arg1}" />
<beans:constructor-arg index="1" value="${ldap.search.arg2}"/>
<beans:constructor-arg index="2" ref="contextSource" />
<beans:property name="searchSubtree" value="false" />
</beans:bean>
<!-- LdapAuthenticationProvider : AuthenticationProvider dédiée au LDAP -->
<beans:bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider" >
<beans:constructor-arg index="0">
<beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<beans:constructor-arg index="0" ref="contextSource" />
<beans:property name="userSearch" ref="ldapUserSearch" />
</beans:bean>
</beans:constructor-arg>
<beans:constructor-arg index="1">
<beans:bean id="appliAuthoritiesPopulator" class="com.monappli.security.AppliAuthoritiesPopulator" />
</beans:constructor-arg>
</beans:bean>
<!-- authenticationManager : Authentifcation Manager censé gérer les multiples authentication-provider : LDAP / DB JDBC -->
<authentication-manager alias="authenticationManager" >
<!-- Reference provider LDAP -->
<authentication-provider ref="ldapAuthProvider" >
</authentication-provider>
<!-- Reference provider BD JDBC -->
<authentication-provider >
<password-encoder
hash="md5" />
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT login, password, actif FROM user WHERE login = ?"
authorities-by-username-query="SELECT login, auth_role FROM authorities a, user u WHERE u.idUser = a.idUser AND login = ?" />
</authentication-provider>
</authentication-manager> |
Partager