public static class Credential.Builder extends Object
Credential
.Modifier and Type | Field and Description |
---|---|
protected String |
myAuthenticationType
The authentication type or mode that the credential should be used
with.
|
protected Authenticator |
myAuthenticator
The template authenticator for the credential.
|
protected String |
myDatabase
The database the credential are valid for.
|
protected File |
myFile
The file containing the full credentials.
|
protected Map<String,String> |
myOptions
Other options for the credentials.
|
protected char[] |
myPassword
The password for the credential set.
|
protected String |
myUserName
The user name for the credential set.
|
Constructor and Description |
---|
Credential.Builder()
Creates a new Builder.
|
Modifier and Type | Method and Description |
---|---|
Credential.Builder |
addOption(String optionName,
boolean optionValue)
Adds an option to the built credentials.
|
Credential.Builder |
addOption(String optionName,
int optionValue)
Adds an option to the built credentials.
|
Credential.Builder |
addOption(String optionName,
String optionValue)
Adds an option to the built credentials.
|
Credential.Builder |
authenticationType(String authenticationType)
Sets the value of the authentication type or mode that the credential
should be used with.
|
Credential.Builder |
authenticator(Authenticator authenticator)
Sets the value of the template authenticator for the credential.
|
Credential |
build()
Creates the credential from this builder.
|
Credential.Builder |
database(String database)
Sets the value of the database the credential are valid for.
|
Credential.Builder |
file(File file)
Sets the value of the file containing the full credentials.
|
Credential.Builder |
kerberos()
Sets the value of the authentication type or mode that the credential
should be used with to Kerberos.
|
Credential.Builder |
ldap()
Sets the value of the authentication type or mode that the credential
should be used with LDAP via PLAIN SASL.
|
Credential.Builder |
mongodbCR()
Sets the value of the authentication type or mode that the credential
should be used with to MongoDB Challenge/Response.
|
Credential.Builder |
pam()
Sets the value of the authentication type or mode that the credential
should be used with PAM via PLAIN SASL.
|
Credential.Builder |
password(char[] password)
Sets the value of the password for the credential set.
|
Credential.Builder |
plainSasl()
Sets the value of the authentication type or mode that the credential
should be used with to PLAIN SASL.
|
Credential.Builder |
reset()
Resets the builder to a known state.
|
Credential.Builder |
setAuthenticationType(String authenticationType)
Sets the value of the authentication type or mode that the credential
should be used with.
|
Credential.Builder |
setAuthenticator(Authenticator authenticator)
Sets the value of the template authenticator for the credential.
|
Credential.Builder |
setDatabase(String database)
Sets the value of the database the credential are valid for.
|
Credential.Builder |
setFile(File file)
Sets the value of the file containing the full credentials.
|
Credential.Builder |
setPassword(char[] password)
Sets the value of the password for the credential set.
|
Credential.Builder |
setUserName(String userName)
Sets the value of the user name for the credential set.
|
Credential.Builder |
userName(String userName)
Sets the value of the user name for the credential set.
|
Credential.Builder |
x509()
Sets the value of the authentication type or mode that the credential
should be used with to x.509 client certificates exchanged via the
TLS connection.
|
Credential.Builder |
x509(X509Certificate cert)
Sets the
user name to that of the x.509
certificate subject name and then sets the value of the
authentication type or mode that the credential should be used with
to x.509 client certificates exchanged via the TLS connection. |
protected String myAuthenticationType
protected Authenticator myAuthenticator
protected String myDatabase
protected File myFile
protected char[] myPassword
protected String myUserName
public Credential.Builder addOption(String optionName, boolean optionValue)
optionName
- The name of the option to set.optionValue
- The value of the option to set.Credential.Builder
for method chaining.public Credential.Builder addOption(String optionName, int optionValue)
optionName
- The name of the option to set.optionValue
- The value of the option to set.Credential.Builder
for method chaining.public Credential.Builder addOption(String optionName, String optionValue)
optionName
- The name of the option to set.optionValue
- The value of the option to set.Credential.Builder
for method chaining.public Credential.Builder authenticationType(String authenticationType)
This method delegates to setAuthenticationType(String)
.
authenticationType
- The new value for the authentication type or mode that the
credential should be used with.Credential.Builder
for method chaining.public Credential.Builder authenticator(Authenticator authenticator)
This method delegates to setAuthenticator(Authenticator)
.
authenticator
- The new value for the template authenticator for the
credential.Credential.Builder
for method chaining.public Credential build()
Credential
populated with the state of this
builder.public Credential.Builder database(String database)
This method delegates to setDatabase(String)
.
database
- The new value for the database the credential are valid
for.Credential.Builder
for method chaining.public Credential.Builder file(File file)
This method delegates to setFile(File)
.
file
- The new value for the file containing the full
credentials.Credential.Builder
for method chaining.public Credential.Builder kerberos()
This method delegates to setAuthenticationType(KERBEROS)
.
Note: Use of Kerberos for authentication requires the driver's extensions. See the Kerberos Usage Guide for details.
Credential.Builder
for method chaining.public Credential.Builder ldap()
This method delegates to setAuthenticationType(PLAIN_SASL)
.
Note: Use of Plain SASL for authentication requires the driver's extensions. See the Plain SASL Usage Guide for details.
Credential.Builder
for method chaining.public Credential.Builder mongodbCR()
This method delegates to setAuthenticationType(MONGODB_CR)
.
Credential.Builder
for method chaining.public Credential.Builder pam()
This method delegates to setAuthenticationType(PLAIN_SASL)
.
Note: Use of Plain SASL for authentication requires the driver's extensions. See the Plain SASL Usage Guide for details.
Credential.Builder
for method chaining.public Credential.Builder password(char[] password)
This method delegates to setPassword(char[])
.
password
- The new value for the password for the credential set.Credential.Builder
for method chaining.public Credential.Builder plainSasl()
This method delegates to setAuthenticationType(PLAIN_SASL)
.
Note: Use of Plain SASL for authentication requires the driver's extensions. See the Plain SASL Usage Guide for details.
Credential.Builder
for method chaining.public Credential.Builder reset()
Credential.Builder
for method chaining.public Credential.Builder setAuthenticationType(String authenticationType)
authenticationType
- The new value for the authentication type or mode that the
credential should be used with.Credential.Builder
for method chaining.public Credential.Builder setAuthenticator(Authenticator authenticator)
authenticator
- The new value for the template authenticator for the
credential.Credential.Builder
for method chaining.public Credential.Builder setDatabase(String database)
database
- The new value for the database the credential are valid
for.Credential.Builder
for method chaining.public Credential.Builder setFile(File file)
file
- The new value for the file containing the full
credentials.Credential.Builder
for method chaining.public Credential.Builder setPassword(char[] password)
password
- The new value for the password for the credential set.Credential.Builder
for method chaining.public Credential.Builder setUserName(String userName)
userName
- The new value for the user name for the credential set.Credential.Builder
for method chaining.public Credential.Builder userName(String userName)
This method delegates to setUserName(String)
.
userName
- The new value for the user name for the credential set.Credential.Builder
for method chaining.public Credential.Builder x509()
This method delegates to setAuthenticationType(X509)
.
Note: Use of x.509 for authentication requires the driver's extensions. See the TLS Usage Guide for details.
Credential.Builder
for method chaining.public Credential.Builder x509(X509Certificate cert)
user name
to that of the x.509
certificate subject name and then sets the value of the
authentication type or mode that the credential should be used with
to x.509 client certificates exchanged via the TLS connection.
This method delegates to userName(cert.getSubjectX500Principal().toString())
.x509()
.
Note: Use of x.509 for authentication requires the driver's extensions. See the TLS Usage Guide for details.
cert
- The client's certificate containing the client subject
name.Credential.Builder
for method chaining.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.