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

br.com.cefis.authentication.BasicAuth Maven / Gradle / Ivy

There is a newer version: 0.0.2
Show newest version
package br.com.cefis.authentication;

import java.net.HttpURLConnection;

public class BasicAuth implements Authentication {
	private final String token;
	private final String key;

	public BasicAuth(String token, String key) {
		this.token = token;
		this.key = key;
	}

	public String getToken() {
		return token;
	}

	public String getKey() {
		return key;
	}

	public void authenticate(HttpURLConnection connection) {
		String authorization = Base64.encode((token + ":" + key).getBytes());

		connection.setRequestProperty("Authorization", "Basic " + authorization);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy