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

java-micronaut.client.auth.configuration.HttpBasicAuthConfiguration.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{>common/licenseInfo}}
package {{invokerPackage}}.auth.configuration;

import io.micronaut.context.annotation.ConfigurationInject;
import io.micronaut.context.annotation.EachProperty;
import io.micronaut.context.annotation.Parameter;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.http.MutableHttpRequest;
import {{javaxPackage}}.annotation.Generated;


{{>common/generatedAnnotation}}
@EachProperty("security.basic-auth")
public class HttpBasicAuthConfiguration implements ConfigurableAuthorization {
    private final String name;
    private String username;
    private String password;

    @ConfigurationInject
    public HttpBasicAuthConfiguration(
            @Parameter String name,
            @NonNull String username,
            @NonNull String password
    ) {
        this.name = name;
        this.username = username;
        this.password = password;
    }

    @Override
    public void applyAuthorization(@NonNull MutableHttpRequest request) {
        request.basicAuth(username, password);
    }

    @Override
    public String getName() {
        return this.name;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy