| 64 | 
           jpm | 
           1 | 
           package org.tela_botanica.client.modeles;
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
           | 1906 | 
           mathias | 
           3 | 
           import java.util.HashMap;
  | 
        
        
            | 
            | 
           4 | 
              | 
        
        
            | 
            | 
           5 | 
           import org.tela_botanica.client.Coel;
  | 
        
        
           | 64 | 
           jpm | 
           6 | 
           import org.tela_botanica.client.RegistreId;
  | 
        
        
           | 772 | 
           jpm | 
           7 | 
           import org.tela_botanica.client.http.JsonRestRequestBuilder;
  | 
        
        
            | 
            | 
           8 | 
           import org.tela_botanica.client.http.JsonRestRequestCallback;
  | 
        
        
           | 64 | 
           jpm | 
           9 | 
           import org.tela_botanica.client.interfaces.Rafraichissable;
  | 
        
        
           | 346 | 
           gduche | 
           10 | 
           import org.tela_botanica.client.util.UtilDAO;
  | 
        
        
           | 64 | 
           jpm | 
           11 | 
              | 
        
        
            | 
            | 
           12 | 
           import com.extjs.gxt.ui.client.Registry;
  | 
        
        
           | 1906 | 
           mathias | 
           13 | 
           import com.google.gwt.http.client.Request;
  | 
        
        
            | 
            | 
           14 | 
           import com.google.gwt.http.client.Response;
  | 
        
        
           | 64 | 
           jpm | 
           15 | 
           import com.google.gwt.json.client.JSONArray;
  | 
        
        
            | 
            | 
           16 | 
           import com.google.gwt.json.client.JSONBoolean;
  | 
        
        
           | 1906 | 
           mathias | 
           17 | 
           import com.google.gwt.json.client.JSONNumber;
  | 
        
        
            | 
            | 
           18 | 
           import com.google.gwt.json.client.JSONObject;
  | 
        
        
           | 64 | 
           jpm | 
           19 | 
           import com.google.gwt.json.client.JSONString;
  | 
        
        
            | 
            | 
           20 | 
           import com.google.gwt.json.client.JSONValue;
  | 
        
        
           | 1906 | 
           mathias | 
           21 | 
           import com.google.gwt.user.client.Timer;
  | 
        
        
           | 64 | 
           jpm | 
           22 | 
              | 
        
        
           | 268 | 
           jp_milcent | 
           23 | 
           /**
  | 
        
        
            | 
            | 
           24 | 
            * Modele DAO, specifique, permettant la validation, l'acces aux donnees distantes et la présentation des donnees en retour
  | 
        
        
            | 
            | 
           25 | 
            *
  | 
        
        
            | 
            | 
           26 | 
            */
  | 
        
        
           | 69 | 
           jpm | 
           27 | 
           public class UtilisateurAsyncDao {
  | 
        
        
           | 268 | 
           jp_milcent | 
           28 | 
           	private static final String SERVICE_NOM = "CoelUtilisateur";
  | 
        
        
            | 
            | 
           29 | 
              | 
        
        
           | 65 | 
           jpm | 
           30 | 
           	private Utilisateur utilisateur = null;
  | 
        
        
           | 358 | 
           jp_milcent | 
           31 | 
           	private Rafraichissable vueARafraichir = null;
  | 
        
        
           | 1906 | 
           mathias | 
           32 | 
              | 
        
        
            | 
            | 
           33 | 
           	private static Timer rafraichisseurJeton = null;
  | 
        
        
           | 64 | 
           jpm | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           	/**
  | 
        
        
            | 
            | 
           36 | 
           	 * Constructeur
  | 
        
        
            | 
            | 
           37 | 
           	 * @param retour : méthode appellée en retour d'appel.
  | 
        
        
            | 
            | 
           38 | 
           	 */
  | 
        
        
           | 772 | 
           jpm | 
           39 | 
           	public UtilisateurAsyncDao(Rafraichissable vueARafraichirCourrante) {
  | 
        
        
            | 
            | 
           40 | 
           		vueARafraichir = vueARafraichirCourrante;
  | 
        
        
           | 277 | 
           jp_milcent | 
           41 | 
           		utilisateur = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
  | 
        
        
           | 64 | 
           jpm | 
           42 | 
           	}
  | 
        
        
           | 1906 | 
           mathias | 
           43 | 
              | 
        
        
           | 64 | 
           jpm | 
           44 | 
           	/**
  | 
        
        
           | 1906 | 
           mathias | 
           45 | 
           	 * Recupere des informations d'authentification à partir du JSON renvoyé par les
  | 
        
        
            | 
            | 
           46 | 
           	 * services Auth de l'annuaire (SSO)
  | 
        
        
            | 
            | 
           47 | 
           	 *
  | 
        
        
            | 
            | 
           48 | 
           	 * @param valeurJson
  | 
        
        
            | 
            | 
           49 | 
           	 * @return AuthInfo
  | 
        
        
           | 64 | 
           jpm | 
           50 | 
           	 */
  | 
        
        
           | 1906 | 
           mathias | 
           51 | 
           	public static AuthInfo parserAuthJson(JSONValue valeurJson) {
  | 
        
        
            | 
            | 
           52 | 
           		AuthInfo authInfo = new AuthInfo();
  | 
        
        
            | 
            | 
           53 | 
           		JSONObject authJson = valeurJson.isObject();
  | 
        
        
            | 
            | 
           54 | 
              | 
        
        
            | 
            | 
           55 | 
           		JSONValue erreurJSON = authJson.get("error");
  | 
        
        
            | 
            | 
           56 | 
           		// test si erreur
  | 
        
        
            | 
            | 
           57 | 
           		if (erreurJSON != null) {
  | 
        
        
            | 
            | 
           58 | 
           			JSONString erreur = erreurJSON.isString();
  | 
        
        
            | 
            | 
           59 | 
           			if (erreur != null) {
  | 
        
        
            | 
            | 
           60 | 
           				authInfo.error = erreur.stringValue();
  | 
        
        
            | 
            | 
           61 | 
           			} else {
  | 
        
        
            | 
            | 
           62 | 
           				authInfo.error = "erreur d'authentification";
  | 
        
        
            | 
            | 
           63 | 
           			}
  | 
        
        
            | 
            | 
           64 | 
           		} else {
  | 
        
        
            | 
            | 
           65 | 
           			boolean session = authJson.get("session").isBoolean().booleanValue();
  | 
        
        
            | 
            | 
           66 | 
           			authInfo.session = session;
  | 
        
        
            | 
            | 
           67 | 
           			// test si session ouverte
  | 
        
        
            | 
            | 
           68 | 
           			if (session) {
  | 
        
        
            | 
            | 
           69 | 
           				JSONValue tokenJson = authJson.get("token");
  | 
        
        
            | 
            | 
           70 | 
           				String token = null;
  | 
        
        
            | 
            | 
           71 | 
           				// protection paranoïaque
  | 
        
        
            | 
            | 
           72 | 
           				if (tokenJson != null) {
  | 
        
        
            | 
            | 
           73 | 
           					JSONString tokenString = tokenJson.isString();
  | 
        
        
            | 
            | 
           74 | 
           					if (tokenString != null) {
  | 
        
        
            | 
            | 
           75 | 
           						token = tokenString.stringValue();
  | 
        
        
            | 
            | 
           76 | 
           					}
  | 
        
        
           | 64 | 
           jpm | 
           77 | 
           				}
  | 
        
        
           | 1906 | 
           mathias | 
           78 | 
           				String tokenId = authJson.get("token_id").isString().stringValue();
  | 
        
        
            | 
            | 
           79 | 
           				int duration = (int) authJson.get("duration").isNumber().doubleValue();
  | 
        
        
            | 
            | 
           80 | 
           				JSONValue lastModifJson = authJson.get("last_modif");
  | 
        
        
            | 
            | 
           81 | 
              | 
        
        
            | 
            | 
           82 | 
           				authInfo.token = token;
  | 
        
        
            | 
            | 
           83 | 
           				authInfo.tokenId = tokenId;
  | 
        
        
            | 
            | 
           84 | 
           				authInfo.duration = duration;
  | 
        
        
            | 
            | 
           85 | 
           				// test si lastModif est null
  | 
        
        
            | 
            | 
           86 | 
           				if (lastModifJson != null) {
  | 
        
        
            | 
            | 
           87 | 
           					JSONNumber lastModif = lastModifJson.isNumber();
  | 
        
        
            | 
            | 
           88 | 
           					if (lastModif != null) {
  | 
        
        
            | 
            | 
           89 | 
           						authInfo.lastModif = (int) lastModif.doubleValue();
  | 
        
        
            | 
            | 
           90 | 
           					}
  | 
        
        
            | 
            | 
           91 | 
           				}
  | 
        
        
           | 772 | 
           jpm | 
           92 | 
           			}
  | 
        
        
           | 1906 | 
           mathias | 
           93 | 
           		}
  | 
        
        
            | 
            | 
           94 | 
              | 
        
        
            | 
            | 
           95 | 
           		return authInfo;
  | 
        
        
           | 64 | 
           jpm | 
           96 | 
           	}
  | 
        
        
            | 
            | 
           97 | 
              | 
        
        
            | 
            | 
           98 | 
           	/**
  | 
        
        
           | 1906 | 
           mathias | 
           99 | 
           	 * Enregistre le jeton (potentiellement NULL), sa durée de vie; appelle le service Coel pour
  | 
        
        
            | 
            | 
           100 | 
           	 * obtenir les données de l'utilisateur relatives à l'application; lorsque le jeton
  | 
        
        
            | 
            | 
           101 | 
           	 * n'est pas nul et que sa durée de vie est spécifiée, déclenche un rafraîchissement
  | 
        
        
            | 
            | 
           102 | 
           	 * périodique du jeton
  | 
        
        
            | 
            | 
           103 | 
           	 *
  | 
        
        
            | 
            | 
           104 | 
           	 * @param objetRetour le retour de l'appel au service annuaire:auth (connexion, deconnexion ou identite)
  | 
        
        
            | 
            | 
           105 | 
           	 */
  | 
        
        
            | 
            | 
           106 | 
           	protected void gererRetourAuthInfo(AuthInfo objetRetour) {
  | 
        
        
            | 
            | 
           107 | 
           		// Stockage du jeton rafraîchi et de sa durée (pourrait avoir changé)
  | 
        
        
            | 
            | 
           108 | 
           		Utilisateur.setJeton(objetRetour.token);
  | 
        
        
            | 
            | 
           109 | 
           		Utilisateur.setDureeJeton(objetRetour.duration);
  | 
        
        
            | 
            | 
           110 | 
              | 
        
        
            | 
            | 
           111 | 
           		// Rafraîchissement automatique du jeton - s'annule lorsque le jeton devient nul
  | 
        
        
            | 
            | 
           112 | 
           		if (Utilisateur.getJeton() != null && Utilisateur.getDureeJeton() > 0) {
  | 
        
        
            | 
            | 
           113 | 
           			if (rafraichisseurJeton == null) { // on sait jamais
  | 
        
        
            | 
            | 
           114 | 
           				// 3/4 de la durée de vie du jeton, en millisecondes (ça laisse de la marge)
  | 
        
        
            | 
            | 
           115 | 
           				int delaiRepetition = (Utilisateur.getDureeJeton() * 1000) * 3 / 4;
  | 
        
        
           | 1909 | 
           mathias | 
           116 | 
           				//delaiRepetition = 10000; // debug
  | 
        
        
           | 1906 | 
           mathias | 
           117 | 
           				rafraichisseurJeton = new Timer() {
  | 
        
        
            | 
            | 
           118 | 
           					@Override
  | 
        
        
            | 
            | 
           119 | 
           					public void run() {
  | 
        
        
            | 
            | 
           120 | 
           						//Coel.LogVersFirebug("rafraichir utilisateur");
  | 
        
        
            | 
            | 
           121 | 
           						// Appel de l'annuaire pour rafraîchir le jeton (cb nul pour l'instant)
  | 
        
        
            | 
            | 
           122 | 
           						getEtatUtilisateur();
  | 
        
        
            | 
            | 
           123 | 
           					}
  | 
        
        
            | 
            | 
           124 | 
           				};
  | 
        
        
            | 
            | 
           125 | 
           				rafraichisseurJeton.scheduleRepeating(delaiRepetition);
  | 
        
        
            | 
            | 
           126 | 
           			}
  | 
        
        
            | 
            | 
           127 | 
           		} else {
  | 
        
        
            | 
            | 
           128 | 
           			if (rafraichisseurJeton != null) { // on sait jamais non plus
  | 
        
        
            | 
            | 
           129 | 
           				rafraichisseurJeton.cancel();
  | 
        
        
            | 
            | 
           130 | 
           				rafraichisseurJeton = null;
  | 
        
        
            | 
            | 
           131 | 
           			}
  | 
        
        
            | 
            | 
           132 | 
           		}
  | 
        
        
            | 
            | 
           133 | 
              | 
        
        
            | 
            | 
           134 | 
           		// Obtention de l'utilisateur final d'après le service de préférences
  | 
        
        
           | 1909 | 
           mathias | 
           135 | 
           		//Coel.LogVersFirebug("va chercher utilisateur Coel");
  | 
        
        
           | 1906 | 
           mathias | 
           136 | 
           		getEtatUtilisateurSansAnnuaire();
  | 
        
        
            | 
            | 
           137 | 
           	}
  | 
        
        
            | 
            | 
           138 | 
              | 
        
        
            | 
            | 
           139 | 
           	/**
  | 
        
        
           | 64 | 
           jpm | 
           140 | 
           	 * Méthode déconnectant un utilisateur de l'application.
  | 
        
        
            | 
            | 
           141 | 
           	 * @param identifiant de l'utilisateur à déconnecter.
  | 
        
        
            | 
            | 
           142 | 
           	 */
  | 
        
        
           | 65 | 
           jpm | 
           143 | 
           	public void deconnecterUtilisateur() {
  | 
        
        
           | 1906 | 
           mathias | 
           144 | 
           		//Coel.LogVersFirebug("deconnexion");
  | 
        
        
            | 
            | 
           145 | 
           		final JsonRestRequestBuilder rb = UtilDAO.construireRequeteAuth("deconnexion", null);
  | 
        
        
           | 772 | 
           jpm | 
           146 | 
           		rb.envoyerRequete(null, new JsonRestRequestCallback() {
  | 
        
        
            | 
            | 
           147 | 
           			@Override
  | 
        
        
            | 
            | 
           148 | 
           			public void surReponse(JSONValue responseValue) {
  | 
        
        
           | 1906 | 
           mathias | 
           149 | 
           				//Coel.LogVersFirebug(responseValue.toString());
  | 
        
        
            | 
            | 
           150 | 
           				AuthInfo info = parserAuthJson(responseValue);
  | 
        
        
            | 
            | 
           151 | 
           				gererRetourAuthInfo(info);
  | 
        
        
           | 772 | 
           jpm | 
           152 | 
           			}
  | 
        
        
            | 
            | 
           153 | 
           		});
  | 
        
        
           | 64 | 
           jpm | 
           154 | 
           	}
  | 
        
        
            | 
            | 
           155 | 
              | 
        
        
            | 
            | 
           156 | 
           	/**
  | 
        
        
           | 1906 | 
           mathias | 
           157 | 
           	 * Méthode connectant un utilisateur à l'application
  | 
        
        
           | 64 | 
           jpm | 
           158 | 
           	 */
  | 
        
        
           | 772 | 
           jpm | 
           159 | 
           	public void connecterUtilisateur() {
  | 
        
        
           | 1906 | 
           mathias | 
           160 | 
           		HashMap<String, String> parametres = new HashMap<String, String>();
  | 
        
        
            | 
            | 
           161 | 
           		parametres.put("login", utilisateur.getLogin());
  | 
        
        
            | 
            | 
           162 | 
           		parametres.put("password", utilisateur.getMotDePasse());
  | 
        
        
            | 
            | 
           163 | 
           		//Coel.LogVersFirebug("connexion");
  | 
        
        
            | 
            | 
           164 | 
           		final JsonRestRequestBuilder rb = UtilDAO.construireRequeteAuth("connexion", parametres);
  | 
        
        
           | 65 | 
           jpm | 
           165 | 
              | 
        
        
           | 772 | 
           jpm | 
           166 | 
           		rb.envoyerRequete(null, new JsonRestRequestCallback() {
  | 
        
        
            | 
            | 
           167 | 
           			@Override
  | 
        
        
            | 
            | 
           168 | 
           			public void surReponse(JSONValue responseValue) {
  | 
        
        
           | 1906 | 
           mathias | 
           169 | 
           				AuthInfo info = parserAuthJson(responseValue);
  | 
        
        
            | 
            | 
           170 | 
           				gererRetourAuthInfo(info);
  | 
        
        
            | 
            | 
           171 | 
           			}
  | 
        
        
           | 1908 | 
           mathias | 
           172 | 
           			@Override
  | 
        
        
            | 
            | 
           173 | 
           			public void onErrorHTTP(Request request, Response reponse) {
  | 
        
        
            | 
            | 
           174 | 
           				// Si on a été déconnecté, on va chercher un profil utilisateur "anonyme" et
  | 
        
        
            | 
            | 
           175 | 
           				// on avertit l'interface
  | 
        
        
           | 1909 | 
           mathias | 
           176 | 
           				//Coel.LogVersFirebug("j'ai une erreur mais je suis content");
  | 
        
        
           | 1908 | 
           mathias | 
           177 | 
           				gererRetourAuthInfo(new AuthInfo());
  | 
        
        
            | 
            | 
           178 | 
           			}
  | 
        
        
           | 1906 | 
           mathias | 
           179 | 
           		});
  | 
        
        
            | 
            | 
           180 | 
           	}
  | 
        
        
            | 
            | 
           181 | 
              | 
        
        
            | 
            | 
           182 | 
           	/**
  | 
        
        
            | 
            | 
           183 | 
           	 * Va chercher les infos de l'utilisateur en vérifiant d'abord l'identité auprès de l'annuaire
  | 
        
        
            | 
            | 
           184 | 
           	 */
  | 
        
        
            | 
            | 
           185 | 
           	public void getEtatUtilisateur() {
  | 
        
        
            | 
            | 
           186 | 
           		getEtatUtilisateur(false);
  | 
        
        
            | 
            | 
           187 | 
           	}
  | 
        
        
            | 
            | 
           188 | 
              | 
        
        
            | 
            | 
           189 | 
           	/**
  | 
        
        
            | 
            | 
           190 | 
           	 * Va chercher les infos de l'utilisateur; si ignorerAnnuaire est false, vérifiera d'abord
  | 
        
        
            | 
            | 
           191 | 
           	 * l'identité auprès de l'annuaire (service annuaire:auth/identite)
  | 
        
        
            | 
            | 
           192 | 
           	 */
  | 
        
        
            | 
            | 
           193 | 
           	public void getEtatUtilisateur(boolean ignorerAnnuaire) {
  | 
        
        
            | 
            | 
           194 | 
           		// par défaut, on appelle d'abord le service auth/identite de l'annuaire, afin de connaître
  | 
        
        
            | 
            | 
           195 | 
           		// le statut de l'utilisateur vis à vis du SSO (connecté ou non) et rafraîchir le jeton
  | 
        
        
            | 
            | 
           196 | 
           		if (! ignorerAnnuaire) {
  | 
        
        
            | 
            | 
           197 | 
           			//Coel.LogVersFirebug("get état");
  | 
        
        
            | 
            | 
           198 | 
           			// sans header Authorization, sinon une déconnexion depuis une autre appli ne sera pas
  | 
        
        
            | 
            | 
           199 | 
           			// prise en compte et le jeton sera rafraîchi indéfiniment
  | 
        
        
            | 
            | 
           200 | 
           			final JsonRestRequestBuilder rb = UtilDAO.construireRequeteAuth("identite", null, false);
  | 
        
        
            | 
            | 
           201 | 
           			rb.envoyerRequete(null, new JsonRestRequestCallback() {
  | 
        
        
            | 
            | 
           202 | 
           				@Override
  | 
        
        
            | 
            | 
           203 | 
           				public void surReponse(JSONValue responseValue) {
  | 
        
        
            | 
            | 
           204 | 
           					AuthInfo info = parserAuthJson(responseValue);
  | 
        
        
            | 
            | 
           205 | 
           					gererRetourAuthInfo(info);
  | 
        
        
            | 
            | 
           206 | 
           				}
  | 
        
        
            | 
            | 
           207 | 
           				@Override
  | 
        
        
            | 
            | 
           208 | 
           				public void onErrorHTTP(Request request, Response reponse) {
  | 
        
        
            | 
            | 
           209 | 
           					// Si on a été déconnecté, on va chercher un profil utilisateur "anonyme" et
  | 
        
        
            | 
            | 
           210 | 
           					// on avertit l'interface
  | 
        
        
            | 
            | 
           211 | 
           					gererRetourAuthInfo(new AuthInfo());
  | 
        
        
            | 
            | 
           212 | 
           				}
  | 
        
        
            | 
            | 
           213 | 
           			});
  | 
        
        
            | 
            | 
           214 | 
           		} else { // sinon on optimise, quand on vient de se (de)connecter, pas la peine de rappeler l'annuaire
  | 
        
        
            | 
            | 
           215 | 
           			getEtatUtilisateurSansAnnuaire();
  | 
        
        
            | 
            | 
           216 | 
           		}
  | 
        
        
            | 
            | 
           217 | 
           	}
  | 
        
        
            | 
            | 
           218 | 
              | 
        
        
            | 
            | 
           219 | 
           	/**
  | 
        
        
            | 
            | 
           220 | 
           	 * Va chercher les infos de l'utilisateur Coel sans vérifier l'identité auprès de l'annuaire;
  | 
        
        
            | 
            | 
           221 | 
           	 * transmet un jeton SSO à chaque fois pour que le service se base dessus
  | 
        
        
            | 
            | 
           222 | 
           	 */
  | 
        
        
            | 
            | 
           223 | 
           	public void getEtatUtilisateurSansAnnuaire() {
  | 
        
        
            | 
            | 
           224 | 
           		final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM);
  | 
        
        
            | 
            | 
           225 | 
           		rb.envoyerRequete(null, new JsonRestRequestCallback() {
  | 
        
        
            | 
            | 
           226 | 
           			@Override
  | 
        
        
            | 
            | 
           227 | 
           			public void surReponse(JSONValue responseValue) {
  | 
        
        
            | 
            | 
           228 | 
           				//Coel.LogVersFirebug("réponse reçue");
  | 
        
        
            | 
            | 
           229 | 
           				JSONArray reponse = responseValue.isArray();
  | 
        
        
            | 
            | 
           230 | 
           				if (reponse != null) {
  | 
        
        
            | 
            | 
           231 | 
           					// Identifiant utilisateur ou identifiant de session si non identifié
  | 
        
        
            | 
            | 
           232 | 
           					String login = ((JSONString) reponse.get(1)).stringValue();
  | 
        
        
            | 
            | 
           233 | 
              | 
        
        
            | 
            | 
           234 | 
           					// Drapeau leve si utilisateur deja identifié
  | 
        
        
            | 
            | 
           235 | 
           					boolean identifie = ((JSONBoolean) reponse.get(2)).booleanValue();
  | 
        
        
            | 
            | 
           236 | 
              | 
        
        
            | 
            | 
           237 | 
           					utilisateur.setIdentification(identifie);
  | 
        
        
            | 
            | 
           238 | 
           					utilisateur.setLogin(login);
  | 
        
        
            | 
            | 
           239 | 
              | 
        
        
           | 897 | 
           gduche | 
           240 | 
           					//Ajout des informations licence
  | 
        
        
           | 1197 | 
           jpm | 
           241 | 
           					if (reponse.get(0).isString() != null)	{
  | 
        
        
           | 1909 | 
           mathias | 
           242 | 
           						//Coel.LogVersFirebug("1 : set licence [" + reponse.get(0).isString().stringValue() + "]");
  | 
        
        
           | 1197 | 
           jpm | 
           243 | 
           						utilisateur.setLicence(reponse.get(0).isString().stringValue());
  | 
        
        
           | 897 | 
           gduche | 
           244 | 
           					} else {
  | 
        
        
           | 1909 | 
           mathias | 
           245 | 
           						//Coel.LogVersFirebug("2 : set licence vide");
  | 
        
        
           | 897 | 
           gduche | 
           246 | 
           						utilisateur.setLicence("");
  | 
        
        
            | 
            | 
           247 | 
           					}
  | 
        
        
           | 1906 | 
           mathias | 
           248 | 
              | 
        
        
            | 
            | 
           249 | 
           					//Coel.LogVersFirebug("Utilisateur CoeL chargé !!");
  | 
        
        
            | 
            | 
           250 | 
           					//Coel.LogVersFirebug("id: " + identifie + ", login: " + login + ", licence: " + utilisateur.getLicence());
  | 
        
        
            | 
            | 
           251 | 
           					//Coel.LogVersFirebug("Taille réponse:" + reponse.size());
  | 
        
        
            | 
            | 
           252 | 
              | 
        
        
            | 
            | 
           253 | 
           					// Utilisateur connecté (non anonyme)
  | 
        
        
            | 
            | 
           254 | 
           					if (reponse.size() > 3) {
  | 
        
        
            | 
            | 
           255 | 
           						//Coel.LogVersFirebug("Utilisateur identifié, on charge plus de trucs !");
  | 
        
        
           | 772 | 
           jpm | 
           256 | 
           						// Identifiant de l'utilisateur ou identifiant de session si non identifié
  | 
        
        
           | 1906 | 
           mathias | 
           257 | 
           						String idUtilisateur = ((JSONString) reponse.get(1)).stringValue();
  | 
        
        
            | 
            | 
           258 | 
           						//Coel.LogVersFirebug("ID utilisateur: " + idUtilisateur);
  | 
        
        
            | 
            | 
           259 | 
           						utilisateur.setId(idUtilisateur);
  | 
        
        
            | 
            | 
           260 | 
              | 
        
        
            | 
            | 
           261 | 
           						// Nom complet de l'utilisateur
  | 
        
        
            | 
            | 
           262 | 
           						if (reponse.get(3).isString() != null) {
  | 
        
        
            | 
            | 
           263 | 
           							String nomComplet = ((JSONString) reponse.get(3)).stringValue();
  | 
        
        
            | 
            | 
           264 | 
           							//Coel.LogVersFirebug("Nom complet: " + nomComplet);
  | 
        
        
            | 
            | 
           265 | 
           							utilisateur.setNomComplet(nomComplet);
  | 
        
        
           | 132 | 
           jpm | 
           266 | 
           						}
  | 
        
        
           | 1906 | 
           mathias | 
           267 | 
           						// Prénom de l'utilisateur
  | 
        
        
            | 
            | 
           268 | 
           						if (reponse.get(4).isString() != null) {
  | 
        
        
            | 
            | 
           269 | 
           							String prenom = ((JSONString) reponse.get(4)).stringValue();
  | 
        
        
            | 
            | 
           270 | 
           							utilisateur.setPrenom(prenom);
  | 
        
        
            | 
            | 
           271 | 
           							//Coel.LogVersFirebug("Prénom: " + prenom);
  | 
        
        
            | 
            | 
           272 | 
           						}
  | 
        
        
            | 
            | 
           273 | 
           						// Nom de l'utilisateur
  | 
        
        
            | 
            | 
           274 | 
           						if (reponse.get(5).isString() != null) {
  | 
        
        
            | 
            | 
           275 | 
           							String nom = ((JSONString) reponse.get(5)).stringValue();
  | 
        
        
            | 
            | 
           276 | 
           							utilisateur.setNom(nom);
  | 
        
        
            | 
            | 
           277 | 
           							//Coel.LogVersFirebug("Nom: " + nom);
  | 
        
        
            | 
            | 
           278 | 
           						}
  | 
        
        
            | 
            | 
           279 | 
           						// Paramètre => was ist das ?
  | 
        
        
            | 
            | 
           280 | 
           						if (reponse.get(6).isString() != null) {
  | 
        
        
            | 
            | 
           281 | 
           							String parametre = ((JSONString) reponse.get(6)).stringValue();
  | 
        
        
            | 
            | 
           282 | 
           							utilisateur.setParametre(parametre);
  | 
        
        
            | 
            | 
           283 | 
           							//Coel.LogVersFirebug("Paramètre: " + parametre);
  | 
        
        
            | 
            | 
           284 | 
           						}
  | 
        
        
           | 358 | 
           jp_milcent | 
           285 | 
           					}
  | 
        
        
           | 1906 | 
           mathias | 
           286 | 
              | 
        
        
            | 
            | 
           287 | 
           					//Coel.LogVersFirebug("Rafraîchissement vue");
  | 
        
        
            | 
            | 
           288 | 
           					vueARafraichir.rafraichir(utilisateur);
  | 
        
        
           | 64 | 
           jpm | 
           289 | 
           				}
  | 
        
        
           | 772 | 
           jpm | 
           290 | 
           			}
  | 
        
        
            | 
            | 
           291 | 
           		});
  | 
        
        
           | 64 | 
           jpm | 
           292 | 
           	}
  | 
        
        
           | 1906 | 
           mathias | 
           293 | 
              | 
        
        
            | 
            | 
           294 | 
           	/**
  | 
        
        
           | 1908 | 
           mathias | 
           295 | 
           	 * Envoie une info au service utilisateur de Coel comme quoi le mec a accepté la licence
  | 
        
        
           | 1906 | 
           mathias | 
           296 | 
           	 */
  | 
        
        
           | 897 | 
           gduche | 
           297 | 
           	public void accepterLicence()	{
  | 
        
        
           | 1909 | 
           mathias | 
           298 | 
           		//Coel.LogVersFirebug("accepter licence: " + utilisateur.getLogin());
  | 
        
        
           | 1908 | 
           mathias | 
           299 | 
           		String[] parametres = {
  | 
        
        
            | 
            | 
           300 | 
           			"setLicence",
  | 
        
        
            | 
            | 
           301 | 
           			utilisateur.getLogin()
  | 
        
        
            | 
            | 
           302 | 
           		};
  | 
        
        
           | 897 | 
           gduche | 
           303 | 
              | 
        
        
            | 
            | 
           304 | 
           		final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres);
  | 
        
        
            | 
            | 
           305 | 
           		rb.envoyerRequete(null, new JsonRestRequestCallback() {
  | 
        
        
            | 
            | 
           306 | 
           			@Override
  | 
        
        
            | 
            | 
           307 | 
           			public void surReponse(JSONValue responseValue) {
  | 
        
        
           | 1909 | 
           mathias | 
           308 | 
           				//Coel.LogVersFirebug("sur réponse setLicence");
  | 
        
        
           | 897 | 
           gduche | 
           309 | 
           				if (responseValue.isArray() != null) {
  | 
        
        
            | 
            | 
           310 | 
           					final JSONArray reponse = responseValue.isArray();
  | 
        
        
           | 1329 | 
           cyprien | 
           311 | 
           					if (reponse.get(0).isString() != null)	{
  | 
        
        
            | 
            | 
           312 | 
           						String licenceAcceptee = reponse.get(0).isString().stringValue();
  | 
        
        
           | 897 | 
           gduche | 
           313 | 
           						Information info = new Information("maj_licence");
  | 
        
        
            | 
            | 
           314 | 
           						info.setDonnee(0, licenceAcceptee);
  | 
        
        
           | 1909 | 
           mathias | 
           315 | 
           						//Coel.LogVersFirebug("licence acceptée : " + licenceAcceptee);
  | 
        
        
           | 897 | 
           gduche | 
           316 | 
           						vueARafraichir.rafraichir(info);
  | 
        
        
            | 
            | 
           317 | 
           					}
  | 
        
        
            | 
            | 
           318 | 
           				}
  | 
        
        
            | 
            | 
           319 | 
           			}
  | 
        
        
            | 
            | 
           320 | 
           		});
  | 
        
        
            | 
            | 
           321 | 
           	}
  | 
        
        
            | 
            | 
           322 | 
           }
  |