...
Dans le fichier src/main/webapp/WEB-INF/deployerConfigContext.xml, ajouter le bean suivant pour déclarer le contexte LDAP :
| Bloc de code |
|---|
|
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="pooled" value="true"/>
<property name="urls">
<list>
<value>ldap://ldapglobal.univ-rennes1.fr/</value>
</list>
</property>
<property name="userDn" value=""/>
<property name="password" value=""/>
<property name="baseEnvironmentProperties">
<map>
<entry>
<key>
<value>java.naming.security.authentication</value>
</key>
<value>simple</value>
</entry>
</map>
</property>
</bean>
|
puis changer le handler SimpleTestUsernamePasswordAuthenticationHandler par celui-ci :
| Bloc de code |
|---|
|
<bean
class="org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler" >
<property name="filter" value="uid=%u,ou=people,dc=univ-rennes1,dc=fr" />
<property name="contextSource" ref="contextSource" />
</bean>
|
...
Editer le fichier <cas-home>/cas-server-webapp/pom.xml et ajouter la dépendance suivante (par exemple juste après la dépendance vers le module cas-server-support-ldap) :
| Bloc de code |
|---|
|
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-support-trusted</artifactId>
<version>${project.version}</version>
</dependency> |
...
Editer le fichier <cas-home>/cas-server-webapp/src/main/webapp/WEB-INF/login-webflow.xml et ajouter l'état suivant juste avant l'état viewLoginForm :
| Bloc de code |
|---|
|
<action-state id="remoteAuthenticate">
<action bean="principalFromRemoteAction" />
<transition on="success" to="sendTicketGrantingTicket" />
<transition on="error" to="viewLoginForm" />
</action-state> |
Dans ce même fichier, remplacer les références à viewLoginForm par remoteAuthenticate pour les trois decision-state gatewayRequestCheck, renewRequestCheck et generateServiceTicket :
| Bloc de code |
|---|
|
<decision-state id="gatewayRequestCheck">
<if
test="${externalContext.requestParameterMap['gateway'] != '' && externalContext.requestParameterMap['gateway'] != null && flowScope.service != null}"
then="redirect"
else="remoteAuthenticate" />
</decision-state> |
| Bloc de code |
|---|
|
<decision-state id="renewRequestCheck">
<if
test="${externalContext.requestParameterMap['renew'] != '' && externalContext.requestParameterMap['renew'] != null}"
then="remoteAuthenticate"
else="generateServiceTicket" />
</decision-state> |
| Bloc de code |
|---|
|
<action-state id="generateServiceTicket">
<action bean="generateServiceTicketAction" />
<transition on="success" to ="warn" />
<transition on="error" to="remoteAuthenticate" />
<transition on="gateway" to="redirect" />
</action-state> |
Déclarer le bean implémentant le nouvel état du webflow en ajoutant les lignes suivantes dans le fichier <cas-home>/cas-server-webapp/src/main/webapp/WEB-INF/cas-servlet.xml :
| Bloc de code |
|---|
|
<bean
id="principalFromRemoteAction"
class="org.jasig.cas.adaptors.trusted.web.flow.PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction"
p:centralAuthenticationService-ref="centralAuthenticationService" /> |
...
- PrincipalBearingCredentialsToPrincipalResolver après les resolvers existants de credentialsToPrincipalResolvers
- PrincipalBearingCredentialsAuthenticationHandler avant les handlers existants de authenticationHandlers
| Bloc de code |
|---|
|
<bean id="authenticationManager" class="org.jasig.cas.authentication.AuthenticationManagerImpl">
<property name="credentialsToPrincipalResolvers">
<list>
<!-- ... the others credentialsToPrincipalResolvers ... -->
<bean class="org.jasig.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredentialsToPrincipalResolver" />
</list>
</property>
<property name="authenticationHandlers">
<list>
<bean class="org.jasig.cas.adaptors.trusted.authentication.handler.support.PrincipalBearingCredentialsAuthenticationHandler" />
<!-- ... the others authenticationHandlers... -->
</list>
</property>
</bean> |
Test
ça doit marcher...