package br.ufrgs.inf.prosoft;

import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.security.crypto.codec.Base64;

import java.nio.charset.Charset;

public class HeadersConfig {

    public static HttpHeaders getHeaderAdmin(){
        HttpHeaders headers = new HttpHeaders();
        MediaType mediaType = new MediaType("application", "json", Charset.forName("UTF-8"));
        //MediaType.APPLICATION_JSON //for application/json
        headers.setContentType(mediaType);
        //Basic Authentication
        String authorisation = "admin" + ":" + "password";
        byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes());
        headers.add("Authorization", "Basic " + new String(encodedAuthorisation));
        return headers;
    }

    public static HttpHeaders getHeaderCustomer(){
        HttpHeaders headers = new HttpHeaders();
        MediaType mediaType = new MediaType("application", "json", Charset.forName("UTF-8"));
        //MediaType.APPLICATION_JSON //for application/json
        headers.setContentType(mediaType);
        return headers;
    }
}
