Class AuthenticationBuilder
- java.lang.Object
-
- org.eclipse.aether.util.repository.AuthenticationBuilder
-
public final class AuthenticationBuilder extends Object
A utility class to build authentication info for repositories and proxies.
-
-
Constructor Summary
Constructors Constructor Description AuthenticationBuilder()
Creates a new authentication builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthenticationBuilder
addCustom(Authentication authentication)
Adds custom authentication data to the authentication.AuthenticationBuilder
addHostnameVerifier(HostnameVerifier verifier)
Adds a hostname verifier for SSL.AuthenticationBuilder
addNtlm(String workstation, String domain)
Adds NTLM data to the authentication.AuthenticationBuilder
addPassword(char[] password)
Adds password data to the authentication.AuthenticationBuilder
addPassword(String password)
Adds password data to the authentication.AuthenticationBuilder
addPrivateKey(String pathname, char[] passphrase)
Adds private key data to the authentication.AuthenticationBuilder
addPrivateKey(String pathname, String passphrase)
Adds private key data to the authentication.AuthenticationBuilder
addSecret(String key, char[] value)
Adds sensitive custom string data to the authentication.AuthenticationBuilder
addSecret(String key, String value)
Adds sensitive custom string data to the authentication.AuthenticationBuilder
addString(String key, String value)
Adds custom string data to the authentication.AuthenticationBuilder
addUsername(String username)
Adds username data to the authentication.Authentication
build()
Builds a new authentication object from the current data of this builder.
-
-
-
Constructor Detail
-
AuthenticationBuilder
public AuthenticationBuilder()
Creates a new authentication builder.
-
-
Method Detail
-
build
public Authentication build()
Builds a new authentication object from the current data of this builder. The state of the builder itself remains unchanged.- Returns:
- The authentication or
null
if no authentication data was supplied to the builder.
-
addUsername
public AuthenticationBuilder addUsername(String username)
Adds username data to the authentication.- Parameters:
username
- The username, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addPassword
public AuthenticationBuilder addPassword(String password)
Adds password data to the authentication.- Parameters:
password
- The password, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addPassword
public AuthenticationBuilder addPassword(char[] password)
Adds password data to the authentication. The resulting authentication object uses an encrypted copy of the supplied character data and callers are advised to clear the input array soon after this method returns.- Parameters:
password
- The password, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addNtlm
public AuthenticationBuilder addNtlm(String workstation, String domain)
Adds NTLM data to the authentication.- Parameters:
workstation
- The NTLM workstation name, may benull
.domain
- The NTLM domain name, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addPrivateKey
public AuthenticationBuilder addPrivateKey(String pathname, String passphrase)
Adds private key data to the authentication.- Parameters:
pathname
- The (absolute) path to the private key file, may benull
.passphrase
- The passphrase protecting the private key, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addPrivateKey
public AuthenticationBuilder addPrivateKey(String pathname, char[] passphrase)
Adds private key data to the authentication. The resulting authentication object uses an encrypted copy of the supplied character data and callers are advised to clear the input array soon after this method returns.- Parameters:
pathname
- The (absolute) path to the private key file, may benull
.passphrase
- The passphrase protecting the private key, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addHostnameVerifier
public AuthenticationBuilder addHostnameVerifier(HostnameVerifier verifier)
Adds a hostname verifier for SSL. Note: This method assumes that all possible instances of the verifier's runtime type exhibit the exact same behavior, i.e. the behavior of the verifier depends solely on the runtime type and not on any configuration. For verifiers that do not fit this assumption, useaddCustom(Authentication)
with a suitable implementation instead.- Parameters:
verifier
- The hostname verifier, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addString
public AuthenticationBuilder addString(String key, String value)
Adds custom string data to the authentication. Note: If the string data is confidential, useaddSecret(String, char[])
instead.- Parameters:
key
- The key for the authentication data, must not benull
.value
- The value for the authentication data, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addSecret
public AuthenticationBuilder addSecret(String key, String value)
Adds sensitive custom string data to the authentication.- Parameters:
key
- The key for the authentication data, must not benull
.value
- The value for the authentication data, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addSecret
public AuthenticationBuilder addSecret(String key, char[] value)
Adds sensitive custom string data to the authentication. The resulting authentication object uses an encrypted copy of the supplied character data and callers are advised to clear the input array soon after this method returns.- Parameters:
key
- The key for the authentication data, must not benull
.value
- The value for the authentication data, may benull
.- Returns:
- This builder for chaining, never
null
.
-
addCustom
public AuthenticationBuilder addCustom(Authentication authentication)
Adds custom authentication data to the authentication.- Parameters:
authentication
- The authentication to add, may benull
.- Returns:
- This builder for chaining, never
null
.
-
-