public class BoxClient extends BoxBase implements IAuthFlowListener
| Constructor and Description |
|---|
BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxConfig config)
Deprecated.
|
BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxResourceHub hub,
IBoxJSONParser parser,
IBoxConfig config) |
BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxResourceHub hub,
IBoxJSONParser parser,
IBoxConfig config,
BoxConnectionManagerBuilder.BoxConnectionManager connectionManager)
This constructor has some connection parameters.
|
BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxResourceHub hub,
IBoxJSONParser parser,
IBoxRESTClient restClient,
IBoxConfig config) |
| Modifier and Type | Method and Description |
|---|---|
void |
addOAuthRefreshListener(OAuthRefreshListener listener)
Add a listener to listen to OAuth refresh events.
|
void |
authenticate(IAuthData authData)
Get authenticated using a Auth object, this could be a previously stored data.
|
void |
authenticate(IAuthFlowUI authFlowUI,
boolean autoRefreshOAuth,
IAuthFlowListener listener)
Get authenticated.
|
void |
authenticateFromSecureStorage(IAuthSecureStorage storage)
Authenticate from the auth object stored in the secure storage.
|
void |
clearBoxClientAuthListener()
Clear the auth listener so it's not held by BoxClient any more.
|
protected IAuthDataController |
createAuthDataController(java.lang.String clientId,
java.lang.String clientSecret)
Create auth data controller, which maintains auth data and handles auth refresh.
|
protected IBoxRequestAuth |
createAuthorization(IAuthDataController controller)
From auth data controller, generate IBoxRequestAuth, which can be applied to api requests.
|
protected IBoxJSONParser |
createJSONParser(IBoxResourceHub resourceHub)
Create a json parser.
|
protected static IBoxRESTClient |
createMonitoredRestClient(BoxConnectionManagerBuilder.BoxConnectionManager connectionManager) |
protected IBoxResourceHub |
createResourceHub()
Create a resource hub
|
protected static IBoxRESTClient |
createRestClient()
Create a REST client to make api calls.
|
IBoxRequestAuth |
getAuth()
Get the auth object used to make api calls.
|
IAuthData |
getAuthData()
Get available OAuthData.
|
OAuthDataController.OAuthTokenState |
getAuthState()
Check authentication state.
|
protected IAuthFlowListener |
getBoxClientAuthenticationListener() |
IBoxItemsManager |
getBoxItemsManager()
Get the BoxItemsManager, which can be used to make API calls on files/folders endpoints.
|
IBoxCollaborationsManager |
getCollaborationsManager() |
IBoxCollectionsManager |
getCollectionsManager() |
IBoxCommentsManager |
getCommentsManager() |
IBoxConfig |
getConfig()
Get config.
|
IBoxEventsManager |
getEventsManager() |
IBoxFilesManager |
getFilesManager()
Get the BoxFilesManager, which can be used to make API calls on files endpoints.
|
IBoxFoldersManager |
getFoldersManager() |
IBoxGroupsManager |
getGroupsManager()
Get the BoxGroupsManager, which can be used to make API calls on groups endpoints.
|
IBoxJSONParser |
getJSONParser() |
OAuthDataController |
getOAuthDataController()
Get the OAuthDataController that controls OAuth data.
|
IBoxOAuthManager |
getOAuthManager()
Get the OAuthManager, which can be used to make OAuth related api calls.
|
protected BoxOAuthToken |
getOAuthTokenFromMessage(IAuthFlowMessage message) |
IBoxResourceManager |
getPluginManager(java.lang.String pluginManagerKey)
Get a resource manager plugged in based on the key.
|
IBoxResourceHub |
getResourceHub()
Get resource hub.
|
IBoxResourceManager |
getResourceManagerWithSharedLinkAuth(BoxResourceType type,
java.lang.String sharedLink,
java.lang.String password)
A generic way to get a resourceManager with shared link auth.
|
protected IBoxRESTClient |
getRestClient()
Get rest client.
|
IBoxSearchManager |
getSearchManager() |
IBoxItemsManager |
getSharedBoxItemsManager(java.lang.String sharedLink,
java.lang.String password)
Get the BoxItemsManager for items(files/folders) shared to you, this can be used to make API calls on files/folders endpoints.
|
IBoxCommentsManager |
getSharedCommentsManager(java.lang.String sharedLink,
java.lang.String password)
Get the BoxCommentsManager for shared items, which can be used to make API calls on comments endpoints for a shared item.
|
IBoxFilesManager |
getSharedFilesManager(java.lang.String sharedLink,
java.lang.String password)
Get the BoxFilesManager for shared items, which can be used to make API calls on files endpoints for a shared item.
|
IBoxFoldersManager |
getSharedFoldersManager(java.lang.String sharedLink,
java.lang.String password)
Get the BoxFoldersManager for shared items, which can be used to make API calls on folders endpoints for a shared item.
|
IBoxRequestAuth |
getSharedItemAuth(java.lang.String sharedLink,
java.lang.String password)
Get the authorization needed for shared items.
|
IBoxSharedItemsManager |
getSharedItemsManager(java.lang.String sharedLink,
java.lang.String password)
Get Shared Items manager, which can be used to make API calls on shared item endpoints.
|
IBoxTrashManager |
getTrashManager()
Get the BoxItemsManager, which can be used to make API calls on files/folders endpoints for trashed files/folders.
|
IBoxUsersManager |
getUsersManager() |
IBoxWebLinksManager |
getWebLinksManager() |
IAuthData |
guaranteedGetAuthData()
Get OAuthData, in case of OAuthTokenState indicating refresh needed, do refresh.
|
boolean |
isAuthenticated()
Whether this client is authenticated.
|
void |
onAuthFlowEvent(IAuthEvent event,
IAuthFlowMessage message)
On an event.
|
void |
onAuthFlowException(java.lang.Exception e)
On an exception.
|
void |
onAuthFlowMessage(IAuthFlowMessage message)
On a message.
|
IBoxResourceManager |
pluginResourceManager(java.lang.String key,
IPluginResourceManagerBuilder builder)
Plug in a resource manager into sdk client.
|
void |
saveAuth(IAuthSecureStorage storage)
Save auth in a customized secure storage.
|
void |
setAutoRefreshOAuth(boolean autoRefresh)
Makes OAuth auto refresh itself when token expires.
|
protected void |
setBoxClientAuthListener(IAuthFlowListener listener)
set listener listening to the events of the states that this BoxClient gets authenticateds.
|
void |
setConnectionOpen(boolean connectionOpen)
Set whether we want the connection to keep open (and reused) after an api call.
|
void |
setConnectionTimeOut(int timeOut)
Set connection time out.
|
public BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxResourceHub hub,
IBoxJSONParser parser,
IBoxConfig config,
BoxConnectionManagerBuilder.BoxConnectionManager connectionManager)
clientId - client id, you can get it from dev console.clientSecret - client secret, you can get it from dev console.hub - resource hub. use null if you want to use default one.parser - json parser, use null if you want to use default one(Jackson).config - BoxConfig. User BoxConfigBuilder to build. Normally you only need default config: (new BoxConfigBuilder()).build()connectionManager - BoxConnectionManager. Normally you only need default connection manager: (new BoxConnectionManagerBuilder()).build()public BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxResourceHub hub,
IBoxJSONParser parser,
IBoxConfig config)
clientId - client idclientSecret - client secrethub - resource hub, use null for default resource hub.parser - json parser, use null for default parser.config - BoxConfig. User BoxConfigBuilder to build. Normally you only need default config: (new BoxConfigBuilder()).build()public BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxResourceHub hub,
IBoxJSONParser parser,
IBoxRESTClient restClient,
IBoxConfig config)
clientId - client idclientSecret - client secrethub - resource hub, use null for default resource hub.parser - json parser, use null for default parser.restClient - rest clientconfig - BoxConfig. User BoxConfigBuilder to build. Normally you only need default config: (new BoxConfigBuilder()).build()@Deprecated
public BoxClient(java.lang.String clientId,
java.lang.String clientSecret,
IBoxConfig config)
public IBoxResourceManager pluginResourceManager(java.lang.String key, IPluginResourceManagerBuilder builder)
key - key of the resource manager. The key is used to retrieve the plugged in resource manager.builder - builder of the resource manager, the builder interface confines the base building blocks of the plugged in resource manager.public boolean isAuthenticated()
public void setAutoRefreshOAuth(boolean autoRefresh)
autoRefresh - public void setConnectionOpen(boolean connectionOpen)
connectionOpen - true if we want the connection to remain open and reused for another api call.public void setConnectionTimeOut(int timeOut)
timeOut - public OAuthDataController getOAuthDataController()
public void addOAuthRefreshListener(OAuthRefreshListener listener)
listener - public IAuthData getAuthData() throws AuthFatalFailureException
AuthFatalFailureExceptionpublic IAuthData guaranteedGetAuthData() throws AuthFatalFailureException
AuthFatalFailureExceptionpublic void saveAuth(IAuthSecureStorage storage) throws AuthFatalFailureException
storage - AuthFatalFailureExceptionpublic void authenticateFromSecureStorage(IAuthSecureStorage storage)
storage - public IBoxFilesManager getFilesManager()
public IBoxItemsManager getBoxItemsManager()
public IBoxItemsManager getSharedBoxItemsManager(java.lang.String sharedLink, java.lang.String password)
sharedLink - shared linkpassword - use null if no password required.public IBoxTrashManager getTrashManager()
public IBoxOAuthManager getOAuthManager()
public IBoxGroupsManager getGroupsManager()
public IBoxSharedItemsManager getSharedItemsManager(java.lang.String sharedLink, java.lang.String password)
sharedLink - shared linkpassword - passwordpublic IBoxFilesManager getSharedFilesManager(java.lang.String sharedLink, java.lang.String password)
sharedLink - shared link.password - password of the shared link, use null if there is no passwordpublic IBoxFoldersManager getSharedFoldersManager(java.lang.String sharedLink, java.lang.String password)
sharedLink - shared link.password - password of the shared link, use null if there is no passwordpublic IBoxCommentsManager getSharedCommentsManager(java.lang.String sharedLink, java.lang.String password)
sharedLink - shared link.password - password of the shared link, use null if there is no passwordpublic IBoxResourceManager getResourceManagerWithSharedLinkAuth(BoxResourceType type, java.lang.String sharedLink, java.lang.String password)
type - sharedLink - password - public IBoxResourceManager getPluginManager(java.lang.String pluginManagerKey)
public IBoxFoldersManager getFoldersManager()
public IBoxWebLinksManager getWebLinksManager()
public IBoxSearchManager getSearchManager()
public IBoxEventsManager getEventsManager()
public IBoxCollaborationsManager getCollaborationsManager()
public IBoxCollectionsManager getCollectionsManager()
public IBoxCommentsManager getCommentsManager()
public IBoxUsersManager getUsersManager()
public void authenticate(IAuthData authData)
authData - public void authenticate(IAuthFlowUI authFlowUI, boolean autoRefreshOAuth, IAuthFlowListener listener)
authFlowUI - UI for the auth(OAuth) flow.autoRefreshOAuth - whether the OAuth token should be auto refreshed when it expires.listener - listener listening to the events of the states that this BoxClient gets authenticated. In the end of normal OAuth flow, since it's already
done it's duty, this listener is removed so it is not held in memory by BoxClient. In unusual ending of OAuth flow, e.g., your own code forces
finish the OAuth flow, this listener may stay binded to BoxClient, call clearBoxClientAuthListener() if you really need to remove it.protected IAuthFlowListener getBoxClientAuthenticationListener()
protected void setBoxClientAuthListener(IAuthFlowListener listener)
public OAuthDataController.OAuthTokenState getAuthState()
public IBoxConfig getConfig()
protected IBoxResourceHub createResourceHub()
protected IBoxJSONParser createJSONParser(IBoxResourceHub resourceHub)
resourceHub - public IBoxResourceHub getResourceHub()
public IBoxJSONParser getJSONParser()
protected IBoxRESTClient getRestClient()
protected static IBoxRESTClient createRestClient()
protected static IBoxRESTClient createMonitoredRestClient(BoxConnectionManagerBuilder.BoxConnectionManager connectionManager)
public IBoxRequestAuth getSharedItemAuth(java.lang.String sharedLink, java.lang.String password)
sharedLink - shared linkpassword - password(use null if no password at all)protected IAuthDataController createAuthDataController(java.lang.String clientId, java.lang.String clientSecret)
protected IBoxRequestAuth createAuthorization(IAuthDataController controller)
public IBoxRequestAuth getAuth()
public void clearBoxClientAuthListener()
public void onAuthFlowEvent(IAuthEvent event, IAuthFlowMessage message)
IAuthFlowListeneronAuthFlowEvent in interface IAuthFlowListenerevent - statemessage - context message of this eventpublic void onAuthFlowMessage(IAuthFlowMessage message)
IAuthFlowListeneronAuthFlowMessage in interface IAuthFlowListenermessage - messagepublic void onAuthFlowException(java.lang.Exception e)
IAuthFlowListeneronAuthFlowException in interface IAuthFlowListenere - exceptionprotected BoxOAuthToken getOAuthTokenFromMessage(IAuthFlowMessage message)