Package com.mongodb
Interface SubjectProvider
-
- All Known Implementing Classes:
KerberosSubjectProvider
@ThreadSafe public interface SubjectProvider
This interface enables applications to take full control of the lifecycle of theSubject
with which authentication requests are executed. For each authentication request, the driver will call thegetSubject()
method and execute the SASL conversation via a call toSubject.doAs(Subject, PrivilegedAction)
.Implementations of this interface will typically cache a
Subject
instance for some period of time before replacing it with a different instance, say, after the expiration time of a ticket has passed.Applications should register an instance of a class implementation this interface as a mechanism property of a
MongoCredential
via a call toMongoCredential.withMechanismProperty(String, Object)
using the keyMongoCredential.JAVA_SUBJECT_PROVIDER_KEY
If use of the same
Subject
for the lifetime of the application is sufficient, an application can simply create a singleSubject
and associate it with aMongoCredential
as a mechanism property using the keyMongoCredential.JAVA_SUBJECT_KEY
.- Since:
- 4.2
- See Also:
MongoCredential
,MongoCredential.JAVA_SUBJECT_PROVIDER_KEY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Subject
getSubject()
Gets the Subject to use for an authentication request.
-
-
-
Method Detail
-
getSubject
@Nullable Subject getSubject() throws LoginException
Gets the Subject to use for an authentication request.- Returns:
- the
Subject
, which may be null - Throws:
LoginException
- a login exception
-
-