[Castore-commits] AuthentificationConstants.java NONE 1.1 CasAuthentification.java NONE 1.1 AuthentificationFactory.java 1.4 1.5 LdapAuthentification.java 1.9 1.10

mathieu grimault grimault-m at adullact1.hosting.cri74.org
Mer 21 Juin 16:18:54 CEST 2006


Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/users/authentification
In directory adullact1:/tmp/cvs-serv12162/src/java/fr/emn/castor/users/authentification

Modified Files:
	AuthentificationFactory.java LdapAuthentification.java 
Added Files:
	AuthentificationConstants.java CasAuthentification.java 
Log Message:
Cassification de Castore : 
Modification de la partie AuthentificationFactory et de la Facade associée.
Ajout des parametres dans castor.properties.

--- NEW FILE: AuthentificationConstants.java ---
/*
 * $Id$
 *
 * Plateforme CASTORE
 * CeCILL Copyright (C) 2005-2006 by EMN
 * Made by 
 * Web site = http://www.emn.fr/castore
 * Contact = Cédric Dumas, e-mail = Cedric.Dumas at emn.fr
 *
 * Version
 *
 * Ce logiciel est un programme informatique servant à créer une plateforme
 * open-source de bibliothèque numérique XML pour Conserver, Valoriser et
 * Diffuser le patrimoine documentaire de votre institut.
 *
 * Ce logiciel est régi par la licence CeCILL soumise au droit français et
 * respectant les principes de diffusion des logiciels libres. Vous pouvez
 * utiliser, modifier et/ou redistribuer ce programme sous les conditions de la
 * licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA sur le site
 * "http://www.cecill.info". En contrepartie de l'accessibilité au code source
 * et des droits de copie, de modification et de redistribution accordés par
 * cette licence, il n'est offert aux utilisateurs qu'une garantie limitée. Pour
 * les mêmes raisons, seule une responsabilité restreinte pèse sur l'auteur du
 * programme, le titulaire des droits patrimoniaux et les concédants successifs.
 * A cet égard l'attention de l'utilisateur est attirée sur les risques associés
 * au chargement, à l'utilisation, à la modification et/ou au développement et à
 * la reproduction du logiciel par l'utilisateur étant donné sa spécificité de
 * logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve
 * donc à des développeurs et des professionnels avertis possédant des
 * connaissances informatiques approfondies. Les utilisateurs sont donc invités
 * à charger et tester l'adéquation du logiciel à leurs besoins dans des
 * conditions permettant d'assurer la sécurité de leurs systèmes et ou de leurs
 * données et, plus généralement, à l'utiliser et l'exploiter dans les mêmes
 * conditions de sécurité. Le fait que vous puissiez accéder à cet en-tête
 * signifie que vous avez pris connaissance de la licence CeCILL, et que vous en
 * avez accepté les termes.
 *
 */

package fr.emn.castor.users.authentification;

/**
 * Constantes associées au package authentification
 *
 * @author $Author$
 * @version $Revision$
 *
 */
public class AuthentificationConstants {
	
	/**
	 * Interdit l'instanciation
	 */
	private AuthentificationConstants() {
		
	}
	
	/** Clef à utiliser dans castor.properties pour une authentification par fichier plat */
	public static final String FLAT_AUTHENTIFICATION = "flat";
	
	/** Clef à utiliser dans castor.properties pour une authentification par LDAP */
	public static final String LDAP_AUTHENTIFICATION = "ldap";
	
	/** Clef à utiliser dans castor.properties pour une authentification par CAS */
	public static final String CAS_AUTHENTIFICATION = "cas";
}

Index: AuthentificationFactory.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/users/authentification/AuthentificationFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** AuthentificationFactory.java	24 Apr 2006 17:49:14 -0000	1.4
--- AuthentificationFactory.java	21 Jun 2006 14:18:52 -0000	1.5
***************
*** 96,98 ****
--- 96,118 ----
      public abstract Map getInfosFromUser(String user)
              throws AuthentificationException;
+     
+     /**
+      * Récupération d'une instace selon la méthodé désirée.
+      * Si la méthode est inconnue, on lance une IllegalArgumentException
+      * @param methode le système d'authentification à utiliser
+      * @return une instance de AuthentificationFactory
+      */
+     public static final AuthentificationFactory getInstance(String methode) {
+     	if (methode.equals(AuthentificationConstants.FLAT_AUTHENTIFICATION)) {
+             return FlatAuthentification.getInstance();
+         } else if (methode.equals(AuthentificationConstants.LDAP_AUTHENTIFICATION)) {
+             return LdapAuthentification.getInstance();
+         } else if (methode.equals(AuthentificationConstants.CAS_AUTHENTIFICATION)) {
+         	return CasAuthentification.getInstance();
+         } else {
+         	throw new IllegalArgumentException(
+         		"Méthode d'authentification inconnue : " + methode	
+         	);
+         }
+     }
  }
\ No newline at end of file

--- NEW FILE: CasAuthentification.java ---
/*
 * $Id$
 *
 * Plateforme CASTORE
 * CeCILL Copyright (C) 2005-2006 by EMN
 * Made by 
 * Web site = http://www.emn.fr/castore
 * Contact = Cédric Dumas, e-mail = Cedric.Dumas at emn.fr
 *
 * Version
 *
 * Ce logiciel est un programme informatique servant à créer une plateforme
 * open-source de bibliothèque numérique XML pour Conserver, Valoriser et
 * Diffuser le patrimoine documentaire de votre institut.
 *
 * Ce logiciel est régi par la licence CeCILL soumise au droit français et
 * respectant les principes de diffusion des logiciels libres. Vous pouvez
 * utiliser, modifier et/ou redistribuer ce programme sous les conditions de la
 * licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA sur le site
 * "http://www.cecill.info". En contrepartie de l'accessibilité au code source
 * et des droits de copie, de modification et de redistribution accordés par
 * cette licence, il n'est offert aux utilisateurs qu'une garantie limitée. Pour
 * les mêmes raisons, seule une responsabilité restreinte pèse sur l'auteur du
 * programme, le titulaire des droits patrimoniaux et les concédants successifs.
 * A cet égard l'attention de l'utilisateur est attirée sur les risques associés
 * au chargement, à l'utilisation, à la modification et/ou au développement et à
 * la reproduction du logiciel par l'utilisateur étant donné sa spécificité de
 * logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve
 * donc à des développeurs et des professionnels avertis possédant des
 * connaissances informatiques approfondies. Les utilisateurs sont donc invités
 * à charger et tester l'adéquation du logiciel à leurs besoins dans des
 * conditions permettant d'assurer la sécurité de leurs systèmes et ou de leurs
 * données et, plus généralement, à l'utiliser et l'exploiter dans les mêmes
 * conditions de sécurité. Le fait que vous puissiez accéder à cet en-tête
 * signifie que vous avez pris connaissance de la licence CeCILL, et que vous en
 * avez accepté les termes.
 *
 */

package fr.emn.castor.users.authentification;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import fr.emn.castor.common.PropertiesHelper;

/**
 * Cette classe permet d'utiliser un serveur CAS (Central Authentication Service 
 * de l'Université de Yale) pour authentifier les utilisateurs.
 * Le serveur CAS ne vérifie que le couple login/mot de passe, pour les attributs
 * on fait appel à une autre méthode d'authentification. 
 * Cette classe ne fait que déléguer la recherche d'information.
 *
 * @author $Author$
 * @version $Revision$
 *
 */
public class CasAuthentification extends AuthentificationFactory {

	/** L'instance de l'object. */
    private static CasAuthentification instance = null;
    
    /** Utilisation du common logging. */
    private static Log log = LogFactory.getLog(CasAuthentification.class);
    
    /** La seconde méthode d'authentification qui récupère les informations sur un utilisateur */
    private static AuthentificationFactory authentificationFactory = null;
	
	/**
     * Methode retournant l'instance unique de la classe.
     * @return CasAuthentification l'instance de la classe
     */
    public static synchronized CasAuthentification getInstance() {
        if (instance == null) {
            instance = new CasAuthentification();
            instance.init();
        }
        return instance;
    }

    /**
     * Initialise l'authentification : on vérifie les paramètres de CAS
     * En cas d'erreur, on jette une IllegalArgumentException car
     * de toute façon castore est inutilisable.
     */
    private void init() {
    	
    	if (log.isDebugEnabled()) {
    		log.debug("Authentification CAS...");
    	}
    	
    	String aTester = PropertiesHelper.getProperty("cas.serveur.login");
    	// Vérification
        if (aTester == null || aTester.length() == 0) {
            throw new IllegalArgumentException(
            	"Impossible de charger l'url de login du Serveur CAS, " +
            	"l'authentification est impossible !"
            );
        }
        
        aTester = PropertiesHelper.getProperty("cas.serveur.validate");
    	// Vérification
        if (aTester == null || aTester.length() == 0) {
            throw new IllegalArgumentException(
            	"Impossible de charger l'url de validation du Serveur CAS, " +
            	"l'authentification est impossible !"
            );
        }
        
        aTester = PropertiesHelper.getProperty("cas.serveur.idTicket");
    	// Vérification
        if (aTester == null || aTester.length() == 0) {
            throw new IllegalArgumentException(
            	"Impossible de charger l'identifiant du ticket du Serveur CAS, " +
            	"l'authentification est impossible !"
            );
        }
        
        authentificationFactory = 
        	AuthentificationFactory.getInstance(
        		PropertiesHelper.getProperty("cas.source.informations")
        	);
    }
	
	/**
	 * @see fr.emn.castor.users.authentification.AuthentificationFactory#authentifieUtilisateur(java.lang.String, java.lang.String)
	 */
	public Map authentifieUtilisateur(String identifiant, String motDePasse)
			throws AuthentificationException {
		return authentificationFactory.getInfosFromUser(identifiant);
	}

	/**
	 * @see fr.emn.castor.users.authentification.AuthentificationFactory#isValidateur(java.lang.String)
	 */
	public boolean isValidateur(String login) throws AuthentificationException {
		return authentificationFactory.isValidateur(login);
	}

	/**
	 * @see fr.emn.castor.users.authentification.AuthentificationFactory#searchUser(java.lang.String)
	 */
	public List<Map<String, String>> searchUser(String query)
			throws AuthentificationException {
		return authentificationFactory.searchUser(query);
	}

	/**
	 * @see fr.emn.castor.users.authentification.AuthentificationFactory#getInfosFromUser(java.lang.String)
	 */
	public Map getInfosFromUser(String user) throws AuthentificationException {
		authentificationFactory.getInfosFromUser(user);
		return authentificationFactory.getInfosFromUser(user);
	}
}
Index: LdapAuthentification.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/users/authentification/LdapAuthentification.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** LdapAuthentification.java	23 May 2006 13:51:19 -0000	1.9
--- LdapAuthentification.java	21 Jun 2006 14:18:52 -0000	1.10
***************
*** 63,67 ****
  
  /**
!  * Cette classe permet d'utiliser LDAP comme systeme d'authentification.
   *
   * @author  $Author$
--- 63,67 ----
  
  /**
!  * Cette classe permet d'utiliser LDAP comme système d'authentification.
   *
   * @author  $Author$
***************
*** 166,169 ****
--- 166,173 ----
              throws AuthentificationException {
  
+         // pour LDAP, il faut mettre en minuscule l'identifiant, sinon
+         // il y a doublon.
+     	String username = identifiant.toLowerCase();
+     	
          // Si le mot de passe est vide, on n'autorise pas la connexion !
          // voir java.sun.com/products/jndi/tutorial/ldap/security/simple.html
***************
*** 189,242 ****
                      AuthentificationException.WRONG_PASSWORD);
              }
-         }
-         // on a pas entré l'identificant demo...
-         // il faut s'authentifier avec LDAP
-         return useLdap(identifiant, motDePasse);
- 
-     }
- 
-     /**
-      * Methode utilisant Ldap pour s'authentifier, apres avoir fait
-      * les verifications dans le fichier de proprietes.
-      * @param identifiant l'identifiant de la personne
-      * @param motDePasse son mot de passe
-      * @return Map une Map contenant ses informations LDAP
-      * @throws AuthentificationException
-      * si une erreur d'authentification survient
-      */
-     private Map useLdap(final String identifiant, final String motDePasse)
-             throws AuthentificationException {
-         // pour LDAP, il faut mettre en minuscule l'identifiant, sinon
-         // il y a doublon.
-         String username = identifiant.toLowerCase();
-         HashMap userLDAPInfos = new HashMap();
-         try {
-             // Creation du contexte
-             DirContext ctx = new InitialDirContext(envLdap);
  
!             // On veut chercher dans toute l'arborescence
!             SearchControls constraints = new SearchControls();
!             constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
  
!             // Recherche dans l'annuaire si l'identifiant existe
!             NamingEnumeration results = ctx.search(
!                 this.ldapBase, this.ldapSearchPredicat + "= " + username,
!                 constraints);
!             if (results == null || !(results.hasMore())) {
!                 // on a pas trouve d'identifiant correspondant
!                 throw new AuthentificationException(
!                     "Utilisateur inconnu !",
!                     AuthentificationException.NO_USER_FOUND);
!             }
!             // On a trouve au moins un resultat
!             while (results.hasMore()) {
!                 // on recupere le dn pour l'authentification
!                 // proprement dite
!                 SearchResult sr = (SearchResult) results.next();
                  // on fork suivant si on fait un bind ou pas..
                  String bind = PropertiesHelper.getProperty("ldap.bind");
                  String castorType = "";
                  Attributes attrs;
-                 String dn = sr.getName() + "," + this.ldapBase;
                  if (bind.equals("true")) {
                      try {
--- 193,219 ----
                      AuthentificationException.WRONG_PASSWORD);
              }
  
!             try {
!                 // Creation du contexte
!                 DirContext ctx = new InitialDirContext(envLdap);
  
!                 // On veut chercher dans toute l'arborescence
!                 SearchControls constraints = new SearchControls();
!                 constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
!                 
!                 ArrayList listeDn = trouverDn(username);
!                 // Si on a plusieurs dn pour un login, on prend le premier...
!             	if (listeDn == null || listeDn.size() == 1) {
!             		throw new AuthentificationException(
!             			"Le login ne correspond pas à une et une seule personne !",
!             			AuthentificationException.NAMING_ERROR
!             		);  
!             	}
!             	String dn = (String)listeDn.get(0); 
!                 
                  // on fork suivant si on fait un bind ou pas..
                  String bind = PropertiesHelper.getProperty("ldap.bind");
                  String castorType = "";
                  Attributes attrs;
                  if (bind.equals("true")) {
                      try {
***************
*** 248,252 ****
                          ctx.addToEnvironment(
                              Context.SECURITY_CREDENTIALS, motDePasse);
-                         attrs = ctx.getAttributes(dn, null);
                      } catch (NamingException ne) {
                          throw new AuthentificationException(
--- 225,228 ----
***************
*** 271,358 ****
                              AuthentificationException.WRONG_PASSWORD);
                      }
-                     attrs = ctx.getAttributes(dn, null);
-                 }
-                 // on va  chercher le type d'utilisateur suivant les infos
-                 // de LDAP.
-                 // pour ca , on recupere les attributs definis dans le fichier
-                 // de propriete pour chaque utilisateur, et on regarde si ca
-                 // correspond
-                 // si l'utilisateur correspond a plusieurs types, il prends le
-                 // dernier de la liste : 
-                 //  -> user, superviseur, documentaliste, administrateur
-                 if (isUserType(PropertiesHelper
-                     .getProperty("castortype.user.key"), PropertiesHelper
-                     .getProperty("castortype.user.value"), attrs)) {
-                     castorType = UsersConstants.USERTYPE_USER;
-                 }
-                 if (isUserType(
-                     PropertiesHelper
-                         .getProperty("castortype.supervisor.key"),
-                     PropertiesHelper
-                         .getProperty("castortype.supervisor.value"), attrs)) {
-                     castorType = UsersConstants.USERTYPE_SUPERVISOR;
-                 }
-                 if (isUserType(
-                     PropertiesHelper
-                         .getProperty("castortype.documentalist.key"),
-                     PropertiesHelper
-                         .getProperty("castortype.documentalist.value"),
-                     attrs)) {
-                     castorType = UsersConstants.USERTYPE_DOCUMENTALIST;
-                 }
-                 if (isUserType(
-                     PropertiesHelper
-                         .getProperty("castortype.administrator.key"),
-                     PropertiesHelper
-                         .getProperty("castortype.administrator.value"),
-                     attrs)) {
-                     castorType = UsersConstants.USERTYPE_ADMINISTRATOR;
-                 }
-                 if (castorType.length() != 0) {
-                     // on a trouve le type d'utilisateur
-                     if (log.isDebugEnabled()) {
-                         log.debug("L'utilisateur est du profil : "
-                                 + castorType);
-                     }
-                 } else {
-                     // on a pas trouve le type d'utilisateur
-                     // donc par defaut on le met en temps que user
-                     if (log.isDebugEnabled()) {
-                         log.debug("L'utilisateur n'a pas de profil !");
-                     }
-                     castorType = UsersConstants.USERTYPE_USER;
                  }
!                 userLDAPInfos.put(UsersConstants.INFO_USER_TYPE, castorType);
!                 // on recupere aussi le groupe natif
!                 String gpNatifs = PropertiesHelper
!                     .getProperty("ldap.groupeNatif");
!                 Attribute groupes = attrs.get(gpNatifs);
!                 if (groupes == null) {
!                     // pas de groupe retrouvé dans la fiche !
!                     userLDAPInfos
!                         .put(
!                             UsersConstants.INFO_USER_GROUPE_NATIF,
!                             fr.emn.castor.groupes.GroupesConstants.GROUPES_NATIFS_ID);
!                 } else {
!                     NamingEnumeration groupesEnum = groupes.getAll();
!                     ArrayList groupeList = new ArrayList();
!                     while (groupesEnum.hasMoreElements()) {
!                         groupeList.add(groupesEnum.nextElement());
!                     }
!                     userLDAPInfos.put(
!                         UsersConstants.INFO_USER_GROUPE_NATIF, groupeList);
!                 }
!                 //recuperation du nom et du prenom de l'utlisateur
!                 String nomPrenom = (String) attrs.get(
!                     this.ldapSearchNamePredicat).get();
!                 userLDAPInfos.put(UsersConstants.INFO_USER_NAME, nomPrenom);
! 
              }
-         } catch (NamingException ne) {
-             throw new AuthentificationException(
-                 "Erreur : " + ne.getMessage(),
-                 AuthentificationException.NAMING_ERROR);
          }
!         return userLDAPInfos;
      }
  
--- 247,260 ----
                              AuthentificationException.WRONG_PASSWORD);
                      }
                  }
!             } catch (NamingException ne) {
!                 throw new AuthentificationException(
!                     "Erreur : " + ne.getMessage(),
!                     AuthentificationException.NAMING_ERROR);
              }
          }
!         // Authentification OK, on retourne les infos sur l'utilisateur
!         return getInfosFromUser(username);
! 
      }
  
***************
*** 370,374 ****
      private boolean isUserType(
              final String userType, final String userValue,
!             final Attributes userAttributes) throws NamingException {
          Attribute attr = userAttributes.get(userType);
          if (attr != null) {
--- 272,276 ----
      private boolean isUserType(
              final String userType, final String userValue,
!             final Attributes userAttributes) throws NamingException {    	
          Attribute attr = userAttributes.get(userType);
          if (attr != null) {
***************
*** 501,580 ****
          HashMap userLDAPInfos = new HashMap();
          try {
!             DirContext ctx = new InitialDirContext(envLdap);
!             // On veut chercher dans toute l'arborescence
!             SearchControls constraints = new SearchControls();
!             constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
!             // Recherche dans l'annuaire si l'identifiant existe
!             NamingEnumeration results = ctx.search(
!                 this.ldapBase, this.ldapSearchPredicat + "= " + user,
!                 constraints);
!             if (results == null || !(results.hasMore())) {
!                 // on a pas trouve d'identifiant correspondant
!                 return new HashMap();
              }
!             // on verifie que c'est bien un user qui a des droits de validation
!             while (results.hasMore()) {
!                 // on recupere le dn pour l'authentification
!                 // proprement dite
!                 String castorType = null;
!                 SearchResult sr = (SearchResult) results.next();
!                 String dn = sr.getName() + "," + this.ldapBase;
!                 Attributes attrs = ctx.getAttributes(dn, null);
!                 if (isUserType(PropertiesHelper
!                     .getProperty("castortype.user.key"), PropertiesHelper
!                     .getProperty("castortype.user.value"), attrs)) {
!                     castorType = UsersConstants.USERTYPE_USER;
!                 }
!                 if (isUserType(
!                     PropertiesHelper
!                         .getProperty("castortype.supervisor.key"),
!                     PropertiesHelper
!                         .getProperty("castortype.supervisor.value"), attrs)) {
!                     castorType = UsersConstants.USERTYPE_SUPERVISOR;
!                 }
!                 if (isUserType(
!                     PropertiesHelper
!                         .getProperty("castortype.documentalist.key"),
!                     PropertiesHelper
!                         .getProperty("castortype.documentalist.value"),
!                     attrs)) {
!                     castorType = UsersConstants.USERTYPE_DOCUMENTALIST;
!                 }
!                 if ((castorType == null) || (castorType.length() != 0)) {
!                     // on a trouve le type d'utilisateur
!                     if (log.isDebugEnabled()) {
!                         log.debug("L'utilisateur est du profil : "
!                                 + castorType);
!                     }
!                 } else {
!                     // on a pas trouve le type d'utilisateur
!                     // donc par defaut on le met en temps que user
!                     if (log.isDebugEnabled()) {
!                         log.debug("L'utilisateur n'a pas de profil !");
!                     }
!                     castorType = UsersConstants.USERTYPE_USER;
                  }
!                 userLDAPInfos.put(UsersConstants.INFO_USER_TYPE, castorType);
!                 // on recupere aussi le groupe natif
!                 String gpNatifs = PropertiesHelper
!                     .getProperty("ldap.groupeNatif");
!                 NamingEnumeration groupes = attrs.get(gpNatifs).getAll();
!                 ArrayList groupeList = new ArrayList();
!                 while (groupes.hasMoreElements()) {
!                     groupeList.add(groupes.nextElement());
                  }
!                 userLDAPInfos.put(
!                     UsersConstants.INFO_USER_GROUPE_NATIF, groupeList);
!                 //recuperation du nom et du prenom de l'utlisateur
!                 String nomPrenom = (String) attrs.get(
!                     this.ldapSearchNamePredicat).get();
!                 userLDAPInfos.put(UsersConstants.INFO_USER_NAME, nomPrenom);
!                 //recuperation du mail
!                 String ldapMailPredicat = PropertiesHelper
!                     .getProperty("ldap.mail");
!                 String email = (String) attrs.get(ldapMailPredicat).get();
!                 userLDAPInfos.put(UsersConstants.INFO_USER_EMAIL, email);
  
              }
              return userLDAPInfos;
          } catch (NamingException ne) {
--- 403,476 ----
          HashMap userLDAPInfos = new HashMap();
          try {
!         	DirContext ctx = new InitialDirContext(envLdap);
!         	ArrayList listeDn = trouverDn(user);
!             // Si on a plusieurs dn pour un login, on prend le premier...
!         	if (listeDn == null || listeDn.size() == 1) {
!         		throw new AuthentificationException(
!         			"Le login ne correspond pas à une et une seule personne !",
!         			AuthentificationException.NAMING_ERROR
!         		);        		
!         	}
!         	String dn = (String)listeDn.get(0); 
!         	String castorType = null;
!         		
!         	// Gestion du profil
!             Attributes attrs = ctx.getAttributes(dn, null);
!             if (isUserType(PropertiesHelper
!                 .getProperty("castortype.user.key"), PropertiesHelper
!                 .getProperty("castortype.user.value"), attrs)) {
!                 castorType = UsersConstants.USERTYPE_USER;
              }
!             if (isUserType(
!                 PropertiesHelper
!                     .getProperty("castortype.supervisor.key"),
!                 PropertiesHelper
!                     .getProperty("castortype.supervisor.value"), attrs)) {
!                 castorType = UsersConstants.USERTYPE_SUPERVISOR;
!             }
!             if (isUserType(
!                 PropertiesHelper
!                     .getProperty("castortype.documentalist.key"),
!                 PropertiesHelper
!                     .getProperty("castortype.documentalist.value"),
!                 attrs)) {
!                 castorType = UsersConstants.USERTYPE_DOCUMENTALIST;
!             }
!             if ((castorType == null) || (castorType.length() != 0)) {
!                 // on a trouve le type d'utilisateur
!                 if (log.isDebugEnabled()) {
!                     log.debug("L'utilisateur est du profil : "
!                             + castorType);
                  }
!             } else {
!                 // on a pas trouve le type d'utilisateur
!                 // donc par defaut on le met en temps que user
!                 if (log.isDebugEnabled()) {
!                     log.debug("L'utilisateur n'a pas de profil !");
                  }
!                 castorType = UsersConstants.USERTYPE_USER;
!             }
!             userLDAPInfos.put(UsersConstants.INFO_USER_TYPE, castorType);
  
+             // on recupere aussi le groupe natif
+             String gpNatifs = PropertiesHelper
+                 .getProperty("ldap.groupeNatif");
+             NamingEnumeration groupes = attrs.get(gpNatifs).getAll();
+             ArrayList groupeList = new ArrayList();
+             while (groupes.hasMoreElements()) {
+                 groupeList.add(groupes.nextElement());
              }
+             userLDAPInfos.put(
+                 UsersConstants.INFO_USER_GROUPE_NATIF, groupeList);
+             //recuperation du nom et du prenom de l'utlisateur
+             String nomPrenom = (String) attrs.get(
+                 this.ldapSearchNamePredicat).get();
+             userLDAPInfos.put(UsersConstants.INFO_USER_NAME, nomPrenom);
+             //recuperation du mail
+             String ldapMailPredicat = PropertiesHelper
+                 .getProperty("ldap.mail");
+             String email = (String) attrs.get(ldapMailPredicat).get();
+             userLDAPInfos.put(UsersConstants.INFO_USER_EMAIL, email);
+                 
              return userLDAPInfos;
          } catch (NamingException ne) {
***************
*** 585,587 ****
--- 481,521 ----
          }
      }
+     
+     /**
+      * Récupération des dn distincts correspondant à un login donné
+      * @param login Id ldap de la personne
+      * @return Liste non nulle, contenant les dn correspondant au login
+      * @throws NamingException En cas d'erreur LDAP
+      * @throws AuthentificationException Si aucun dn n'a été trouvé
+      */
+     private ArrayList trouverDn(String login) throws NamingException, AuthentificationException {    	
+     	ArrayList<String> listeDn = new ArrayList();
+ 
+ 		DirContext ctx = new InitialDirContext(envLdap);
+ 		// On veut chercher dans toute l'arborescence
+ 		SearchControls constraints = new SearchControls();
+ 		constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ 		// Recherche dans l'annuaire si l'identifiant existe
+ 		NamingEnumeration results = ctx.search(
+ 		    this.ldapBase, this.ldapSearchPredicat + "= " + login,
+ 		    constraints);
+ 		
+ 		if (results == null || !(results.hasMore())) {
+             // on a pas trouve d'identifiant correspondant
+             throw new AuthentificationException(
+                 "Utilisateur inconnu !",
+                 AuthentificationException.NO_USER_FOUND);
+         }
+ 		
+ 		while (results.hasMore()) {
+ 		    // on recupere le dn
+ 		    SearchResult sr = (SearchResult) results.next();
+ 		    String dn = sr.getName() + "," + this.ldapBase;
+ 		    if (!listeDn.contains(dn)) {
+ 		    	listeDn.add(dn);
+ 		    }
+ 		}
+         
+         return listeDn;
+     }
  }
\ No newline at end of file




Plus d'informations sur la liste de diffusion Castore-commits