Class UserService
-
- All Implemented Interfaces:
public final class UserService extends MobileService
Represents the service to retrieve user information from mobile server.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringMOBILE_SERVICES_APPLICATIONpublic final static StringROLE_SERVICE_APPLICATIONpublic final static StringTAG_USER_WORKprivate Applicationapplicationprivate StringapiKey
-
Constructor Summary
Constructors Constructor Description UserService(ServiceListener<User> serviceListener)
-
Method Summary
Modifier and Type Method Description Unitinit(Application application, String apiKey)Initializes the mobile service UnitonStateChange(ApplicationState state)Notified when application state changes. final JobretrieveUser(ServiceListener<User> listener)Retrieves user information. final ServiceResult<User>retrieveUser(Boolean silent)Retrieves the user information from mobile server. final ServiceResult<User>retrieveUser()Retrieves the user information from mobile server. final JoblogoutUser(ServiceListener<Boolean> listener, String userId, String clientId, Boolean keepTokenValid, UserSessionRevokeLevel sessionRevokeLevel)Logouts the current user for Java client. final JoblogoutUser(ServiceListener<Boolean> listener, String userId, String clientId, Boolean keepTokenValid)Logouts the current user for Java client. final JoblogoutUser(ServiceListener<Boolean> listener, String userId, String clientId)Logouts the current user for Java client. final JoblogoutUser(ServiceListener<Boolean> listener, String userId)Logouts the current user for Java client. final JoblogoutUser(ServiceListener<Boolean> listener)Logouts the current user for Java client. final ServiceResult<Boolean>logoutUser(String userId, String clientId, Boolean keepTokenValid, UserSessionRevokeLevel sessionRevokeLevel)Signs out the current onboarded user. final ServiceResult<Boolean>logoutUser(String userId, String clientId, Boolean keepTokenValid)Signs out the current onboarded user. final ServiceResult<Boolean>logoutUser(String userId, String clientId)Signs out the current onboarded user. final ServiceResult<Boolean>logoutUser(String userId)Signs out the current onboarded user. final ServiceResult<Boolean>logoutUser()Signs out the current onboarded user. final JobdeleteRegistration(ServiceListener<Boolean> listener, String userId, String clientId, UserSessionRevokeLevel sessionRevokeLevel)Deletes the registration of the current user. final JobdeleteRegistration(ServiceListener<Boolean> listener, String userId, String clientId)Deletes the registration of the current user. final JobdeleteRegistration(ServiceListener<Boolean> listener, String userId)Deletes the registration of the current user. final JobdeleteRegistration(ServiceListener<Boolean> listener)Deletes the registration of the current user. final ServiceResult<Boolean>deleteRegistration(String userId, String clientId, UserSessionRevokeLevel sessionRevokeLevel)Deletes the registration of the current user. final ServiceResult<Boolean>deleteRegistration(String userId, String clientId)Deletes the registration of the current user. final ServiceResult<Boolean>deleteRegistration(String userId)Deletes the registration of the current user. final ServiceResult<Boolean>deleteRegistration()Deletes the registration of the current user. final JobcheckUserSession(String currentUserId, ServiceListener<Boolean> listener)Checks whether the current user session belongs to the user identified by the given currentUserId, and notify the result out with the given listener final ServiceResult<Boolean>checkUserSession(String currentUserId)Checks whether the current user session belongs to the user identified by the given currentUserId. -
Methods inherited from class com.sap.cloud.mobile.foundation.mobileservices.MobileService
enableNetworkPolicy, getApiKey, getApplication, isApplicationInitialized, mayStartNewProcess, reset, setApiKey, setApplication -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
UserService
UserService(ServiceListener<User> serviceListener)
-
-
Method Detail
-
init
Unit init(Application application, String apiKey)
Initializes the mobile service
-
onStateChange
Unit onStateChange(ApplicationState state)
Notified when application state changes. This function will be called on Main thread.
-
retrieveUser
final Job retrieveUser(ServiceListener<User> listener)
Retrieves user information.
-
retrieveUser
@JvmOverloads() final ServiceResult<User> retrieveUser(Boolean silent)
Retrieves the user information from mobile server.
-
retrieveUser
@JvmOverloads() final ServiceResult<User> retrieveUser()
Retrieves the user information from mobile server.
-
logoutUser
@JvmOverloads() final Job logoutUser(ServiceListener<Boolean> listener, String userId, String clientId, Boolean keepTokenValid, UserSessionRevokeLevel sessionRevokeLevel)
Logouts the current user for Java client. clientId is used in the case of OAuth with CCT/TWA/Browser, the client code needs to make sure the network is available before calling this API, otherwise, the logout process is not able to clear the cookies of this user.
-
logoutUser
@JvmOverloads() final Job logoutUser(ServiceListener<Boolean> listener, String userId, String clientId, Boolean keepTokenValid)
Logouts the current user for Java client. clientId is used in the case of OAuth with CCT/TWA/Browser, the client code needs to make sure the network is available before calling this API, otherwise, the logout process is not able to clear the cookies of this user.
-
logoutUser
@JvmOverloads() final Job logoutUser(ServiceListener<Boolean> listener, String userId, String clientId)
Logouts the current user for Java client. clientId is used in the case of OAuth with CCT/TWA/Browser, the client code needs to make sure the network is available before calling this API, otherwise, the logout process is not able to clear the cookies of this user.
-
logoutUser
@JvmOverloads() final Job logoutUser(ServiceListener<Boolean> listener, String userId)
Logouts the current user for Java client. clientId is used in the case of OAuth with CCT/TWA/Browser, the client code needs to make sure the network is available before calling this API, otherwise, the logout process is not able to clear the cookies of this user.
-
logoutUser
@JvmOverloads() final Job logoutUser(ServiceListener<Boolean> listener)
Logouts the current user for Java client. clientId is used in the case of OAuth with CCT/TWA/Browser, the client code needs to make sure the network is available before calling this API, otherwise, the logout process is not able to clear the cookies of this user.
-
logoutUser
@JvmOverloads() final ServiceResult<Boolean> logoutUser(String userId, String clientId, Boolean keepTokenValid, UserSessionRevokeLevel sessionRevokeLevel)
Signs out the current onboarded user.
- Parameters:
userId- optional parameter.clientId- is used in the case of OAuth authentication with CCT/TWA/Browser, if it's provided, the client code needs to ensure the network is available, otherwise, the logout process is not able to clear the session cookies in the browser.keepTokenValid- is to say whether keep the token valid after the logout call.sessionRevokeLevel- the user session revoke level, UserSessionRevokeLevel.DEVICE means only logout the user from the current device, UserSessionRevokeLevel.USER means the user sessions on all devices will be logged out.
-
logoutUser
@JvmOverloads() final ServiceResult<Boolean> logoutUser(String userId, String clientId, Boolean keepTokenValid)
Signs out the current onboarded user.
- Parameters:
userId- optional parameter.clientId- is used in the case of OAuth authentication with CCT/TWA/Browser, if it's provided, the client code needs to ensure the network is available, otherwise, the logout process is not able to clear the session cookies in the browser.keepTokenValid- is to say whether keep the token valid after the logout call.
-
logoutUser
@JvmOverloads() final ServiceResult<Boolean> logoutUser(String userId, String clientId)
Signs out the current onboarded user.
- Parameters:
userId- optional parameter.clientId- is used in the case of OAuth authentication with CCT/TWA/Browser, if it's provided, the client code needs to ensure the network is available, otherwise, the logout process is not able to clear the session cookies in the browser.
-
logoutUser
@JvmOverloads() final ServiceResult<Boolean> logoutUser(String userId)
Signs out the current onboarded user.
- Parameters:
userId- optional parameter.
-
logoutUser
@JvmOverloads() final ServiceResult<Boolean> logoutUser()
Signs out the current onboarded user.
-
deleteRegistration
@JvmOverloads() final Job deleteRegistration(ServiceListener<Boolean> listener, String userId, String clientId, UserSessionRevokeLevel sessionRevokeLevel)
Deletes the registration of the current user. For Java client. clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
-
deleteRegistration
@JvmOverloads() final Job deleteRegistration(ServiceListener<Boolean> listener, String userId, String clientId)
Deletes the registration of the current user. For Java client. clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
-
deleteRegistration
@JvmOverloads() final Job deleteRegistration(ServiceListener<Boolean> listener, String userId)
Deletes the registration of the current user. For Java client. clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
-
deleteRegistration
@JvmOverloads() final Job deleteRegistration(ServiceListener<Boolean> listener)
Deletes the registration of the current user. For Java client. clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
-
deleteRegistration
@JvmOverloads() final ServiceResult<Boolean> deleteRegistration(String userId, String clientId, UserSessionRevokeLevel sessionRevokeLevel)
Deletes the registration of the current user. 'device id' must be in the request header before calling this.
clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
- Parameters:
userId- The current user id.clientId- The client id of the current OAuth client, if it's not null, the session in the browser will be also removedsessionRevokeLevel- the user session revoke level, UserSessionRevokeLevel.DEVICE means only logout the user from the current device, UserSessionRevokeLevel.USER means the user sessions on all devices will be logged out.
-
deleteRegistration
@JvmOverloads() final ServiceResult<Boolean> deleteRegistration(String userId, String clientId)
Deletes the registration of the current user. 'device id' must be in the request header before calling this.
clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
- Parameters:
userId- The current user id.clientId- The client id of the current OAuth client, if it's not null, the session in the browser will be also removed
-
deleteRegistration
@JvmOverloads() final ServiceResult<Boolean> deleteRegistration(String userId)
Deletes the registration of the current user. 'device id' must be in the request header before calling this.
clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
- Parameters:
userId- The current user id.
-
deleteRegistration
@JvmOverloads() final ServiceResult<Boolean> deleteRegistration()
Deletes the registration of the current user. 'device id' must be in the request header before calling this.
clientId is for OAuth with CCT/TWA/Browser case, the client code needs to make sure the network is available before calling this API.
-
checkUserSession
final Job checkUserSession(String currentUserId, ServiceListener<Boolean> listener)
Checks whether the current user session belongs to the user identified by the given currentUserId, and notify the result out with the given listener
-
checkUserSession
final ServiceResult<Boolean> checkUserSession(String currentUserId)
Checks whether the current user session belongs to the user identified by the given currentUserId.
For offline applications, one user may unlock the app with his/her passcode, then begin to work on the offline database operations, then later when the network is available, sync the changes to the server side. At this time, since for some reasons, this user might not use the correct session, this API is to make sure this case does not happen.
When this API returns 'false', the client needs to remove the session and let the current user re-create the session.
-
-
-
-