io.dropwizard.client.proxy.AuthConfiguration Maven / Gradle / Ivy
package io.dropwizard.client.proxy;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.validation.constraints.NotEmpty;
import javax.annotation.Nullable;
import javax.validation.constraints.Pattern;
/**
* Represents a configuration of credentials for either Username Password or NT credentials
*
* Configuration Parameters:
*
*
* Name
* Default
* Description
*
*
* {@code username}
* REQUIRED
* The username used to connect to the server.
*
*
* {@code password}
* REQUIRED
* The password used to connect to the server.
*
*
* {@code authScheme}
* null
* Optional, The authentication scheme used by the underlying
* {@link org.apache.http.auth.AuthScope} class. Can be one of:
* - Basic
- NTLM
*
*
* {@code realm}
* null
* Optional, Realm to be used for NTLM Authentication.
*
*
* {@code hostname}
* null
* The hostname of the Principal in NTLM Authentication.
*
*
* {@code domain}
* null
* Optional, The domain used in NTLM Authentication.
*
*
* {@code credentialType}
* null
* The {@link org.apache.http.auth.Credentials} implementation
* to use for proxy authentication. Currently supports
* UsernamePassword ({@link org.apache.http.auth.UsernamePasswordCredentials}) and
* NT ({@link org.apache.http.auth.NTCredentials})
*
*
*/
public class AuthConfiguration {
public static final String BASIC_AUTH_SCHEME = "Basic";
public static final String NTLM_AUTH_SCHEME = "NTLM";
public static final String USERNAME_PASSWORD_CREDS = "UsernamePassword";
public static final String NT_CREDS = "NT";
@NotEmpty
private String username = "";
@NotEmpty
private String password = "";
@Pattern(regexp = BASIC_AUTH_SCHEME + "|" + NTLM_AUTH_SCHEME)
@Nullable
private String authScheme;
@Nullable
private String realm;
@Nullable
private String hostname;
@Nullable
private String domain;
@Pattern(regexp = USERNAME_PASSWORD_CREDS + "|" + NT_CREDS, flags = {Pattern.Flag.CASE_INSENSITIVE})
@Nullable
private String credentialType;
public AuthConfiguration() {
}
public AuthConfiguration(String username, String password) {
this.username = username;
this.password = password;
}
public AuthConfiguration(String username, String password, String authScheme, String realm, String hostname, String domain, String credentialType) {
this.username = username;
this.password = password;
this.authScheme = authScheme;
this.realm = realm;
this.hostname = hostname;
this.domain = domain;
this.credentialType = credentialType;
}
@JsonProperty
public String getUsername() {
return username;
}
@JsonProperty
public void setUsername(String username) {
this.username = username;
}
@JsonProperty
public String getPassword() {
return password;
}
@JsonProperty
public void setPassword(String password) {
this.password = password;
}
@JsonProperty
@Nullable
public String getAuthScheme() {
return authScheme;
}
@JsonProperty
public void setAuthScheme(String authScheme) {
this.authScheme = authScheme;
}
@JsonProperty
@Nullable
public String getRealm() {
return realm;
}
@JsonProperty
public void setRealm(String realm) {
this.realm = realm;
}
@JsonProperty
@Nullable
public String getHostname() {
return hostname;
}
@JsonProperty
public void setHostname(String hostname) {
this.hostname = hostname;
}
@JsonProperty
@Nullable
public String getDomain() {
return domain;
}
@JsonProperty
public void setDomain(String domain) {
this.domain = domain;
}
@JsonProperty
@Nullable
public String getCredentialType() {
return credentialType;
}
@JsonProperty
public void setCredentialType(String credentialType) {
this.credentialType = credentialType;
}
}