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 voidaddAuthListener(StitchAuthListener listener)Adds a listener for any important auth event.protected DocumentgetDeviceInfo()<ClientT> ClientTgetProviderClient(AuthProviderClientFactory<ClientT> factory)Gets a client for the given authentication provider.<T> TgetProviderClient(NamedAuthProviderClientFactory<T> factory, String providerName)Gets a client for the given named authentication provider.protected StitchUserFactory<StitchUser>getUserFactory()StitchUserloginWithCredential(StitchCredential credential)Logs a user in with the given credentials associated with an authentication provider created fromStitchAuth.getProviderClient(AuthProviderClientFactory)orStitchAuth.getProviderClient(NamedAuthProviderClientFactory, String).voidlogout()Logs out the currently logged in, active user.voidlogoutUserWithId(String userId)Logs out the a user with the provided id.protected voidonActiveUserChanged(StitchUser currentActiveUser, StitchUser previousActiveUser)protected voidonAuthEvent()protected voidonListenerInitialized()protected voidonUserAdded(StitchUser createdUser)protected voidonUserLinked(StitchUser linkedUser)protected voidonUserLoggedIn(StitchUser loggedInUser)protected voidonUserLoggedOut(StitchUser loggedOutUser)protected voidonUserRemoved(StitchUser removedUser)voidrefreshCustomData()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.voidremoveAuthListener(StitchAuthListener listener)Removes a listener.voidremoveUser()Logs out and removes the currently logged in, active user.voidremoveUserWithId(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:
getUserFactoryin classCoreStitchAuth<StitchUser>
-
getProviderClient
public <ClientT> ClientT getProviderClient(AuthProviderClientFactory<ClientT> factory)
Description copied from interface:StitchAuthGets a client for the given authentication provider. Most authentication providers will allow creation of a client without a name of the provider.- Specified by:
getProviderClientin 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:StitchAuthGets a client for the given named authentication provider.- Specified by:
getProviderClientin 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:StitchAuthLogs a user in with the given credentials associated with an authentication provider created fromStitchAuth.getProviderClient(AuthProviderClientFactory)orStitchAuth.getProviderClient(NamedAuthProviderClientFactory, String).- Specified by:
loginWithCredentialin 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:StitchAuthLogs out the currently logged in, active user. Switches to the next logged in user if there is another.- Specified by:
logoutin interfaceStitchAuth
-
logoutUserWithId
public void logoutUserWithId(String userId)
Description copied from interface:StitchAuthLogs out the a user with the provided id. Throws an exception if the user was not found.- Specified by:
logoutUserWithIdin interfaceStitchAuth- Parameters:
userId- the id of the user to logoutUserWithId
-
removeUser
public void removeUser()
Description copied from interface:StitchAuthLogs out and removes the currently logged in, active user. Switches to the next logged in user if there is another.- Specified by:
removeUserin interfaceStitchAuth
-
removeUserWithId
public void removeUserWithId(String userId)
Description copied from interface:StitchAuthLogs out and removes the a user with the provided id. Throws an exception if the user was not found.- Specified by:
removeUserWithIdin 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:
addAuthListenerin interfaceStitchAuth- Parameters:
listener- the listener to add.- See Also:
StitchAuthListener
-
removeAuthListener
public void removeAuthListener(StitchAuthListener listener)
Removes a listener.- Specified by:
removeAuthListenerin interfaceStitchAuth- Parameters:
listener- the listener to remove.- See Also:
StitchAuthListener
-
onAuthEvent
protected void onAuthEvent()
- Specified by:
onAuthEventin classCoreStitchAuth<StitchUser>
-
onListenerInitialized
protected void onListenerInitialized()
- Specified by:
onListenerInitializedin classCoreStitchAuth<StitchUser>
-
onActiveUserChanged
protected void onActiveUserChanged(@Nullable StitchUser currentActiveUser, @Nullable StitchUser previousActiveUser)
- Specified by:
onActiveUserChangedin classCoreStitchAuth<StitchUser>
-
onUserAdded
protected void onUserAdded(StitchUser createdUser)
- Specified by:
onUserAddedin classCoreStitchAuth<StitchUser>
-
onUserLoggedIn
protected void onUserLoggedIn(StitchUser loggedInUser)
- Specified by:
onUserLoggedInin classCoreStitchAuth<StitchUser>
-
onUserRemoved
protected void onUserRemoved(StitchUser removedUser)
- Specified by:
onUserRemovedin classCoreStitchAuth<StitchUser>
-
onUserLoggedOut
protected void onUserLoggedOut(StitchUser loggedOutUser)
- Specified by:
onUserLoggedOutin classCoreStitchAuth<StitchUser>
-
onUserLinked
protected void onUserLinked(StitchUser linkedUser)
- Specified by:
onUserLinkedin classCoreStitchAuth<StitchUser>
-
getDeviceInfo
protected Document getDeviceInfo()
- Overrides:
getDeviceInfoin classCoreStitchAuth<StitchUser>
-
refreshCustomData
public void refreshCustomData()
Description copied from interface:StitchAuthYou 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:
refreshCustomDatain interfaceStitchAuth
-
-