Package org.forgerock.android.auth
Class FRUser
- java.lang.Object
-
- org.forgerock.android.auth.FRUser
-
public class FRUser extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFRUser.Browser
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FRUser.Browserbrowser()AccessTokengetAccessToken()Retrieve theAccessToken, if the storedAccessTokenis expired, auto refresh the token it refresh token is available.voidgetAccessToken(FRListener<AccessToken> listener)Retrieve theAccessTokenasynchronously,static FRUsergetCurrentUser()Retrieve the existing FRUser instance,voidgetUserInfo(FRListener<UserInfo> listener)Handles REST requests to the OpenId Connect userinfo endpoint for retrieving information about the user who granted the authorization for the token.static voidlogin(android.content.Context context, NodeListener<FRUser> listener)Trigger the user login process, the login service name is defined under string.xml file with forgerock_auth_servicevoidlogout()Logout the userstatic voidregister(android.content.Context context, NodeListener<FRUser> listener)Trigger the user registration process, the registration service name is defined under string.xml file with forgerock_registration_servicevoidrevokeAccessToken(FRListener<java.lang.Void> listener)Revoke theAccessTokenasynchronously,
-
-
-
Method Detail
-
getCurrentUser
public static FRUser getCurrentUser()
Retrieve the existing FRUser instance,If user session does not exist return null, otherwise return the existing FRUser with the associated user session, this cannot guarantee the existing user session is valid.
- Returns:
- The existing FRUser instance, or null if there is no user session.
-
logout
public void logout()
Logout the user
-
revokeAccessToken
public void revokeAccessToken(FRListener<java.lang.Void> listener)
Revoke theAccessTokenasynchronously,- Parameters:
listener- Listener to listen for token revocation event. throwswhen server returns {@link java.net.HttpURLConnection#HTTP_UNAUTHORIZED} throws {@link org.forgerock.android.auth.exception.ApiException} When server return errors. throws {@link IOException} When there is any network error. throws {@link java.net.MalformedURLException} When failed to parse the URL for API request.
-
getAccessToken
public void getAccessToken(FRListener<AccessToken> listener)
Retrieve theAccessTokenasynchronously,If the stored
AccessTokenis expired, auto refresh the token if refresh token is available.- Parameters:
listener- Listener to listen get Access Token event. throwsAuthenticationRequiredExceptionwhen unable to retrieve a validAccessToken, throwswhen server returns {@link java.net.HttpURLConnection#HTTP_UNAUTHORIZED} throws {@link org.forgerock.android.auth.exception.ApiException} When server return errors. throws {@link org.json.JSONException} when failed to parse server response as JSON String. throws {@link IOException} When there is any network error. throws {@link java.net.MalformedURLException} When failed to parse the URL for API request.
-
getAccessToken
@WorkerThread public AccessToken getAccessToken() throws AuthenticationRequiredException
Retrieve theAccessToken, if the storedAccessTokenis expired, auto refresh the token it refresh token is available.- Returns:
- The
AccessToken - Throws:
AuthenticationRequiredException- when unable to retrieve a validAccessToken, re-login withlogin(Context, NodeListener)
-
getUserInfo
public void getUserInfo(FRListener<UserInfo> listener)
Handles REST requests to the OpenId Connect userinfo endpoint for retrieving information about the user who granted the authorization for the token.- Parameters:
listener- Listener to listen get UserInfo event. throwswhen server returns {@link java.net.HttpURLConnection#HTTP_UNAUTHORIZED} throws {@link org.forgerock.android.auth.exception.ApiException} When server return errors. throws {@link org.json.JSONException} when failed to parse server response as JSON String. throws {@link IOException} When there is any network error. throws {@link java.net.MalformedURLException} When failed to parse the URL for API request.
-
login
public static void login(android.content.Context context, NodeListener<FRUser> listener)Trigger the user login process, the login service name is defined under string.xml file with forgerock_auth_service- Parameters:
context- The Application Contextlistener- Listener to listen login event.FRListener.onSuccess(Object)on success login,FRUseris returned.NodeListener.onCallbackReceived(Node)step to the next node,Nodeis returned. throwsAlreadyAuthenticatedExceptionuser session already exists. throwswhen server returns {@link java.net.HttpURLConnection#HTTP_UNAUTHORIZED} throws {@link org.forgerock.android.auth.exception.ApiException} When server return errors. throws {@link javax.security.auth.callback.UnsupportedCallbackException} When {@link org.forgerock.android.auth.callback.Callback} returned from Server is not supported by the SDK. throws {@link org.forgerock.android.auth.exception.AuthenticationTimeoutException} When Authentication tree timeout throws {@link org.json.JSONException} when failed to parse server response as JSON String. throws {@link IOException} When there is any network error. throws {@link java.net.MalformedURLException} When failed to parse the URL for API request. throws {@link NoSuchMethodException} or {@link SecurityException} When failed to initialize the Callback class.
-
register
public static void register(android.content.Context context, NodeListener<FRUser> listener)Trigger the user registration process, the registration service name is defined under string.xml file with forgerock_registration_service- Parameters:
context- The Application Contextlistener- Listener to listen register event.FRListener.onSuccess(Object)on success login,FRUseris returned.NodeListener.onCallbackReceived(Node)step to the next node,Nodeis returned. throwsAlreadyAuthenticatedExceptionuser session already exists. throwswhen server returns {@link java.net.HttpURLConnection#HTTP_UNAUTHORIZED} throws {@link org.forgerock.android.auth.exception.ApiException} When server return errors. throws {@link javax.security.auth.callback.UnsupportedCallbackException} When {@link org.forgerock.android.auth.callback.Callback} returned from Server is not supported by the SDK. throws {@link org.forgerock.android.auth.exception.AuthenticationTimeoutException} When Authentication tree timeout throws {@link org.json.JSONException} when failed to parse server response as JSON String. throws {@link IOException} When there is any network error. throws {@link java.net.MalformedURLException} When failed to parse the URL for API request. throws {@link NoSuchMethodException} or {@link SecurityException} When failed to initialize the Callback class.
-
browser
public static FRUser.Browser browser()
-
-