org.codehaus.httpcache4j.auth.BasicAuthentication Maven / Gradle / Ivy
The newest version!
package org.codehaus.httpcache4j.auth;
import java.nio.charset.Charset;
import org.codehaus.httpcache4j.UsernamePasswordChallenge;
import java.util.Base64;
/**
* @author Erlend Hamnaberg
*/
public class BasicAuthentication {
private static final Charset UTF_8 = Charset.forName("UTF-8");
public static String getHeaderValue(UsernamePasswordChallenge challenge) {
String basicString = challenge.getIdentifier() + ":" + new String(challenge.getPassword());
return "Basic " + Base64.getEncoder().encodeToString(basicString.getBytes(UTF_8));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy