@Deprecated public static final String MONGODB_CR_MECHANISM
The MongoDB Challenge Response mechanism.
public static final String MONGODB_X509_MECHANISM
The MongoDB X.509
public static final String SCRAM_SHA_1_MECHANISM
The SCRAM-SHA-1 Mechanism.
public static final String SCRAM_SHA_256_MECHANISM
The SCRAM-SHA-256 Mechanism.
public static final String SERVICE_NAME_KEY
Mechanism property key for overriding the service name for GSSAPI authentication.
createGSSAPICredential(String)
, withMechanismProperty(String, Object)
, Constant Field Values
public static final String CANONICALIZE_HOST_NAME_KEY
Mechanism property key for specifying whether to canonicalize the host name for GSSAPI authentication.
createGSSAPICredential(String)
, withMechanismProperty(String, Object)
, Constant Field Values
public static final String JAVA_SASL_CLIENT_PROPERTIES_KEY
Mechanism property key for overriding the SaslClient properties for GSSAPI authentication. The value of this property must be a
Map<String, Object>
. In most cases there is no need to set this mechanism property. But if an application does:
Sasl.CREDENTIALS
property to an instance of GSSCredential
.Sasl.MAX_BUFFER
property to "0" to ensure compatibility with all versions of MongoDB.createGSSAPICredential(String)
, withMechanismProperty(String, Object)
, Sasl
, Sasl.CREDENTIALS
, Sasl.MAX_BUFFER
, Constant Field Values
public static final String JAVA_SUBJECT_KEY
Mechanism property key for overriding the
Subject
under which GSSAPI authentication executes.
createGSSAPICredential(String)
, withMechanismProperty(String, Object)
, Constant Field Values
public static MongoCredential createCredential(String userName, String database, char[] password)
If the server version is 4.0 or higher, the driver will negotiate with the server preferring the SCRAM-SHA-256 mechanism. 3.x servers will authenticate using SCRAM-SHA-1, older servers will authenticate using the MONGODB_CR mechanism.
userName
- the user name
database
- the database where the user is defined
password
- the user's password
public static MongoCredential createScramSha1Credential(String userName, String source, char[] password)
Creates a MongoCredential instance for the SCRAM-SHA-1 SASL mechanism. Use this method only if you want to ensure that the driver uses the SCRAM-SHA-1 mechanism regardless of whether the server you are connecting to supports the authentication mechanism. Otherwise use the
createCredential(String, String, char[])
method to allow the driver to negotiate the best mechanism based on the server version.
userName
- the non-null user name
source
- the source where the user is defined.
password
- the non-null user password
createCredential(String, String, char[])
public static MongoCredential createScramSha256Credential(String userName, String source, char[] password)
Creates a MongoCredential instance for the SCRAM-SHA-256 SASL mechanism.
userName
- the non-null user name
source
- the source where the user is defined.
password
- the non-null user password
createCredential(String, String, char[])
@Deprecated public static MongoCredential createMongoCRCredential(String userName, String database, char[] password)
Creates a MongoCredential instance for the MongoDB Challenge Response protocol. Use this method only if you want to ensure that the driver uses the MONGODB_CR mechanism regardless of whether the server you are connecting to supports a more secure authentication mechanism. Otherwise use the
createCredential(String, String, char[])
method to allow the driver to negotiate the best mechanism based on the server version.
userName
- the user name
database
- the database where the user is defined
password
- the user's password
createCredential(String, String, char[])
public static MongoCredential createMongoX509Credential(String userName)
Creates a MongoCredential instance for the MongoDB X.509 protocol.
public static MongoCredential createMongoX509Credential()
Available on MongoDB server versions >= 3.4.
public static MongoCredential createPlainCredential(String userName, String source, char[] password)
Creates a MongoCredential instance for the PLAIN SASL mechanism.
public static MongoCredential createGSSAPICredential(String userName)
Creates a MongoCredential instance for the GSSAPI SASL mechanism.
To override the default service name of "mongodb"
, add a mechanism property with the name "SERVICE_NAME"
.
To force canonicalization of the host name prior to authentication, add a mechanism property with the name "CANONICALIZE_HOST_NAME"
with the valuetrue
.
To override the Subject
with which the authentication executes, add a mechanism property with the name "JAVA_SUBJECT"
with the value of a Subject
instance.
To override the properties of the SaslClient
with which the authentication executes, add a mechanism property with the name "JAVA_SASL_CLIENT_PROPERTIES"
with the value of a Map<String, Object
instance containing the necessary properties. This can be useful if the application is customizing the default SaslClientFactory
.
userName
- the non-null user name
withMechanismProperty(String, Object)
, SERVICE_NAME_KEY
, CANONICALIZE_HOST_NAME_KEY
, JAVA_SUBJECT_KEY
, JAVA_SASL_CLIENT_PROPERTIES_KEY
public <T> MongoCredential withMechanismProperty(String key, T value)
Creates a new MongoCredential as a copy of this instance, with the specified mechanism property added.
T
- the property type
key
- the key to the property, which is treated as case-insensitive
value
- the value of the property
public MongoCredential withMechanism(AuthenticationMechanism mechanism)
Creates a new MongoCredential with the set mechanism. The existing mechanism must be null.
mechanism
- the mechanism to set
@Nullable public AuthenticationMechanism getAuthenticationMechanism()
Gets the mechanism
public String getSource()
Gets the source of the user name, typically the name of the database where the user is defined.
@Nullable public char[] getPassword()
Gets the password.
@Nullable public <T> T getMechanismProperty(String key, @Nullable T defaultValue)
Get the value of the given key to a mechanism property, or defaultValue if there is no mapping.
T
- the value type
key
- the mechanism property key, which is treated as case-insensitive
defaultValue
- the default value, if no mapping exists
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4