com.tambapps.http.hyperpoet.Headers Maven / Gradle / Ivy
package com.tambapps.http.hyperpoet;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;
public final class Headers {
public static String AUTHORIZATION = "Authorization";
private Headers() {}
public static List basicAuth(String user, String password) {
return basicAuth(user + ":" + password);
}
public static List basicAuth(String credentials) {
return authorization(String.format("Basic %s", Base64.getEncoder()
.encodeToString(credentials.getBytes(StandardCharsets.UTF_8))));
}
public static List bearer(String token) {
return authorization(String.format("Bearer %s", token));
}
public static List authorization(String value) {
return Arrays.asList(AUTHORIZATION, value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy