org.hisp.dhis.auth.BasicAuthentication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dhis2-java-client Show documentation
Show all versions of dhis2-java-client Show documentation
DHIS 2 API client for Java.
package org.hisp.dhis.auth;
import java.util.Base64;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.apache.hc.core5.http.HttpHeaders;
@Getter
@RequiredArgsConstructor
public class BasicAuthentication
implements Authentication
{
@NonNull
private final String username;
@NonNull
private final String password;
@Override
public String getHttpHeaderAuthName()
{
return HttpHeaders.AUTHORIZATION;
}
@Override
public String getHttpHeaderAuthValue()
{
String value = String.format( "%s:%s", username, password );
return "Basic " + Base64.getEncoder().encodeToString( value.getBytes() );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy