public class BoxSession extends BoxObject implements BoxAuthentication.AuthListener
| Modifier and Type | Field and Description |
|---|---|
protected BoxAuthentication.BoxAuthenticationInfo |
mAuthInfo |
protected java.lang.String |
mClientId |
protected java.lang.String |
mClientRedirectUrl |
protected java.lang.String |
mClientSecret |
protected boolean |
mEnableBoxAppAuthentication |
protected BoxAuthentication.AuthenticationRefreshProvider |
mRefreshProvider
Optional refresh provider.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BoxSession(BoxSession session)
Construct a new box session object based off of an existing session.
|
|
BoxSession(android.content.Context context)
When using this constructor, if a user has previously been logged in/stored or there is only one user, this user will be authenticated.
|
|
BoxSession(android.content.Context context,
BoxAuthentication.BoxAuthenticationInfo authInfo,
BoxAuthentication.AuthenticationRefreshProvider refreshProvider)
This is an advanced constructor that can be used when implementing an authentication flow that differs from the default oauth 2 flow.
|
|
BoxSession(android.content.Context context,
java.lang.String userId)
When setting the userId to null ui will be shown to ask which user to authenticate as if at least one user is logged in.
|
|
BoxSession(android.content.Context context,
java.lang.String accessToken,
BoxAuthentication.AuthenticationRefreshProvider refreshProvider)
This is a convenience constructor.
|
|
BoxSession(android.content.Context context,
java.lang.String userId,
java.lang.String clientId,
java.lang.String clientSecret,
java.lang.String redirectUrl)
Create a BoxSession using a specific box clientId, secret, and redirectUrl.
|
| Modifier and Type | Method and Description |
|---|---|
BoxFutureTask<BoxSession> |
authenticate() |
android.content.Context |
getApplicationContext() |
BoxAuthentication.BoxAuthenticationInfo |
getAuthInfo() |
java.io.File |
getCacheDir()
This function gives you the cache location associated with this session.
|
java.lang.String |
getClientId()
Returns the associated client id.
|
java.lang.String |
getClientSecret()
Returns the associated client secret.
|
java.lang.String |
getRedirectUrl() |
BoxAuthentication.AuthenticationRefreshProvider |
getRefreshProvider() |
BoxSharedLinkSession |
getSharedLinkSession(java.lang.String sharedLinkUri)
Create a shared link session based off of the current session.
|
BoxUser |
getUser() |
java.lang.String |
getUserAgent() |
java.lang.String |
getUserId() |
boolean |
isEnabledBoxAppAuthentication() |
BoxFutureTask<BoxSession> |
logout()
Logout the currently authenticated user.
|
void |
onAuthCreated(BoxAuthentication.BoxAuthenticationInfo info)
Called when this user has logged in.
|
void |
onAuthFailure(BoxAuthentication.BoxAuthenticationInfo info,
java.lang.Exception ex)
Called when a failure occurs trying to authenticate or refresh.
|
void |
onLoggedOut(BoxAuthentication.BoxAuthenticationInfo info,
java.lang.Exception ex) |
void |
onRefreshed(BoxAuthentication.BoxAuthenticationInfo info)
Called when this session has been refreshed with new authentication info.
|
BoxFutureTask<BoxSession> |
refresh()
Refresh authentication information associated with this session.
|
protected void |
setAuthInfo(BoxAuthentication.BoxAuthenticationInfo authInfo) |
void |
setEnableBoxAppAuthentication(boolean enabled)
Sets whether or not Box App authentication is enabled or not.
|
void |
setSessionAuthListener(BoxAuthentication.AuthListener listener) |
protected void |
setupSession() |
protected void |
setUserId(java.lang.String userId) |
protected java.lang.String mClientId
protected java.lang.String mClientSecret
protected java.lang.String mClientRedirectUrl
protected BoxAuthentication.BoxAuthenticationInfo mAuthInfo
protected BoxAuthentication.AuthenticationRefreshProvider mRefreshProvider
protected boolean mEnableBoxAppAuthentication
public BoxSession(android.content.Context context)
context - current context.public BoxSession(android.content.Context context,
java.lang.String userId)
userId - user id to login as or null to login a new user.context - current context.public BoxSession(android.content.Context context,
java.lang.String userId,
java.lang.String clientId,
java.lang.String clientSecret,
java.lang.String redirectUrl)
context - current context.clientId - the developer's client id to access the box api.clientSecret - the developer's secret used to interpret the response coming from Box.redirectUrl - the developer's redirect url to use for authenticating via Box.userId - user id to login as or null to login as a new user.protected BoxSession(BoxSession session)
session - session to use as the base.public BoxSession(android.content.Context context,
BoxAuthentication.BoxAuthenticationInfo authInfo,
BoxAuthentication.AuthenticationRefreshProvider refreshProvider)
context - current context.authInfo - authentication information that should be used. (Must at the minimum provide an access token).refreshProvider - the refresh provider to use when the access token expires and needs to be refreshed.public BoxSession(android.content.Context context,
java.lang.String accessToken,
BoxAuthentication.AuthenticationRefreshProvider refreshProvider)
context - current contextaccessToken - a valid accessToken.refreshProvider - the refresh provider to use when the access token expires and needs to refreshed.protected void setAuthInfo(BoxAuthentication.BoxAuthenticationInfo authInfo)
public void setEnableBoxAppAuthentication(boolean enabled)
enabled - true if the session should try to authenticate via the Box application, false otherwise.public boolean isEnabledBoxAppAuthentication()
public android.content.Context getApplicationContext()
public void setSessionAuthListener(BoxAuthentication.AuthListener listener)
listener - listener to notify when authentication events (authentication, refreshing, and their exceptions) occur.protected void setupSession()
public BoxUser getUser()
public java.lang.String getUserId()
protected void setUserId(java.lang.String userId)
public BoxAuthentication.BoxAuthenticationInfo getAuthInfo()
public BoxAuthentication.AuthenticationRefreshProvider getRefreshProvider()
public java.lang.String getUserAgent()
public BoxFutureTask<BoxSession> authenticate()
public BoxFutureTask<BoxSession> logout()
public BoxFutureTask<BoxSession> refresh()
public BoxSharedLinkSession getSharedLinkSession(java.lang.String sharedLinkUri)
sharedLinkUri - The url of the shared link.public java.io.File getCacheDir()
public void onRefreshed(BoxAuthentication.BoxAuthenticationInfo info)
onRefreshed in interface BoxAuthentication.AuthListenerinfo - the latest info from a successful refresh.public void onAuthCreated(BoxAuthentication.BoxAuthenticationInfo info)
onAuthCreated in interface BoxAuthentication.AuthListenerinfo - the latest info from going through the login flow.public void onAuthFailure(BoxAuthentication.BoxAuthenticationInfo info, java.lang.Exception ex)
onAuthFailure in interface BoxAuthentication.AuthListenerinfo - The last authentication information available, before the exception.ex - the exception that occurred.public void onLoggedOut(BoxAuthentication.BoxAuthenticationInfo info, java.lang.Exception ex)
onLoggedOut in interface BoxAuthentication.AuthListenerpublic java.lang.String getClientId()
public java.lang.String getClientSecret()
public java.lang.String getRedirectUrl()