Class StitchAuthImpl
- java.lang.Object
-
- com.mongodb.stitch.core.auth.internal.CoreStitchAuth<StitchUser>
-
- com.mongodb.stitch.server.core.auth.internal.StitchAuthImpl
-
- All Implemented Interfaces:
StitchAuthRequestClient
,StitchAuth
,Closeable
,AutoCloseable
public final class StitchAuthImpl extends CoreStitchAuth<StitchUser> implements StitchAuth
-
-
Constructor Summary
Constructors Constructor Description StitchAuthImpl(StitchRequestClient requestClient, StitchAuthRoutes authRoutes, Storage storage, StitchAppClientInfo appInfo)
-
Method Summary
Modifier and Type Method Description void
addAuthListener(StitchAuthListener listener)
Adds a listener for any important auth event.protected Document
getDeviceInfo()
<ClientT> ClientT
getProviderClient(AuthProviderClientFactory<ClientT> factory)
Gets a client for the given authentication provider.<T> T
getProviderClient(NamedAuthProviderClientFactory<T> factory, String providerName)
Gets a client for the given named authentication provider.protected StitchUserFactory<StitchUser>
getUserFactory()
StitchUser
loginWithCredential(StitchCredential credential)
Logs a user in with the given credentials associated with an authentication provider created fromStitchAuth.getProviderClient(AuthProviderClientFactory)
orStitchAuth.getProviderClient(NamedAuthProviderClientFactory, String)
.void
logout()
Logs out the currently logged in, active user.void
logoutUserWithId(String userId)
Logs out the a user with the provided id.protected void
onActiveUserChanged(StitchUser currentActiveUser, StitchUser previousActiveUser)
protected void
onAuthEvent()
protected void
onListenerInitialized()
protected void
onUserAdded(StitchUser createdUser)
protected void
onUserLinked(StitchUser linkedUser)
protected void
onUserLoggedIn(StitchUser loggedInUser)
protected void
onUserLoggedOut(StitchUser loggedOutUser)
protected void
onUserRemoved(StitchUser removedUser)
void
refreshCustomData()
You can store arbitrary data about your application users in a MongoDB collection and configure Stitch to automatically expose each user’s data in a field of their user object.void
removeAuthListener(StitchAuthListener listener)
Removes a listener.void
removeUser()
Logs out and removes the currently logged in, active user.void
removeUserWithId(String userId)
Logs out and removes the a user with the provided id.-
Methods inherited from class com.mongodb.stitch.core.auth.internal.CoreStitchAuth
close, doAuthenticatedRequest, doAuthenticatedRequest, doAuthenticatedRequest, getAuthRoutes, getDeviceId, getRequestClient, getUser, hasDeviceId, isLoggedIn, isLoggedInInterruptibly, linkUserWithCredentialInternal, listUsers, loginWithCredentialInternal, logoutInternal, logoutUserWithIdInternal, openAuthenticatedStream, refreshAccessToken, removeUserInternal, removeUserWithIdInternal, switchToUserWithId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.mongodb.stitch.server.core.auth.StitchAuth
getUser, isLoggedIn, listUsers, switchToUserWithId
-
-
-
-
Constructor Detail
-
StitchAuthImpl
public StitchAuthImpl(StitchRequestClient requestClient, StitchAuthRoutes authRoutes, Storage storage, StitchAppClientInfo appInfo)
-
-
Method Detail
-
getUserFactory
protected StitchUserFactory<StitchUser> getUserFactory()
- Specified by:
getUserFactory
in classCoreStitchAuth<StitchUser>
-
getProviderClient
public <ClientT> ClientT getProviderClient(AuthProviderClientFactory<ClientT> factory)
Description copied from interface:StitchAuth
Gets a client for the given authentication provider. Most authentication providers will allow creation of a client without a name of the provider.- Specified by:
getProviderClient
in interfaceStitchAuth
- Type Parameters:
ClientT
- The type of client to be returned by the factory.- Parameters:
factory
- The factory that will create a client for the authentication provider.- Returns:
- A client to interact with the authentication provider.
-
getProviderClient
public <T> T getProviderClient(NamedAuthProviderClientFactory<T> factory, String providerName)
Description copied from interface:StitchAuth
Gets a client for the given named authentication provider.- Specified by:
getProviderClient
in interfaceStitchAuth
- Type Parameters:
T
- the type of client to be returned by the factory.- Parameters:
factory
- the factory that will create a client for the authentication provider.providerName
- the name of the authentication provider.- Returns:
- A client to interact with the authentication provider.
-
loginWithCredential
public StitchUser loginWithCredential(StitchCredential credential)
Description copied from interface:StitchAuth
Logs a user in with the given credentials associated with an authentication provider created fromStitchAuth.getProviderClient(AuthProviderClientFactory)
orStitchAuth.getProviderClient(NamedAuthProviderClientFactory, String)
.- Specified by:
loginWithCredential
in interfaceStitchAuth
- Parameters:
credential
- the credentials of the user to log in.- Returns:
- the user associated with the credentials if log in is successful.
-
logout
public void logout()
Description copied from interface:StitchAuth
Logs out the currently logged in, active user. Switches to the next logged in user if there is another.- Specified by:
logout
in interfaceStitchAuth
-
logoutUserWithId
public void logoutUserWithId(String userId)
Description copied from interface:StitchAuth
Logs out the a user with the provided id. Throws an exception if the user was not found.- Specified by:
logoutUserWithId
in interfaceStitchAuth
- Parameters:
userId
- the id of the user to logoutUserWithId
-
removeUser
public void removeUser()
Description copied from interface:StitchAuth
Logs out and removes the currently logged in, active user. Switches to the next logged in user if there is another.- Specified by:
removeUser
in interfaceStitchAuth
-
removeUserWithId
public void removeUserWithId(String userId)
Description copied from interface:StitchAuth
Logs out and removes the a user with the provided id. Throws an exception if the user was not found.- Specified by:
removeUserWithId
in interfaceStitchAuth
- Parameters:
userId
- the id of the user to remove
-
addAuthListener
public void addAuthListener(StitchAuthListener listener)
Adds a listener for any important auth event.- Specified by:
addAuthListener
in interfaceStitchAuth
- Parameters:
listener
- the listener to add.- See Also:
StitchAuthListener
-
removeAuthListener
public void removeAuthListener(StitchAuthListener listener)
Removes a listener.- Specified by:
removeAuthListener
in interfaceStitchAuth
- Parameters:
listener
- the listener to remove.- See Also:
StitchAuthListener
-
onAuthEvent
protected void onAuthEvent()
- Specified by:
onAuthEvent
in classCoreStitchAuth<StitchUser>
-
onListenerInitialized
protected void onListenerInitialized()
- Specified by:
onListenerInitialized
in classCoreStitchAuth<StitchUser>
-
onActiveUserChanged
protected void onActiveUserChanged(@Nullable StitchUser currentActiveUser, @Nullable StitchUser previousActiveUser)
- Specified by:
onActiveUserChanged
in classCoreStitchAuth<StitchUser>
-
onUserAdded
protected void onUserAdded(StitchUser createdUser)
- Specified by:
onUserAdded
in classCoreStitchAuth<StitchUser>
-
onUserLoggedIn
protected void onUserLoggedIn(StitchUser loggedInUser)
- Specified by:
onUserLoggedIn
in classCoreStitchAuth<StitchUser>
-
onUserRemoved
protected void onUserRemoved(StitchUser removedUser)
- Specified by:
onUserRemoved
in classCoreStitchAuth<StitchUser>
-
onUserLoggedOut
protected void onUserLoggedOut(StitchUser loggedOutUser)
- Specified by:
onUserLoggedOut
in classCoreStitchAuth<StitchUser>
-
onUserLinked
protected void onUserLinked(StitchUser linkedUser)
- Specified by:
onUserLinked
in classCoreStitchAuth<StitchUser>
-
getDeviceInfo
protected Document getDeviceInfo()
- Overrides:
getDeviceInfo
in classCoreStitchAuth<StitchUser>
-
refreshCustomData
public void refreshCustomData()
Description copied from interface:StitchAuth
You can store arbitrary data about your application users in a MongoDB collection and configure Stitch to automatically expose each user’s data in a field of their user object. For example, you might store a user’s preferred language, date of birth, or their local timezone. If this functionality has not been configured, this is a no-op.- Specified by:
refreshCustomData
in interfaceStitchAuth
-
-