Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1732 Rev 1906
1
package org.tela_botanica.client.http;
1
package org.tela_botanica.client.http;
-
 
2
 
-
 
3
import org.tela_botanica.client.modeles.Utilisateur;
2
 
4
 
3
import com.google.gwt.http.client.RequestBuilder;
5
import com.google.gwt.http.client.RequestBuilder;
4
 
6
 
5
public class RequestBuilderWithCredentials extends RequestBuilder {
7
public class RequestBuilderWithCredentials extends RequestBuilder {
-
 
8
 
-
 
9
	/**
-
 
10
	 * Crée une requête AJAX avec les headers "Credentials" (pour CORS) et "Authorization" (pour SSO)
6
 
11
	 */
-
 
12
	public RequestBuilderWithCredentials(Method httpMethod, String url) {
-
 
13
		this(httpMethod, url, true);
-
 
14
	}
-
 
15
 
-
 
16
	/**
-
 
17
	 * Crée une requête AJAX avec les headers "Credentials" (pour CORS); si authorizationHeader est true,
-
 
18
	 * ajoute le header "Authorization" pour SSO
-
 
19
	 */
7
	public RequestBuilderWithCredentials(Method httpMethod, String url) {
20
	public RequestBuilderWithCredentials(Method httpMethod, String url, boolean authorizationHeader) {
-
 
21
		super(httpMethod, url);
-
 
22
		if(authorizationHeader && Utilisateur.getJeton() != null && ! Utilisateur.getJeton().isEmpty()) {
-
 
23
			this.setHeader("Authorization", Utilisateur.getJeton());
8
		super(httpMethod, url);
24
		}
9
		this.setIncludeCredentials(true);
25
		this.setIncludeCredentials(true);
10
	}
26
	}
11
}
27
}