Subversion Repositories eFlore/Applications.coel

Rev

Rev 1908 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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