All Downloads are FREE. Search and download functionalities are using the official Maven repository.

infobip.api.config.BasicAuthConfiguration Maven / Gradle / Ivy

There is a newer version: 4.4.0
Show newest version
package infobip.api.config;

import javax.xml.bind.DatatypeConverter;

public class BasicAuthConfiguration extends Configuration {

    private final String username;
    private final String password;

    public BasicAuthConfiguration(String baseUrl, String username, String password) {
        this.baseUrl = baseUrl;
        this.username = username;
        this.password = password;
    }

    public BasicAuthConfiguration(String username, String password) {
        this.baseUrl = "https://api.infobip.com";
        this.username = username;
        this.password = password;
    }

    @Override
    public String getAuthorizationHeader() {
        return "Basic " + encodeBase64();
    }

    private String encodeBase64() {
        String userPass = username + ":" + password;
        return DatatypeConverter.printBase64Binary(userPass.getBytes());
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy