public class BoxAuthentication
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
BoxAuthentication.AuthenticationRefreshProvider
An interface that should be implemented if using a custom authentication scheme and not the default oauth 2 based token refresh logic.
|
static interface |
BoxAuthentication.AuthListener
Interface of a listener to listen to authentication events.
|
static class |
BoxAuthentication.AuthStorage
Storage class to store auth info.
|
static class |
BoxAuthentication.BoxAuthenticationInfo
Object holding authentication info.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String[] |
MINIMUM_USER_FIELDS |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(BoxAuthentication.AuthListener listener)
Add listener to listen to the authentication process for this BoxSession.
|
java.util.concurrent.FutureTask<BoxAuthentication.BoxAuthenticationInfo> |
create(BoxSession session,
java.lang.String code)
Create Oauth for the first time.
|
BoxAuthentication.BoxAuthenticationInfo |
getAuthInfo(java.lang.String userId,
android.content.Context context)
Get the BoxAuthenticationInfo for a given user.
|
BoxAuthentication.AuthStorage |
getAuthStorage() |
static BoxAuthentication |
getInstance()
Get singleton instance of the BoxAuthentication object.
|
java.lang.String |
getLastAuthenticatedUserId(android.content.Context context)
Get the user id that was last authenticated.
|
java.util.Set<BoxAuthentication.AuthListener> |
getListeners() |
BoxAuthentication.AuthenticationRefreshProvider |
getRefreshProvider()
Get the refresh provider if singleton was created with one, or one was set.
|
java.util.Map<java.lang.String,BoxAuthentication.BoxAuthenticationInfo> |
getStoredAuthInfo(android.content.Context context)
Get a map of all stored auth information.
|
static boolean |
isBoxAuthAppAvailable(android.content.Context context)
A check to see if an official box application supporting third party authentication is available.
|
void |
logout(BoxSession session)
Log out current BoxSession.
|
void |
logoutAllUsers(android.content.Context context)
Log out all users.
|
void |
onAuthenticated(BoxAuthentication.BoxAuthenticationInfo infoOriginal,
android.content.Context context)
Callback method to be called when authentication process finishes.
|
void |
onAuthenticationFailure(BoxAuthentication.BoxAuthenticationInfo infoOriginal,
java.lang.Exception ex)
Callback method to be called if authentication process fails.
|
void |
onLoggedOut(BoxAuthentication.BoxAuthenticationInfo infoOriginal,
java.lang.Exception ex)
Callback method to be called on logout.
|
java.util.concurrent.FutureTask<BoxAuthentication.BoxAuthenticationInfo> |
refresh(BoxSession session)
Refresh the OAuth in the given BoxSession.
|
void |
setAuthStorage(BoxAuthentication.AuthStorage storage)
Set the storage to store auth information.
|
void |
setRefreshProvider(BoxAuthentication.AuthenticationRefreshProvider refreshProvider) |
void |
startAuthenticationUI(BoxSession session)
Launch ui to authenticate.
|
public BoxAuthentication.BoxAuthenticationInfo getAuthInfo(java.lang.String userId, android.content.Context context)
userId - the user id to get auth info for.context - current context used for accessing resource.public java.util.Map<java.lang.String,BoxAuthentication.BoxAuthenticationInfo> getStoredAuthInfo(android.content.Context context)
context - current context.public java.lang.String getLastAuthenticatedUserId(android.content.Context context)
context - current context.public static BoxAuthentication getInstance()
public void setAuthStorage(BoxAuthentication.AuthStorage storage)
storage - set a custom implementation of AuthStorage.public BoxAuthentication.AuthStorage getAuthStorage()
public BoxAuthentication.AuthenticationRefreshProvider getRefreshProvider()
public void setRefreshProvider(BoxAuthentication.AuthenticationRefreshProvider refreshProvider)
refreshProvider - a custom refresh provider in case developer is using app user.public void startAuthenticationUI(BoxSession session)
session - to authenticate using ui.public void onAuthenticated(BoxAuthentication.BoxAuthenticationInfo infoOriginal, android.content.Context context)
infoOriginal - the authentication information that successfully authenticated.context - the current application context (that can be used to launch ui or access resources).public void onAuthenticationFailure(BoxAuthentication.BoxAuthenticationInfo infoOriginal, java.lang.Exception ex)
infoOriginal - the authentication information associated with the failed authentication.ex - the exception if appliable that caused the logout.public void onLoggedOut(BoxAuthentication.BoxAuthenticationInfo infoOriginal, java.lang.Exception ex)
infoOriginal - the authentication information associated with the user that was logged out.ex - the exception if appliable that caused the logout.public java.util.Set<BoxAuthentication.AuthListener> getListeners()
public void logout(BoxSession session)
session - session to logout user frompublic void logoutAllUsers(android.content.Context context)
context - current contextpublic java.util.concurrent.FutureTask<BoxAuthentication.BoxAuthenticationInfo> create(BoxSession session, java.lang.String code)
session - a box session with all the necessary information to authenticate the user for the first time.code - the code returned by web page necessary to authenticate.public java.util.concurrent.FutureTask<BoxAuthentication.BoxAuthenticationInfo> refresh(BoxSession session)
session - a box session with all the necessary information to authenticate the user for the first time.public void addListener(BoxAuthentication.AuthListener listener)
listener - listener for authenticationpublic static boolean isBoxAuthAppAvailable(android.content.Context context)
context - current context