
com.botscrew.botframework.plivo.util.PlivoHttpHeadersCreator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plivo-spring-boot-starter Show documentation
Show all versions of plivo-spring-boot-starter Show documentation
Module for making SMS chatbot based on Plivo API and Bot Framework
The newest version!
/*
* Copyright 2019 BotsCrew
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.botscrew.botframework.plivo.util;
import org.apache.tomcat.util.codec.binary.Base64;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import java.nio.charset.Charset;
public class PlivoHttpHeadersCreator {
private PlivoHttpHeadersCreator() {}
public static HttpHeaders createHeaders(String authId, String authToken) {
HttpHeaders headers = new HttpHeaders();
String auth = authId + ":" + authToken;
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("UTF-8")));
String authHeader = "Basic " + new String(encodedAuth);
headers.set("Authorization", authHeader);
headers.setContentType(MediaType.APPLICATION_JSON);
return headers;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy