Class APISession
- java.lang.Object
-
- com.blackberry.workspaces.api.sdk.APISession
-
- All Implemented Interfaces:
ISessionCallbacks
public class APISession extends Object implements ISessionCallbacks
Provides entry point to create a session for Java SDK.
-
-
Constructor Summary
Constructors Constructor Description APISession(String serverUrl)
APISession constructorAPISession(String serverUrl, String subDomain)
APISession constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addApiSessionEventListener(IAPISessionEvent listener)
addApiSessionEventListener helper method for IAPISessionEvent classes to register themselvesvoid
caughtSocketException(SocketException socketException)
caughtSocketExceptionboolean
connected()
connectedNetworkConnectionManager
connection()
connectionvoid
endSession()
EndSession Clear the SessionID value and stop the renewal timervoid
establishedConnectionToTheInternet()
establishedConnectionToTheInternetlong
expiryTimeInSeconds()
expiryTimeInSecondsString
getAccessToken()
getAccessTokenString
getActiveEmail()
getActiveEmailAuthentication
getAuthenticationResource()
getAuthenticationResource retrieves an instance of an Authentication resourceNetworkConnectionManager
getConnection()
getConnectionDownloadManager
getDownloadManager()
get a new DownloadManager instance.String
getEmailFromSessionId(String id)
getEmailFromSessionIdFiles
getFilesResource()
getFilesResource retrieves an instance of an Files resourceboolean
getGlobalDownloadPermission()
getGlobalDownloadPermissionIManageWorkspaces
getIManageWorkspacesResource()
getIManageWorkspacesResource retrieves an instance of IManageWorkspaces resourceboolean
getIsUploading()
getIsUploading if there is a file being uploaded right now in a thread safe mannerDate
getLastSignInTime()
getLastSignInTimeNotifications
getNotificationsResource()
getNotificationsResource retrieves an instance of an Notifications resourceOneDriveManagement
getOneDriveManagementResource()
getOneDriveManagementResource retrieves an instance of an OneDriveManagement resourceOrganizations
getOrganizationsResource()
getOrganizationsResource retrieves an instance of an Organizations resourceCalendar[]
getServerTime()
getServerTimeString
getServiceAccountToken(String userEmail, String issuer, int expiresInMinutes, PrivateKey privateKey, String encryptionAlgorithm)
getServiceAccountToken A helper method for formulating an authorization token when using Service Accounts for user authentication.String
getSessionID()
getSessionIDSessions
getSessionsResource()
getSessionsResource retrieves an instance of an Sessions resourceSharePoint
getSharePointResource()
getSharePointResource retrieves an instance of an SharePoint resourceEnums.SignInType
getSignInMethods(String email)
getSignInMethodsString[]
getSupportedFileTypes()
getSupportedFileTypesSystemProperties
getSystemPropertiesResource()
getSystemPropertiesResource retrieves an instance of SystemProperties resourceTransientWorkspaces
getTransientWorkspacesResource()
getTransientWorkspacesResource retrieves an instance of TransientWorkspaces resourceUploadManager
getUploadManager()
get a new UploadManager instance.Users
getUsersResource()
getUsersResource retrieves an instance of a Users resourceWorkspaces
getWorkspacesResource()
getWorkspacesResource retrieves an instance of a Workspaces resourceboolean
isServiceAccount()
isServiceAccountDate
lastUserPlansRefreshTime()
lastUserPlansRefreshTimeItemListJson<WorkspaceInfoJson>
listAvailableVDRs(List<String> roomTypes)
listAvailableVDRs helper method to return list of Workspaces info for specific roomTypes.Enums.LoginResult
loadExistingSession(String sessionId)
loadExistingSession having obtained an authentication token from the other module, it would then passed to the loadExistingSession method.Enums.LoginResult
loadExistingSession(String sessionId, boolean useServerCertificateValidationCallback, boolean loadUserData)
loadExistingSession having obtained an authentication token from the other module, it would then passed to the loadExistingSession method.boolean
logOff()
logOffvoid
lostConnectionToTheInternet()
lostConnectionToTheInternet helper to inform whether connection lost to the Internet.String
refreshToken()
refreshTokenvoid
reportProxyAuthenticationRequired()
reportProxyAuthenticationRequiredlong
SentBytes()
SentBytesEnums.RestartStatus
sessionIdExpired(String oldSid)
sessionIdExpiredvoid
setActiveEmail(String activeEmail)
setActiveEmailvoid
setConnection(NetworkConnectionManager m_Connection)
setConnectionvoid
setGlobalDownloadPermission(boolean GlobalDownloadPermission)
setGlobalDownloadPermissionvoid
setIsUploading(boolean m_IsUploading)
setIsUploadingvoid
setNetworkBandwidthLimit(int download, int upload)
setNetworkBandwidthLimitvoid
setServerTime(Calendar serverTime)
setServerTime sets server time.void
setSessionID(String m_SessionID)
setSessionIDSignInManager
signInManager()
signInManagerEnums.LoginResult
startSessionWithOAuth(String email, String refreshToken, boolean showUiIfRefreshFails)
startSessionWithOAuth is a way to authenticate users using OAuth.Enums.LoginResult
startSessionWithServiceAccount(String userEmail, String issuer, int expiresInMinutes, PrivateKey privateKey, String encryptionAlgorithm)
startSessionWithServiceAccount is a way to authenticate users using ServiceAccount.int
SyncDownloadLimit()
SyncDownloadLimitint
syncUploadLimit()
syncUploadLimitboolean
testConnection()
testConnection helper method to test the connection to the Internet.void
updateBytesSent(long bytes)
updateBytesSentvoid
updateUploadSpeed(float speed)
updateUploadSpeedfloat
uploadSpeed()
uploadSpeedUser
userPlan()
userPlanvoid
waitForRenewal()
waitForRenewal Waits for renewal
-
-
-
Method Detail
-
getConnection
public NetworkConnectionManager getConnection()
getConnection- Returns:
- NetworkConnectionManager
-
setConnection
public void setConnection(NetworkConnectionManager m_Connection)
setConnection- Parameters:
m_Connection
-
-
getSessionID
public String getSessionID()
getSessionID- Returns:
- String m_SessionID
-
setSessionID
public void setSessionID(String m_SessionID)
setSessionID- Parameters:
m_SessionID
-
-
getLastSignInTime
public Date getLastSignInTime()
getLastSignInTime- Returns:
- Date m_LastSignInTime
-
connected
public boolean connected()
connected- Returns:
- true if connected to the server; otherwise, false
-
getActiveEmail
public String getActiveEmail()
getActiveEmail- Returns:
- the email address for the currently signed in user.
-
setActiveEmail
public void setActiveEmail(String activeEmail)
setActiveEmail- Parameters:
activeEmail
-
-
connection
public NetworkConnectionManager connection()
connection- Returns:
- NetworkConnectionManager The connection object
-
signInManager
public SignInManager signInManager()
signInManager- Returns:
- SignInManager the SignInManager object.
-
getGlobalDownloadPermission
public boolean getGlobalDownloadPermission()
getGlobalDownloadPermission- Returns:
- True if global download permission is on; otherwise, false.
-
setGlobalDownloadPermission
public void setGlobalDownloadPermission(boolean GlobalDownloadPermission)
setGlobalDownloadPermission- Parameters:
GlobalDownloadPermission
-
-
getIsUploading
public boolean getIsUploading()
getIsUploading if there is a file being uploaded right now in a thread safe manner- Returns:
- True if there is a file being uploaded; otherwise, false.
-
setIsUploading
public void setIsUploading(boolean m_IsUploading)
setIsUploading- Parameters:
m_IsUploading
-
-
userPlan
public User userPlan()
userPlan- Returns:
- User the user plan information.
-
SentBytes
public long SentBytes()
SentBytes- Returns:
- long the current sent bytes
-
uploadSpeed
public float uploadSpeed()
uploadSpeed- Returns:
- float current upload speed.
-
lastUserPlansRefreshTime
public Date lastUserPlansRefreshTime()
lastUserPlansRefreshTime- Returns:
- Date last user plans refresh time.
-
syncUploadLimit
@Nullable public int syncUploadLimit()
syncUploadLimit- Returns:
- int user plans sync upload limit
-
SyncDownloadLimit
@Nullable public int SyncDownloadLimit()
SyncDownloadLimit- Returns:
- int user plan sync download limit.
-
startSessionWithServiceAccount
public Enums.LoginResult startSessionWithServiceAccount(String userEmail, String issuer, int expiresInMinutes, PrivateKey privateKey, String encryptionAlgorithm)
startSessionWithServiceAccount is a way to authenticate users using ServiceAccount.- Parameters:
userEmail
- the user email associated to login.issuer
- service account id associated with the account (e.g. com.watchdox.system.1f32.2)expiresInMinutes
- minutes to expire.privateKey
- the private key from the certificate.encryptionAlgorithm
- algorithm that was used to create the certificate.(RSA/DSA/SHA256withRSA)- Returns:
- success when Login successful;other wise one of login results
- See Also:
Login successful;other wise one of login results
,Enums.LoginResult
-
startSessionWithOAuth
public Enums.LoginResult startSessionWithOAuth(String email, String refreshToken, boolean showUiIfRefreshFails)
startSessionWithOAuth is a way to authenticate users using OAuth.- Parameters:
email
- the user email associated to login.refreshToken
- refresh token if available or null.showUiIfRefreshFails
- if true the login page pop ups when the refresh fails.- Returns:
- success when Login successful;other wise one of login results
- See Also:
Enums.LoginResult
-
endSession
public void endSession()
EndSession Clear the SessionID value and stop the renewal timer
-
logOff
public boolean logOff()
logOff- Returns:
- true if logoff succeeded; otherwise, false.
-
loadExistingSession
public Enums.LoginResult loadExistingSession(String sessionId)
loadExistingSession having obtained an authentication token from the other module, it would then passed to the loadExistingSession method.- Parameters:
sessionId
- existing authentication token.- Returns:
- success when Login successful;other wise one of login results.
- See Also:
Enums.LoginResult
-
loadExistingSession
public Enums.LoginResult loadExistingSession(String sessionId, boolean useServerCertificateValidationCallback, boolean loadUserData)
loadExistingSession having obtained an authentication token from the other module, it would then passed to the loadExistingSession method.- Parameters:
sessionId
- existing authentication token.useServerCertificateValidationCallback
-loadUserData
- true if to load user data.- Returns:
- success when Login successful;other wise one of login results.
- See Also:
Enums.LoginResult
-
testConnection
public boolean testConnection()
testConnection helper method to test the connection to the Internet.- Returns:
- true if connected to the Internet and to the server
-
listAvailableVDRs
public ItemListJson<WorkspaceInfoJson> listAvailableVDRs(@Nullable List<String> roomTypes)
listAvailableVDRs helper method to return list of Workspaces info for specific roomTypes.- Parameters:
roomTypes
- list of room types- Returns:
- ItemListJson of WorkspaceInfoJson
-
getServerTime
public Calendar[] getServerTime()
getServerTime- Returns:
- Date[] array of Last server time and Last local time
-
getAuthenticationResource
public Authentication getAuthenticationResource()
getAuthenticationResource retrieves an instance of an Authentication resource- Returns:
- Authentication a new instance of an Authentication Resource
-
getFilesResource
public Files getFilesResource()
getFilesResource retrieves an instance of an Files resource- Returns:
- Files a new instance of Files Resource
-
getNotificationsResource
public Notifications getNotificationsResource()
getNotificationsResource retrieves an instance of an Notifications resource- Returns:
- Notifications a new instance of Notifications Resource
-
getOneDriveManagementResource
public OneDriveManagement getOneDriveManagementResource()
getOneDriveManagementResource retrieves an instance of an OneDriveManagement resource- Returns:
- OneDriveManagement a new instance of an OneDriveManagement Resource
-
getOrganizationsResource
public Organizations getOrganizationsResource()
getOrganizationsResource retrieves an instance of an Organizations resource- Returns:
- Organizations a new instance of Organizations Resource
-
getSessionsResource
public Sessions getSessionsResource()
getSessionsResource retrieves an instance of an Sessions resource- Returns:
- Sessions a new instance of Sessions Resource
-
getSharePointResource
public SharePoint getSharePointResource()
getSharePointResource retrieves an instance of an SharePoint resource- Returns:
- SharePoint a new instance of a SharePoint Resource
-
getSignInMethods
public Enums.SignInType getSignInMethods(String email)
getSignInMethods- Parameters:
email
-- Returns:
- SignInType
-
getSystemPropertiesResource
public SystemProperties getSystemPropertiesResource()
getSystemPropertiesResource retrieves an instance of SystemProperties resource- Returns:
- SystemProperties a new instance of SystemProperties Resource
-
getTransientWorkspacesResource
public TransientWorkspaces getTransientWorkspacesResource()
getTransientWorkspacesResource retrieves an instance of TransientWorkspaces resource- Returns:
- TransientWorkspaces a new instance of TransientWorkspaces Resource
-
getIManageWorkspacesResource
public IManageWorkspaces getIManageWorkspacesResource()
getIManageWorkspacesResource retrieves an instance of IManageWorkspaces resource- Returns:
- IManageWorkspaces a new instance of IManageWorkspaces Resource
-
getUsersResource
public Users getUsersResource()
getUsersResource retrieves an instance of a Users resource- Returns:
- Users a new instance of a Users Resource
-
getWorkspacesResource
public Workspaces getWorkspacesResource()
getWorkspacesResource retrieves an instance of a Workspaces resource- Returns:
- Workspaces a new instance of a Workspaces Resource
-
getUploadManager
public UploadManager getUploadManager()
get a new UploadManager instance.- Returns:
- new UploadManager instance related to this session
-
getDownloadManager
public DownloadManager getDownloadManager()
get a new DownloadManager instance.- Returns:
- New DownloadManager instance related to this session
-
setNetworkBandwidthLimit
public void setNetworkBandwidthLimit(@Nullable int download, @Nullable int upload)
setNetworkBandwidthLimit- Parameters:
download
- Sync download user limitupload
- Sync upload user limit
-
getEmailFromSessionId
public String getEmailFromSessionId(String id)
getEmailFromSessionId- Parameters:
id
-- Returns:
- String Email
-
refreshToken
public String refreshToken()
refreshToken- Returns:
- String refreshToken
-
expiryTimeInSeconds
public long expiryTimeInSeconds()
expiryTimeInSeconds- Returns:
- int expiryTimeInSeconds
-
getSupportedFileTypes
public String[] getSupportedFileTypes()
getSupportedFileTypes- Returns:
- String[] array of supported file types
-
isServiceAccount
public boolean isServiceAccount()
isServiceAccount- Returns:
- true if the signIn type is Service Account, false otherwise
-
getServiceAccountToken
public String getServiceAccountToken(String userEmail, String issuer, int expiresInMinutes, PrivateKey privateKey, String encryptionAlgorithm)
getServiceAccountToken A helper method for formulating an authorization token when using Service Accounts for user authentication.- Parameters:
userEmail
- the user email associated to login.issuer
- service account id associated with the account (e.g. com.watchdox.system.1f32.2)expiresInMinutes
- minutes to expire.privateKey
- the private key from the certificate.encryptionAlgorithm
- algorithm that was used to create the certificate.(RSA/DSA/SHA256withRSA)- Returns:
- String authToken The authorization token to be used in making API requests
-
addApiSessionEventListener
public void addApiSessionEventListener(IAPISessionEvent listener)
addApiSessionEventListener helper method for IAPISessionEvent classes to register themselves- Parameters:
listener
-
-
updateUploadSpeed
public void updateUploadSpeed(float speed)
updateUploadSpeed- Specified by:
updateUploadSpeed
in interfaceISessionCallbacks
- Parameters:
speed
-
-
updateBytesSent
public void updateBytesSent(long bytes)
updateBytesSent- Specified by:
updateBytesSent
in interfaceISessionCallbacks
- Parameters:
bytes
-
-
sessionIdExpired
public Enums.RestartStatus sessionIdExpired(String oldSid)
sessionIdExpired- Specified by:
sessionIdExpired
in interfaceISessionCallbacks
- Parameters:
oldSid
- existing session ID.- Returns:
- Success if session restarted successfully;other wise one of RestartStatus results.
-
lostConnectionToTheInternet
public void lostConnectionToTheInternet()
lostConnectionToTheInternet helper to inform whether connection lost to the Internet.- Specified by:
lostConnectionToTheInternet
in interfaceISessionCallbacks
-
reportProxyAuthenticationRequired
public void reportProxyAuthenticationRequired()
Description copied from interface:ISessionCallbacks
reportProxyAuthenticationRequired- Specified by:
reportProxyAuthenticationRequired
in interfaceISessionCallbacks
-
setServerTime
public void setServerTime(Calendar serverTime)
setServerTime sets server time.- Specified by:
setServerTime
in interfaceISessionCallbacks
- Parameters:
serverTime
-
-
waitForRenewal
public void waitForRenewal()
waitForRenewal Waits for renewal- Specified by:
waitForRenewal
in interfaceISessionCallbacks
-
getAccessToken
public String getAccessToken()
getAccessToken- Specified by:
getAccessToken
in interfaceISessionCallbacks
- Returns:
- session ID
-
caughtSocketException
public void caughtSocketException(SocketException socketException)
Description copied from interface:ISessionCallbacks
caughtSocketException- Specified by:
caughtSocketException
in interfaceISessionCallbacks
- Parameters:
socketException
- SocketException
-
establishedConnectionToTheInternet
public void establishedConnectionToTheInternet()
Description copied from interface:ISessionCallbacks
establishedConnectionToTheInternet- Specified by:
establishedConnectionToTheInternet
in interfaceISessionCallbacks
-
-