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