public class BoxSession extends BoxObject implements BoxAuthentication.AuthListener
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
mAccountEmail |
protected BoxAuthentication.BoxAuthenticationInfo |
mAuthInfo |
protected java.lang.String |
mClientId |
protected java.lang.String |
mClientRedirectUrl |
protected java.lang.String |
mClientSecret |
protected java.lang.String |
mDeviceId |
protected java.lang.String |
mDeviceName |
protected boolean |
mEnableBoxAppAuthentication |
protected java.lang.Long |
mExpiresAt |
protected BoxMDMData |
mMDMData |
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,
E 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,
E 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()
Deprecated.
|
BoxFutureTask<BoxSession> |
authenticate(android.content.Context context) |
void |
clearCache()
This clears the contents of the directory provided in
getCacheDir(). |
android.content.Context |
getApplicationContext() |
BoxAuthentication.BoxAuthenticationInfo |
getAuthInfo() |
java.lang.String |
getBoxAccountEmail() |
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 |
getDeviceId() |
java.lang.String |
getDeviceName() |
BoxMDMData |
getManagementData() |
java.lang.String |
getRedirectUrl() |
BoxAuthentication.AuthenticationRefreshProvider |
getRefreshProvider() |
java.lang.Long |
getRefreshTokenExpiresAt() |
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)
Called when the session was logged out of
|
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.
|
void |
setApplicationContext(android.content.Context context)
Set the application context if this session loses it for instance when this object is deserialized.
|
protected void |
setAuthInfo(BoxAuthentication.BoxAuthenticationInfo authInfo) |
void |
setBoxAccountEmail(java.lang.String accountName) |
void |
setDeviceId(java.lang.String deviceId) |
void |
setDeviceName(java.lang.String deviceName) |
void |
setEnableBoxAppAuthentication(boolean enabled)
Sets whether or not Box App authentication is enabled or not.
|
void |
setManagementData(BoxMDMData mdmData) |
void |
setRefreshTokenExpiresAt(long expiresAt) |
void |
setSessionAuthListener(BoxAuthentication.AuthListener listener) |
protected void |
setupSession() |
protected void |
setUserId(java.lang.String userId) |
protected void |
startAuthenticationUI() |
void |
suppressAuthErrorUIAfterLogin(boolean suppress)
When set, the content sdk will not show activities/fragments requiring user input,
for e.g.
|
boolean |
suppressesAuthErrorUIAfterLogin() |
protected java.lang.String mClientId
protected java.lang.String mClientSecret
protected java.lang.String mClientRedirectUrl
protected BoxAuthentication.BoxAuthenticationInfo mAuthInfo
protected java.lang.String mDeviceId
protected java.lang.String mDeviceName
protected BoxMDMData mMDMData
protected java.lang.Long mExpiresAt
protected java.lang.String mAccountEmail
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,
E refreshProvider)
E - an instanceof of a refresh provider that is serializable.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,
E refreshProvider)
E - an instanceof of a refresh provider that is serializable.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 void setApplicationContext(android.content.Context context)
context - current contextpublic 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 void setDeviceId(java.lang.String deviceId)
deviceId - the optional unique ID of this device. Used for applications that want to support device-pinning.public java.lang.String getDeviceId()
public void setDeviceName(java.lang.String deviceName)
deviceName - the optional human readable name for this device.public java.lang.String getDeviceName()
public java.lang.String getUserAgent()
public void setManagementData(BoxMDMData mdmData)
mdmData - MDM data object that should be used to authenticate this session if required.public BoxMDMData getManagementData()
public void setRefreshTokenExpiresAt(long expiresAt)
expiresAt - (optional) set the time as a unix time stamp in seconds when the refresh token should expire. Must be less than the default 60 days if used.public java.lang.Long getRefreshTokenExpiresAt()
public void setBoxAccountEmail(java.lang.String accountName)
accountName - (optional) set email account to prefill into authentication ui if available.public java.lang.String getBoxAccountEmail()
@Deprecated public BoxFutureTask<BoxSession> authenticate()
public BoxFutureTask<BoxSession> authenticate(android.content.Context context)
context - The current context.public BoxFutureTask<BoxSession> logout()
public BoxFutureTask<BoxSession> refresh()
public void suppressAuthErrorUIAfterLogin(boolean suppress)
suppress - true if error ui should be supressed, false otherwise.public boolean suppressesAuthErrorUIAfterLogin()
public java.io.File getCacheDir()
public void clearCache()
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.protected void startAuthenticationUI()
public void onLoggedOut(BoxAuthentication.BoxAuthenticationInfo info, java.lang.Exception ex)
BoxAuthentication.AuthListeneronLoggedOut in interface BoxAuthentication.AuthListenerinfo - The last authentication information availableex - the exception that occurred, if anypublic java.lang.String getClientId()
public java.lang.String getClientSecret()
public java.lang.String getRedirectUrl()