java-micronaut-client.auth.configuration.HttpBasicAuthConfiguration.mustache Maven / Gradle / Ivy
{{>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 javax.annotation.Generated;
{{>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;
}
}