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

com.chavaillaz.client.common.security.PasswordAuthentication Maven / Gradle / Ivy

Go to download

Library for the creation of asynchronous clients supporting multiple HTTP clients

There is a newer version: 2.1.3
Show newest version
package com.chavaillaz.client.common.security;

import static com.chavaillaz.client.common.utility.Utils.encodeBase64;

import java.util.function.BiConsumer;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * Basic authentication with username and password, adding {@code Authorization} header with them.
 */
@Getter
@RequiredArgsConstructor
public class PasswordAuthentication extends AnonymousAuthentication {

    private final String username;
    private final String password;

    @Override
    public void fillHeaders(BiConsumer addHeader) {
        addHeader.accept("Authorization", "Basic " + encodeBase64(getUsername() + ":" + getPassword()));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy