Subversion Repositories eFlore/Applications.coel

Rev

Rev 1906 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.http;

import org.tela_botanica.client.modeles.Utilisateur;

import com.google.gwt.http.client.RequestBuilder;

public class RequestBuilderWithCredentials extends RequestBuilder {

        /**
         * Crée une requête AJAX avec les headers "Credentials" (pour CORS) et "Authorization" (pour SSO)
         */
        public RequestBuilderWithCredentials(Method httpMethod, String url) {
                this(httpMethod, url, true);
        }

        /**
         * Crée une requête AJAX avec les headers "Credentials" (pour CORS); si authorizationHeader est true,
         * ajoute le header "Authorization" pour SSO
         */
        public RequestBuilderWithCredentials(Method httpMethod, String url, boolean authorizationHeader) {
                super(httpMethod, url);
                if(authorizationHeader && Utilisateur.getJeton() != null && ! Utilisateur.getJeton().isEmpty()) {
                        this.setHeader("Authorization", Utilisateur.getJeton());
                }
                this.setIncludeCredentials(true);
        }
}