├── .github ├── ISSUE_TEMPLATE │ ├── bug.md │ ├── config.yml │ ├── enhancement.md │ └── question.md ├── stale.yml └── workflows │ ├── build-main.yml │ ├── integration-tests.yml │ ├── releases.yml │ ├── semantic-pr.yml │ └── spell-check-lint.yml ├── .gitignore ├── .versionrc ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── VERSIONS.md ├── build.gradle ├── config └── checkstyle │ ├── checkstyle.xml │ └── suppressions.xml ├── doc ├── ai.md ├── android.md ├── authentication.md ├── classifications.md ├── collaboration_allowlists.md ├── collaborations.md ├── collections.md ├── comments.md ├── configuration.md ├── css │ └── javadoc.css ├── devices.md ├── events.md ├── file_requests.md ├── files.md ├── folders.md ├── groups.md ├── legal_holds.md ├── logging.md ├── metadata_template.md ├── overview.md ├── recent_items.md ├── retention_policies.md ├── search.md ├── shared-items.md ├── sign_requests.md ├── sign_templates.md ├── storage_policy.md ├── tasks.md ├── terms_of_service.md ├── trash.md ├── upgrades │ └── 3.x.x to 4.x.x.md ├── upgrading.md ├── users.md ├── watermarking.md ├── webhooks.md ├── weblinks.md └── zip_download.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src ├── example ├── config │ └── config.json └── java │ └── com │ └── box │ └── sdk │ └── example │ ├── AccessAsAppUser.java │ ├── BoxDeveloperEditionAPIConnectionAsEnterpriseUser.java │ ├── CreateAppUser.java │ ├── Main.java │ └── SearchExamplesAsAppUser.java ├── intTest ├── README.md └── java │ └── com │ └── box │ └── sdk │ ├── BoxAIIT.java │ ├── BoxAPIConnectionIT.java │ ├── BoxAPIRequestIT.java │ ├── BoxApiProvider.java │ ├── BoxClassificationTemplateIT.java │ ├── BoxCollaborationAllowlistIT.java │ ├── BoxCollaborationIT.java │ ├── BoxCollectionIT.java │ ├── BoxCommentIT.java │ ├── BoxFileIT.java │ ├── BoxFolderIT.java │ ├── BoxGroupIT.java │ ├── BoxGroupMembershipIT.java │ ├── BoxRecentsIT.java │ ├── BoxRetentionPolicyAssignmentIT.java │ ├── BoxSignRequestIT.java │ ├── BoxTaskIT.java │ ├── BoxTermsOfServiceIT.java │ ├── BoxTransactionalAPIConnectionIT.java │ ├── BoxTrashIT.java │ ├── BoxUserIT.java │ ├── BoxWebHookIT.java │ ├── BoxWebLinkIT.java │ ├── BoxZipIT.java │ ├── CleanupTools.java │ ├── EventLogIT.java │ ├── EventStreamIT.java │ ├── FileUtils.java │ ├── MetadataIT.java │ ├── MetadataTemplateIT.java │ ├── RetentionPolicyUtils.java │ ├── Retry.java │ ├── TestConfig.java │ └── UniqueTestFolder.java ├── main └── java │ └── com │ └── box │ └── sdk │ ├── AbstractBoxMultipartRequest.java │ ├── AvatarUploadResponse.java │ ├── BCPrivateKeyDecryptor.java │ ├── BackoffCounter.java │ ├── Base64.java │ ├── BinaryBodyUtils.java │ ├── BoxAI.java │ ├── BoxAIAgent.java │ ├── BoxAIAgentAsk.java │ ├── BoxAIAgentAskBasicText.java │ ├── BoxAIAgentAskLongText.java │ ├── BoxAIAgentEmbeddings.java │ ├── BoxAIAgentEmbeddingsStrategy.java │ ├── BoxAIAgentExtract.java │ ├── BoxAIAgentExtractStructured.java │ ├── BoxAIAgentLLMEndpointParams.java │ ├── BoxAIAgentLLMEndpointParamsGoogle.java │ ├── BoxAIAgentLLMEndpointParamsOpenAI.java │ ├── BoxAIAgentTextGen.java │ ├── BoxAIAgentTextGenBasicGen.java │ ├── BoxAIDialogueEntry.java │ ├── BoxAIExtractField.java │ ├── BoxAIExtractFieldOption.java │ ├── BoxAIExtractMetadataTemplate.java │ ├── BoxAIExtractStructuredResponse.java │ ├── BoxAIItem.java │ ├── BoxAIResponse.java │ ├── BoxAPIConnection.java │ ├── BoxAPIConnectionListener.java │ ├── BoxAPIException.java │ ├── BoxAPIRequest.java │ ├── BoxAPIResponse.java │ ├── BoxAPIResponseException.java │ ├── BoxCCGAPIConnection.java │ ├── BoxClassification.java │ ├── BoxCollaboration.java │ ├── BoxCollaborationAllowlist.java │ ├── BoxCollaborationAllowlistExemptTarget.java │ ├── BoxCollaborationIterator.java │ ├── BoxCollaborator.java │ ├── BoxCollection.java │ ├── BoxCollectionIterator.java │ ├── BoxComment.java │ ├── BoxConfig.java │ ├── BoxDateFormat.java │ ├── BoxDeserializationException.java │ ├── BoxDeveloperEditionAPIConnection.java │ ├── BoxDevicePin.java │ ├── BoxEnterprise.java │ ├── BoxEvent.java │ ├── BoxFile.java │ ├── BoxFileRequest.java │ ├── BoxFileUploadSession.java │ ├── BoxFileUploadSessionPart.java │ ├── BoxFileUploadSessionPartList.java │ ├── BoxFileVersion.java │ ├── BoxFileVersionLegalHold.java │ ├── BoxFileVersionRetention.java │ ├── BoxFolder.java │ ├── BoxFolderLock.java │ ├── BoxGlobalSettings.java │ ├── BoxGroup.java │ ├── BoxGroupIterator.java │ ├── BoxGroupMembership.java │ ├── BoxGroupMembershipIterator.java │ ├── BoxImageMultipartRequest.java │ ├── BoxInvite.java │ ├── BoxItem.java │ ├── BoxItemIterator.java │ ├── BoxJSONObject.java │ ├── BoxJSONRequest.java │ ├── BoxJSONResponse.java │ ├── BoxLegalHoldAssignment.java │ ├── BoxLegalHoldPolicy.java │ ├── BoxLock.java │ ├── BoxLogger.java │ ├── BoxMetadataCascadePolicy.java │ ├── BoxMetadataFilter.java │ ├── BoxMetadataQueryItem.java │ ├── BoxMultipartRequest.java │ ├── BoxNotificationEmail.java │ ├── BoxRecentItem.java │ ├── BoxRecents.java │ ├── BoxResource.java │ ├── BoxResourceIterable.java │ ├── BoxResourceType.java │ ├── BoxRetentionPolicy.java │ ├── BoxRetentionPolicyAssignment.java │ ├── BoxSearch.java │ ├── BoxSearchParameters.java │ ├── BoxSearchSharedLink.java │ ├── BoxSensitiveDataSanitizer.java │ ├── BoxSharedLink.java │ ├── BoxSignRequest.java │ ├── BoxSignRequestCreateParams.java │ ├── BoxSignRequestFile.java │ ├── BoxSignRequestPrefillTag.java │ ├── BoxSignRequestSignatureColor.java │ ├── BoxSignRequestSigner.java │ ├── BoxSignRequestSignerRole.java │ ├── BoxSignTemplate.java │ ├── BoxSignTemplateAdditionalInfo.java │ ├── BoxSignTemplateAdditionalInfoRequired.java │ ├── BoxSignTemplateCustomBranding.java │ ├── BoxSignTemplateReadySignLink.java │ ├── BoxSignTemplateSigner.java │ ├── BoxStoragePolicy.java │ ├── BoxStoragePolicyAssignment.java │ ├── BoxTask.java │ ├── BoxTaskAssignment.java │ ├── BoxTaskAssignmentIterator.java │ ├── BoxTermsOfService.java │ ├── BoxTermsOfServiceUserStatus.java │ ├── BoxTransactionalAPIConnection.java │ ├── BoxTrash.java │ ├── BoxUploadEmail.java │ ├── BoxUser.java │ ├── BoxUserIterator.java │ ├── BoxWatermark.java │ ├── BoxWebHook.java │ ├── BoxWebHookSignatureVerifier.java │ ├── BoxWebLink.java │ ├── BoxZip.java │ ├── BoxZipConflict.java │ ├── BoxZipConflictItem.java │ ├── BoxZipDownloadStatus.java │ ├── BoxZipInfo.java │ ├── BoxZipItem.java │ ├── CreateUserParams.java │ ├── DateRange.java │ ├── DeveloperEditionEntityType.java │ ├── EmailAlias.java │ ├── EncryptionAlgorithm.java │ ├── EnterpriseEventsRequest.java │ ├── EnterpriseEventsStreamRequest.java │ ├── EventListener.java │ ├── EventLog.java │ ├── EventStream.java │ ├── FileUploadParams.java │ ├── Filter.java │ ├── IAccessTokenCache.java │ ├── IPrivateKeyDecryptor.java │ ├── InMemoryLRUAccessTokenCache.java │ ├── JWTEncryptionPreferences.java │ ├── JsonIterator.java │ ├── LRUCache.java │ ├── LargeFileUpload.java │ ├── LargeFileUploadTask.java │ ├── Metadata.java │ ├── MetadataFieldFilter.java │ ├── MetadataQuery.java │ ├── MetadataTemplate.java │ ├── PagingParameters.java │ ├── PartialCollection.java │ ├── ProgressInputStream.java │ ├── ProgressListener.java │ ├── ProgressOutputStream.java │ ├── QueryStringBuilder.java │ ├── RealtimeServerConnection.java │ ├── Representation.java │ ├── RequestBodyFromCallback.java │ ├── RequestBodyFromStream.java │ ├── RequestInterceptor.java │ ├── RetentionPolicyParams.java │ ├── ScopedToken.java │ ├── SharedLinkAPIConnection.java │ ├── SizeRange.java │ ├── SortParameters.java │ ├── StandardCharsets.java │ ├── Time.java │ ├── URLTemplate.java │ ├── UploadFileCallback.java │ ├── ZstdInterceptor.java │ ├── http │ ├── ContentType.java │ ├── HttpHeaders.java │ └── HttpMethod.java │ ├── internal │ ├── package-info.java │ ├── pool │ │ └── MacPool.java │ └── utils │ │ ├── CollectionUtils.java │ │ ├── JsonUtils.java │ │ └── Parsers.java │ ├── package-info.java │ └── sharedlink │ ├── AbstractSharedLinkRequest.java │ ├── BoxSharedLinkRequest.java │ └── BoxSharedLinkWithoutPermissionsRequest.java └── test ├── Fixtures ├── BoxAI │ ├── ExtractMetadataFreeform200.json │ ├── ExtractMetadataStructured200.json │ ├── GetAIAgentDefaultConfigAsk200.json │ ├── GetAIAgentDefaultConfigExtract200.json │ ├── GetAIAgentDefaultConfigExtractStructured200.json │ ├── GetAIAgentDefaultConfigTextGen200.json │ ├── SendAIRequest200.json │ └── SendAITextGen200.json ├── BoxAPIConnection │ ├── State.json │ └── StateDeprecated.json ├── BoxBatch │ ├── BatchCreateMetadataRequest.json │ └── BatchCreateMetadataResponse.json ├── BoxCollaboration │ ├── CreateCollaboration201.json │ ├── CreateFileCollaboration201.json │ ├── GetCollaborationInfo200.json │ ├── GetCollaborationOnFolder200.json │ ├── GetInviteEmailAttributesOnCollaboration200.json │ ├── GetPendingCollaborationInfo200.json │ └── UpdateCollaboration200.json ├── BoxCollaborationAllowlist │ ├── CreateAllowlistForAUser201.json │ ├── CreateAllowlistForDomain201.json │ ├── GetAllowlistInfoForADomain200.json │ ├── GetAllowlistInfoForAUser200.json │ ├── GetAllowlistInfoForAllDomains200.json │ └── GetAllowlistInfoForAllUsers200.json ├── BoxCollection │ ├── AddItemToCollection200.json │ ├── GetCollectionItems200.json │ └── GetCollections200.json ├── BoxComment │ ├── CreateComment201.json │ ├── GetCommentInfo200.json │ ├── GetCommentsOnFile200.json │ └── UpdateCommentsMessage200.json ├── BoxDevicePin │ ├── GetAllEnterpriseDevicePins200.json │ └── GetDevicePinInfo200.json ├── BoxEvent │ └── GetEnterpriseEvents200.json ├── BoxException │ ├── BoxResponseException400WithErrorAndErrorDescription.json │ ├── BoxResponseException403.json │ ├── BoxResponseException403WithRequestID.json │ ├── BoxResponseException404.json │ ├── BoxResponseException409.json │ └── BoxResponseException500.json ├── BoxFile │ ├── CanUploadFile200.json │ ├── CommitUpload201.json │ ├── CommitUploadWithAttributes201.json │ ├── CopyFile200.json │ ├── CreateClassificationOnFile201.json │ ├── CreateFileWithDescription201.json │ ├── CreateMetadataOnFile201.json │ ├── CreateSharedLinkWithPassword201.json │ ├── CreateUploadSession201.json │ ├── GetAllFileVersions200.json │ ├── GetFileInfo200.json │ ├── GetFileInfoCausesDeserializationException.json │ ├── GetFileRepresentation200.json │ ├── GetFileRepresentation200WithPending.json │ ├── GetFileRepresentations200.json │ ├── GetFileTasksInfoWithFields200.json │ ├── GetFileVersion200.json │ ├── GetMetadataOnFile200.json │ ├── ListUploadedPart200.json │ ├── ListUploadedParts200.json │ ├── LockFile200.json │ ├── MoveFile200.json │ ├── UnlockFile200.json │ ├── UpdateClassificationOnFile200.json │ ├── UpdateFileInfo200.json │ ├── UpdateMetadataOnFile200.json │ ├── UploadNewVersion201.json │ └── UploadPartOne200.json ├── BoxFileRequest │ ├── CopyFileRequest200.json │ ├── GetFileRequest200.json │ └── UpdateFileRequest200.json ├── BoxFolder │ ├── CopyFolder201.json │ ├── CreateClassificationOnFolder201.json │ ├── CreateFolderLock200.json │ ├── CreateMetadataOnFolder201.json │ ├── CreateNewFolder201.json │ ├── CreateSharedLinkForFolder200.json │ ├── GetAllFolderCollaborations200.json │ ├── GetAllFolderCollaborations200WithFields.json │ ├── GetAllFolderItems200.json │ ├── GetAllMetadataOnFolder200.json │ ├── GetAllRootFolderItems200.json │ ├── GetCollaborations200.json │ ├── GetFolderInfo200.json │ ├── GetFolderInfoCausesDeserializationException.json │ ├── GetFolderInfoForCollaborationRestriction200.json │ ├── GetFolderItemsWithSort200.json │ ├── GetFolderLocks200.json │ ├── GetMetadataForFolder200.json │ ├── MoveFolder200.json │ ├── PutTransferFolder200.json │ ├── UpdateClassificationOnFolder200.json │ ├── UpdateFolderInfo200.json │ └── UpdateMetadataOnFolder200.json ├── BoxGroup │ ├── CreateAGroup201.json │ ├── CreateGroupMembership201.json │ ├── GetAGroupsCollaborations1stPage200.json │ ├── GetAGroupsCollaborations2ndPage200.json │ ├── GetAGroupsInfo200.json │ ├── GetAllGroups200.json │ ├── GetGroupMembershipForAUser200.json │ ├── GetGroupsByName200.json │ ├── GetGroupsByNameWithFieldsOption200.json │ ├── GetMembershipForAGroup200.json │ ├── UpdateAGroupsInfo200.json │ └── UpdateGroupMembership200.json ├── BoxItem │ └── GetSharedItemFile200.json ├── BoxLegalHold │ ├── GetFileVersionLegalHolds200.json │ ├── GetFileVersionLegalHoldsID200.json │ ├── GetLegalHoldPolicies200.json │ ├── GetLegalHoldPoliciesID200.json │ ├── GetLegalHoldPolicyAssignmentsID200.json │ ├── GetLegalHoldPolicyAssignmentsPolicyID200.json │ ├── PostLegalHoldPolicies201.json │ ├── PostLegalHoldPolicyAssignments201.json │ ├── PostOngoingLegalHoldPolicies201.json │ ├── PostOngoingWithStartDateLegalHoldPolicies201.json │ └── PutLegalHoldPoliciesID200.json ├── BoxMetadataCascadePolicy │ ├── CreateMetadataCascadePolicies201.json │ ├── GetAllMetadataCascadePolicies200.json │ └── GetMetadataCascadePoliciesID200.json ├── BoxMetadataTemplate │ ├── CreateMetadataTemplate200.json │ ├── GetAMetadataTemplateInfo200.json │ ├── GetAllEnterpriseTemplates200.json │ ├── GetMetadataTemplateOptionInfo200.json │ ├── MetadataQuery1stRequest.json │ ├── MetadataQuery1stResponse200.json │ ├── MetadataQuery2ndRequest.json │ ├── MetadataQuery2ndResponse200.json │ ├── MetadataQueryResponseForFields200.json │ ├── UpdateMetadataTemplate200.json │ └── UpdateMetadataTemplateWithStaticConfig200.json ├── BoxRetentionPolicy │ ├── CreateRetentionPolicy201.json │ ├── CreateRetentionPolicyAssignmentForEnterprise201.json │ ├── CreateRetentionPolicyAssignmentForMetadataTemplate201.json │ ├── CreateRetentionPolicyAssignmentForMetadataTemplateWithoutStartDateField201.json │ ├── GetAllFileVersionRetentions200.json │ ├── GetAllRetentionPolicies200.json │ ├── GetAllRetentionPolicyAssignments200.json │ ├── GetFileRetentionInfo200.json │ ├── GetFileVersionsUnderRetention200.json │ ├── GetFilesUnderRetention200.json │ ├── GetRetentionPolicyAssignment200.json │ ├── GetRetentionPolicyAssignmentInfo200.json │ ├── GetRetentionPolicyInfo200.json │ └── UpdateRetentionPolicyInfo200.json ├── BoxSearch │ └── GetSearchItemsIncludingSharedLinks200.json ├── BoxSharedLink │ ├── CreateEditableSharedLink201.json │ └── CreateSharedLink201.json ├── BoxSignRequest │ ├── CancelSignRequest200.json │ ├── CreateSignRequest200.json │ ├── GetAllSignRequests200.json │ └── GetSignRequest200.json ├── BoxSignTemplate │ ├── GetAllSignTemplates200.json │ └── GetSignTemplateInfo200.json ├── BoxStoragePolicy │ ├── Get_A_Storage_Policy_200.json │ ├── Get_All_Storage_Policies_200.json │ └── Get_Storage_Policy_Assignments_200.json ├── BoxTask │ ├── CreateATaskWithActionComplete200.json │ ├── CreateTaskAssignment201.json │ ├── CreateTaskOnFile201.json │ ├── GetATaskOnFile200.json │ ├── GetAllTaskAssignments200.json │ ├── GetAllTasksOnFile200.json │ ├── GetStatusOnTaskAssignment200.json │ ├── GetTaskAssignment200.json │ ├── GetTaskInfo200.json │ ├── UpdateATaskAssignmentInfo200.json │ └── UpdateATaskInfo200.json ├── BoxTermsOfService │ ├── GetATermsOfServiceInfo200.json │ ├── GetAllTermsOfServices200.json │ └── GetTermsOfServiceForUserStatuses200.json ├── BoxTrash │ ├── GetAllTrashItems200.json │ ├── GetAllTrashItemsUsingmarker200.json │ ├── GetTrashedFileItemInfo200.json │ ├── GetTrashedFolderItemInfo200.json │ ├── RestoreFileItemFromTrash201.json │ └── RestoreFolderItemFromTrash201.json ├── BoxUser │ ├── CreateAppUser201.json │ ├── CreateEmailAlias201.json │ ├── CreateManagedUser201.json │ ├── CreateTrackingCodes200.json │ ├── GetAllEnterpriseUsers200.json │ ├── GetAllEnterpriseUsersMarkerPagination200.json │ ├── GetCurrentUserInfo200.json │ ├── GetCurrentUserInfoWithNoNotifcationEmail200.json │ ├── GetUserEmailAlias200.json │ ├── GetUserInfoCausesDeserializationException.json │ ├── GetUserThreeTrackingCodes200.json │ ├── GetUserTwoTrackingCodes200.json │ ├── UpdateTrackingCodes200.json │ ├── UpdateUserInfo200.json │ └── small_avatar.png ├── BoxWatermark │ ├── CreateWatermarkOnFile200.json │ └── CreateWatermarkOnFolder200.json ├── BoxWebLink │ ├── CreateWebLinkOnFolder201.json │ ├── GetWebLinkOnFolder200.json │ └── UpdateWebLinkOnFolder200.json ├── BoxWebhook │ ├── CreateWebhook201.json │ ├── GetAllWebhooks200.json │ ├── GetWebhook200.json │ └── UpdateWebhookInfo200.json └── BoxZip │ └── CreateZipFile202.json ├── config ├── config.json.template └── config.properties.template ├── java └── com │ └── box │ └── sdk │ ├── AcceptAllHostsVerifier.java │ ├── BoxAITest.java │ ├── BoxAPIConnectionForTests.java │ ├── BoxAPIConnectionTest.java │ ├── BoxAPIRequestTest.java │ ├── BoxAPIResponseExceptionTest.java │ ├── BoxAPIResponseTest.java │ ├── BoxCCGAPIConnectionTest.java │ ├── BoxCollaborationAllowlistExemptTargetTest.java │ ├── BoxCollaborationAllowlistTest.java │ ├── BoxCollaborationTest.java │ ├── BoxCollectionTest.java │ ├── BoxCommentTest.java │ ├── BoxDateFormatTest.java │ ├── BoxDeveloperEditionAPIConnectionTest.java │ ├── BoxDevicePinTest.java │ ├── BoxEventTest.java │ ├── BoxFileRequestTest.java │ ├── BoxFileTest.java │ ├── BoxFileVersionLegalHoldTest.java │ ├── BoxFileVersionRetentionTest.java │ ├── BoxFileVersionTest.java │ ├── BoxFolderTest.java │ ├── BoxGroupMembershipTest.java │ ├── BoxGroupTest.java │ ├── BoxInviteTest.java │ ├── BoxItemTest.java │ ├── BoxJSONRequestTest.java │ ├── BoxLegalHoldPolicyAssignmentTest.java │ ├── BoxLegalHoldPolicyTest.java │ ├── BoxLoggerTest.java │ ├── BoxMetadataCascadePolicyTest.java │ ├── BoxResourceIterableTest.java │ ├── BoxResourceTest.java │ ├── BoxRetentionPolicyAssignmentTest.java │ ├── BoxRetentionPolicyTest.java │ ├── BoxSearchParametersTest.java │ ├── BoxSearchTest.java │ ├── BoxSensitiveDataSanitizerTest.java │ ├── BoxSharedLinkTest.java │ ├── BoxSignRequestTest.java │ ├── BoxSignTemplateTest.java │ ├── BoxStoragePolicyAssignmentTest.java │ ├── BoxStoragePolicyTest.java │ ├── BoxTaskAssignmentTest.java │ ├── BoxTaskTest.java │ ├── BoxTermsOfServiceTest.java │ ├── BoxTermsOfServiceUserStatusTest.java │ ├── BoxTransactionalAPIConnectionTest.java │ ├── BoxTrashTest.java │ ├── BoxURLTemplateTest.java │ ├── BoxUserTest.java │ ├── BoxWatermarkTest.java │ ├── BoxWebHookSignatureVerifierTest.java │ ├── BoxWebHookTest.java │ ├── BoxWebLinkTest.java │ ├── BoxZipTest.java │ ├── EventLogTest.java │ ├── EventStreamTest.java │ ├── IntegrationTestJWT.java │ ├── JSONRequestInterceptor.java │ ├── LRUCacheTest.java │ ├── MetadataQueryTest.java │ ├── MetadataTemplateTest.java │ ├── MetadataTest.java │ ├── PagingParametersTest.java │ ├── QueryStringBuilderTest.java │ ├── RequestBodyFromStreamTest.java │ ├── SortParametersTest.java │ ├── TestUtils.java │ ├── TrustAllTrustManager.java │ └── internal │ └── utils │ └── CollectionUtilsTest.java └── resources └── sample-files ├── empty_file ├── file_to_sign.pdf ├── file_to_sign2.pdf ├── red_100x100.png ├── rep_content.pdf ├── small_file.rtf ├── smalltest.pdf ├── text.pdf └── zip_test.zip /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: SDK documentation 4 | url: https://github.com/box/box-java-sdk/tree/main/doc 5 | about: Before creating an issue, I have checked that the SDK documentation doesn't solve my issue. 6 | - name: API documentation 7 | url: https://developer.box.com/docs 8 | about: Before creating an issue, I have checked that the API documentation doesn't solve my issue. 9 | - name: Box Developer Forums 10 | url: https://community.box.com/t5/Platform-and-Development-Forum/bd-p/DeveloperForum 11 | about: Before creating an issue, I have searched the Box Developer Forums and my issue isn't already reported there. 12 | - name: Issues in this repo 13 | url: https://github.com/box/box-java-sdk/search?type=Issues 14 | about: Before creating an issue, I have searched Issues in this repo and my issue isn't already reported. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement 3 | about: Suggest a new feature or change 4 | title: '' 5 | labels: enhancement 6 | assignees: mwwoda, mhagmajer, antusus, arjankowski, lukaszsocha2, bartlomiejleszczynski 7 | 8 | --- 9 | 10 | ### Is your feature request related to a problem? Please describe. 11 | 12 | 13 | ### Describe the solution you'd like 14 | 15 | 16 | ### Describe alternatives you've considered 17 | 18 | 19 | ### Additional context 20 | 21 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 30 3 | 4 | # Number of days of inactivity before a stale issue is closed 5 | daysUntilClose: 7 6 | 7 | # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable 8 | exemptLabels: 9 | - enhancement 10 | - dontstale 11 | - needs-triage 12 | 13 | # Label to use when marking an issue as stale 14 | staleLabel: stale 15 | 16 | # Comment to post when marking an issue as stale. Set to `false` to disable 17 | markComment: > 18 | This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed. 19 | 20 | # Comment to post when closing a stale issue. Set to `false` to disable 21 | closeComment: > 22 | This issue has been automatically closed due to maximum period of being stale. Thank you for your contribution to Box Java SDK and feel free to open another PR/issue at any time. 23 | -------------------------------------------------------------------------------- /.github/workflows/build-main.yml: -------------------------------------------------------------------------------- 1 | name: build-main 2 | on: 3 | pull_request: 4 | types: [ opened, synchronize ] 5 | push: 6 | branches: 7 | - main 8 | jobs: 9 | build-and-test: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | distribution: [ 'zulu', 'temurin' ] 14 | java: [ '8', '11', '17' ] 15 | name: Java ${{ matrix.java }} (${{ matrix.distribution }}) 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | - name: Setup Java 20 | uses: actions/setup-java@v4 21 | with: 22 | distribution: ${{ matrix.distribution }} 23 | java-version: ${{ matrix.java }} 24 | cache: 'gradle' 25 | - name: Build and test 26 | run: ./gradlew check --stacktrace 27 | - name: Coverage 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | run: ./gradlew jacocoTestReport coverallsJacoco 31 | -------------------------------------------------------------------------------- /.github/workflows/integration-tests.yml: -------------------------------------------------------------------------------- 1 | name: Integration tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | core: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | - name: Setup Java 18 | uses: actions/setup-java@v4 19 | with: 20 | distribution: 'temurin' 21 | java-version: '8' 22 | - name: Run Tests 23 | env: 24 | JAVA_COLLABORATOR_ID: ${{ secrets.JAVA_COLLABORATOR_ID }} 25 | JAVA_COLLABORATOR: ${{ secrets.JAVA_COLLABORATOR }} 26 | JAVA_ENTERPRISE_ID: ${{ secrets.JAVA_ENTERPRISE_ID }} 27 | JAVA_JWT_CONFIG: ${{ secrets.JAVA_JWT_CONFIG }} 28 | JAVA_USER_ID: ${{ secrets.JAVA_USER_ID }} 29 | run: ./gradlew integrationTest 30 | -------------------------------------------------------------------------------- /.github/workflows/releases.yml: -------------------------------------------------------------------------------- 1 | # A GitHub action that notifies the developer 2 | # changelog repository of any new releases. 3 | 4 | name: Notify changelog 5 | 6 | on: 7 | # Only trigger for a full release, 8 | # ignoring pre-releases and drafts 9 | release: 10 | types: 11 | - released 12 | 13 | jobs: 14 | notify: 15 | # This job can run on the latest Ubuntu 16 | # and it should not take more than 3 minutes 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 3 19 | 20 | steps: 21 | # There's really only 1 step, and i 22 | - name: Notify changelog of new release 23 | uses: peter-evans/repository-dispatch@v1 24 | with: 25 | token: ${{ secrets.DISPATCH_ACCESS_TOKEN }} 26 | repository: box/box-developer-changelog 27 | event-type: new-release-note 28 | client-payload: '{"ref": "${{ github.ref }}", "repository": "${{github.repository}}", "labels": "sdks,java", "repo_display_name": "Box Java SDK"}' 29 | -------------------------------------------------------------------------------- /.github/workflows/semantic-pr.yml: -------------------------------------------------------------------------------- 1 | name: Semantic PR 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | - edited 8 | - synchronize 9 | 10 | jobs: 11 | main: 12 | name: Validate semantic PR title 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: amannn/action-semantic-pull-request@v4 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | -------------------------------------------------------------------------------- /.github/workflows/spell-check-lint.yml: -------------------------------------------------------------------------------- 1 | name: spell-check-lint 2 | on: 3 | pull_request_target: 4 | types: [ opened, synchronize, edited ] 5 | branches: 6 | - main 7 | jobs: 8 | spellcheck-request-title: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout current repository 12 | uses: actions/checkout@v4 13 | - name: Checkout spellchecker 14 | uses: actions/checkout@v4 15 | with: 16 | ref: refs/heads/main 17 | repository: box/box-sdk-spellchecker 18 | token: ${{ secrets.DISPATCH_ACCESS_TOKEN }} 19 | path: spellchecker 20 | - name: Execute spellchecker 21 | uses: ./spellchecker 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | build/ 3 | .DS_Store 4 | src/test/config/config.properties 5 | src/test/config/config.json 6 | /target/ 7 | .settings/ 8 | .idea/ 9 | *.iml 10 | # Eclipse Related 11 | .project 12 | .classpath 13 | .checkstyle 14 | bin/ 15 | out/ 16 | *.secret 17 | #Sdkman 18 | .sdkmanrc 19 | #Release process 20 | gradle.properties 21 | release_notes.md -------------------------------------------------------------------------------- /.versionrc: -------------------------------------------------------------------------------- 1 | { 2 | "types": [ 3 | {"type": "feat", "section": "New Features and Enhancements:", "hidden": false}, 4 | {"type": "fix", "section": "Bug Fixes:", "hidden": false}, 5 | {"type": "build", "section": "Dependency Upgrades:", "hidden": false}, 6 | {"type": "chore", "hidden": true}, 7 | {"type": "docs", "hidden": true}, 8 | {"type": "style", "hidden": true}, 9 | {"type": "refactor", "hidden": true}, 10 | {"type": "test", "hidden": true}, 11 | {"type": "ci", "hidden":true} 12 | ] 13 | } -------------------------------------------------------------------------------- /config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 12 | 14 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/recent_items.md: -------------------------------------------------------------------------------- 1 | Recent Items 2 | ============ 3 | 4 | Recent Items returns information about files that have been accessed by a user not long ago. It keeps track of items 5 | that were accessed either in the last 90 days or the last 1000 items accessed (both conditions must be met). 6 | 7 | 8 | 9 | 10 | 11 | - [Get a User's Recent Items](#get-a-users-recent-items) 12 | 13 | 14 | 15 | 16 | Get a User's Recent Items 17 | ------------------------- 18 | 19 | Get a list of all recent items the user has by calling 20 | [`BoxRecents.getRecentItems(BoxAPIConnection api, int limit, String... fields)`][get-recents]. 21 | This returns an ordered iterable of the [`BoxRecentItem`][recent-item] records, 22 | which describe which item the user interacted with, when they interacted with it, 23 | and what type of interaction it was. Any `fields` specified relate to the items 24 | themselves (e.g. the recent files and folders). 25 | 26 | 27 | ```java 28 | // Get the latest 100 items the user has interacted with 29 | Iterable recentItems = BoxRecents.getRecentItems(api, 100); 30 | ``` 31 | 32 | [get-recents]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxRecents.html#getRecentItems-com.box.sdk.BoxAPIConnection-int-java.lang.String...- 33 | [recent-item]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxRecentItem.html 34 | -------------------------------------------------------------------------------- /doc/shared-items.md: -------------------------------------------------------------------------------- 1 | Shared Items 2 | ============ 3 | 4 | Shared Items represent files and folders on Box accessed via a shared link. 5 | 6 | * [Get a Shared Item](#get-a-shared-item) 7 | 8 | Get a Shared Item 9 | ----------------- 10 | 11 | To get the file or folder information for a shared link, you can call 12 | [`BoxItem.getSharedItem(BoxAPIConnection api, String sharedLink)`][get-shared-item] 13 | with the shared link to get information about the item behind it. 14 | 15 | ```java 16 | String sharedLink = "https://app.box.com/s/abcdefghijklmnopqrstuvwxyz123456"; 17 | BoxItem.Info itemInfo = BoxItem.getSharedItem(api, sharedLink); 18 | ``` 19 | 20 | If the shared link is password-protected, call 21 | [`BoxItem.getSharedItem(BoxAPIConnection api, String sharedLink, String password)`][get-shared-item-password] 22 | with the shared link and password. 23 | 24 | 25 | ```java 26 | String sharedLink = "https://app.box.com/s/abcdefghijklmnopqrstuvwxyz123456"; 27 | String password = "foo"; 28 | BoxItem.Info itemInfo = BoxItem.getSharedItem(api, sharedLink, password); 29 | ``` 30 | 31 | [get-shared-item]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxItem.html#getSharedItem-com.box.sdk.BoxAPIConnection-java.lang.String- 32 | [get-shared-item-password]: http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxItem.html#getSharedItem-com.box.sdk.BoxAPIConnection-java.lang.String-java.lang.String- 33 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-java-sdk/5fee0c3e2db5f077fccb0a5b9cfd17e99b9df925/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /src/example/config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "boxAppSettings": { 3 | "clientID": "", 4 | "clientSecret": "", 5 | "appAuth": { 6 | "publicKeyID": "", 7 | "privateKey": "", 8 | "passphrase": "" 9 | } 10 | }, 11 | "enterpriseID": "" 12 | } 13 | -------------------------------------------------------------------------------- /src/example/java/com/box/sdk/example/Main.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk.example; 2 | 3 | import com.box.sdk.BoxAPIConnection; 4 | import com.box.sdk.BoxFolder; 5 | import com.box.sdk.BoxItem; 6 | import com.box.sdk.BoxLogger; 7 | import com.box.sdk.BoxUser; 8 | 9 | public final class Main { 10 | private static final String DEVELOPER_TOKEN = ""; 11 | private static final int MAX_DEPTH = 1; 12 | 13 | private Main() { 14 | } 15 | 16 | public static void main(String[] args) { 17 | // Limit logging messages to prevent polluting the output. 18 | BoxLogger.defaultLogger().setLevelToWarning(); 19 | 20 | BoxAPIConnection api = new BoxAPIConnection(DEVELOPER_TOKEN); 21 | 22 | BoxUser.Info userInfo = BoxUser.getCurrentUser(api).getInfo(); 23 | System.out.format("Welcome, %s <%s>!\n\n", userInfo.getName(), userInfo.getLogin()); 24 | 25 | BoxFolder rootFolder = BoxFolder.getRootFolder(api); 26 | listFolder(rootFolder, 0); 27 | } 28 | 29 | private static void listFolder(BoxFolder folder, int depth) { 30 | for (BoxItem.Info itemInfo : folder) { 31 | StringBuilder indent = new StringBuilder(); 32 | for (int i = 0; i < depth; i++) { 33 | indent.append(" "); 34 | } 35 | 36 | System.out.println(indent + itemInfo.getName()); 37 | if (itemInfo instanceof BoxFolder.Info) { 38 | BoxFolder childFolder = (BoxFolder) itemInfo.getResource(); 39 | if (depth < MAX_DEPTH) { 40 | listFolder(childFolder, depth + 1); 41 | } 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/intTest/java/com/box/sdk/BoxAPIRequestIT.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static com.box.sdk.BoxApiProvider.jwtApiForServiceAccount; 4 | import static org.junit.Assert.fail; 5 | 6 | import org.junit.Test; 7 | 8 | /** 9 | * Integration test for BoxAPIRequest 10 | */ 11 | public class BoxAPIRequestIT { 12 | 13 | @Test 14 | public void loggingWorks() { 15 | BoxLogger.defaultLogger().setLevelToAll(); 16 | try { 17 | BoxAPIConnection api = jwtApiForServiceAccount(); 18 | BoxUser.getCurrentUser(api); 19 | } catch (Exception e) { 20 | e.printStackTrace(); 21 | fail("Exception occured"); 22 | } finally { 23 | BoxLogger.defaultLogger().resetToDefaultLevel(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/intTest/java/com/box/sdk/BoxApiProvider.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static java.lang.String.format; 4 | 5 | import java.util.Base64; 6 | import java.util.Map; 7 | import java.util.Optional; 8 | 9 | final class BoxApiProvider { 10 | 11 | private static final String JWT_CONFIG_ENV_NAME = "JAVA_JWT_CONFIG"; 12 | 13 | private BoxApiProvider() { 14 | // hiding constructor 15 | } 16 | 17 | static BoxDeveloperEditionAPIConnection jwtApiForServiceAccount() { 18 | BoxConfig boxConfig = jwtBoxConfig(); 19 | InMemoryLRUAccessTokenCache tokenCache = new InMemoryLRUAccessTokenCache(10); 20 | return BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig, tokenCache); 21 | } 22 | 23 | static BoxConfig jwtBoxConfig() { 24 | Map environmentProperties = System.getenv(); 25 | String jwtConfigEncoded = getEnvProperty(environmentProperties, JWT_CONFIG_ENV_NAME); 26 | byte[] decodedJwtConfig = Base64.getDecoder().decode(jwtConfigEncoded); 27 | return BoxConfig.readFrom(new String(decodedJwtConfig)); 28 | } 29 | 30 | private static String getEnvProperty(Map environmentProperties, String name) { 31 | return Optional.ofNullable(environmentProperties.get(name)) 32 | .orElseThrow(() -> new RuntimeException(format("Missing '%s' environmental variable", name))); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/intTest/java/com/box/sdk/BoxCollectionIT.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static com.box.sdk.BoxApiProvider.jwtApiForServiceAccount; 4 | import static org.hamcrest.MatcherAssert.assertThat; 5 | import static org.hamcrest.Matchers.equalTo; 6 | import static org.hamcrest.Matchers.is; 7 | 8 | import java.util.ArrayList; 9 | import org.junit.Test; 10 | 11 | public class BoxCollectionIT { 12 | 13 | @Test 14 | public void getAllCollectionsReturnsFavorites() { 15 | BoxAPIConnection api = jwtApiForServiceAccount(); 16 | ArrayList collectionList = new ArrayList<>(); 17 | for (BoxCollection.Info info : BoxCollection.getAllCollections(api)) { 18 | collectionList.add(info); 19 | } 20 | 21 | assertThat(collectionList.size(), is(equalTo(1))); 22 | BoxCollection.Info firstCollection = collectionList.get(0); 23 | assertThat(firstCollection.getName(), is(equalTo("Favorites"))); 24 | assertThat(firstCollection.getCollectionType(), is(equalTo("favorites"))); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/intTest/java/com/box/sdk/BoxTermsOfServiceIT.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNotNull; 5 | 6 | import java.util.List; 7 | import org.junit.Ignore; 8 | import org.junit.Test; 9 | 10 | @Ignore("Terms of servcie are disabled on test account") 11 | public class BoxTermsOfServiceIT { 12 | 13 | @Test 14 | public void getAllTermsOfServicesWithNoParamSucceeds() { 15 | final String tosType = "terms_of_service"; 16 | 17 | BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken()); 18 | 19 | List termsOfServicesInfo = BoxTermsOfService.getAllTermsOfServices(api); 20 | 21 | for (BoxTermsOfService.Info info : termsOfServicesInfo) { 22 | assertNotNull(info); 23 | assertNotNull(info.getEnterprise()); 24 | assertEquals(tosType, info.getType()); 25 | } 26 | } 27 | 28 | @Test 29 | public void getAllTermsOfServicesWithParamSucceeds() { 30 | final String type = "terms_of_service"; 31 | final BoxTermsOfService.TermsOfServiceType tosType = BoxTermsOfService.TermsOfServiceType.MANAGED; 32 | 33 | BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken()); 34 | 35 | List termsOfServicesInfo = BoxTermsOfService.getAllTermsOfServices(api, 36 | BoxTermsOfService.TermsOfServiceType.MANAGED); 37 | 38 | for (BoxTermsOfService.Info info : termsOfServicesInfo) { 39 | assertNotNull(info); 40 | assertNotNull(info.getEnterprise()); 41 | assertEquals(tosType, info.getTosType()); 42 | assertEquals(type, info.getType()); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/intTest/java/com/box/sdk/CleanupTools.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static com.box.sdk.BoxApiProvider.jwtApiForServiceAccount; 4 | 5 | import java.util.Arrays; 6 | import java.util.Optional; 7 | 8 | final class CleanupTools { 9 | private CleanupTools() { 10 | // hiding constructor 11 | } 12 | 13 | static void removeAllowedDomains(String... names) { 14 | BoxCollaborationAllowlist.getAll(jwtApiForServiceAccount()) 15 | .forEach(l -> { 16 | Optional isDomainMatching = Arrays.stream(names) 17 | .filter(n -> l.getDomain().contains(n)) 18 | .findFirst(); 19 | if (isDomainMatching.isPresent()) { 20 | l.getResource().delete(); 21 | } 22 | }); 23 | } 24 | 25 | static void removeAllGroups() { 26 | for (BoxGroup.Info group : BoxGroup.getAllGroups(jwtApiForServiceAccount())) { 27 | group.getResource().delete(); 28 | } 29 | } 30 | 31 | static void deleteFile(BoxFile file) { 32 | Optional.ofNullable(file).ifPresent(BoxFile::delete); 33 | } 34 | 35 | static void deleteFolder(BoxFolder folder) { 36 | Optional.ofNullable(folder).ifPresent(f -> f.delete(true)); 37 | } 38 | 39 | static void deleteGroup(BoxGroup group) { 40 | if (group != null) { 41 | group.delete(); 42 | } 43 | } 44 | 45 | static void deleteUser(BoxUser user) { 46 | if (user != null) { 47 | user.delete(false, false); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/intTest/java/com/box/sdk/Retry.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static java.lang.String.format; 4 | 5 | /** 6 | * Utility class to retry API actions 7 | */ 8 | public final class Retry { 9 | private static final BoxLogger LOGGER = BoxLogger.defaultLogger(); 10 | 11 | private Retry() { 12 | // hide constructor in utility class 13 | } 14 | 15 | /** 16 | * Retries execution 17 | * @param toExecute Runnable to retry 18 | * @param retries how many times we want to retry 19 | * @param sleep how much miliseconds to sleep between retries 20 | * @throws InterruptedException when sleep was interuppted 21 | */ 22 | public static void retry(Runnable toExecute, int retries, int sleep) throws InterruptedException { 23 | int retriesExecuted = 0; 24 | while (retriesExecuted < retries) { 25 | try { 26 | toExecute.run(); 27 | break; 28 | } catch (Exception e) { 29 | retriesExecuted++; 30 | if (retriesExecuted >= retries) { 31 | throw e; 32 | } 33 | LOGGER.debug( 34 | format("Retrying [%d/%d] becasue of Exception '%s'", retriesExecuted, retries, e.getMessage()) 35 | ); 36 | Thread.sleep(sleep); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/AvatarUploadResponse.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * Upload avatar response 5 | */ 6 | public class AvatarUploadResponse { 7 | private final String small; 8 | private final String large; 9 | private final String preview; 10 | 11 | AvatarUploadResponse(String small, String large, String preview) { 12 | this.small = small; 13 | this.large = large; 14 | this.preview = preview; 15 | } 16 | 17 | /** 18 | * URL with the small representation of Avatar. 19 | * 20 | * @return URL with the small representation of Avatar 21 | */ 22 | public String getSmall() { 23 | return small; 24 | } 25 | 26 | /** 27 | * URL with the large representation of Avatar. 28 | * 29 | * @return URL with the large representation of Avatar 30 | */ 31 | public String getLarge() { 32 | return large; 33 | } 34 | 35 | /** 36 | * URL with the preview representation of Avatar. 37 | * 38 | * @return URL with the preview representation of Avatar 39 | */ 40 | public String getPreview() { 41 | return preview; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxAIExtractFieldOption.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | 4 | import com.box.sdk.internal.utils.JsonUtils; 5 | import com.eclipsesource.json.JsonObject; 6 | 7 | public class BoxAIExtractFieldOption extends BoxJSONObject { 8 | /** 9 | * A unique identifier for the option. 10 | */ 11 | private final String key; 12 | 13 | /** 14 | * Constructs a BoxAIExtractFieldOption object with a given key. 15 | * 16 | * @param key the key of the field option. 17 | */ 18 | public BoxAIExtractFieldOption(String key) { 19 | this.key = key; 20 | } 21 | 22 | public JsonObject getJSONObject() { 23 | JsonObject jsonObject = new JsonObject(); 24 | JsonUtils.addIfNotNull(jsonObject, "key", this.key); 25 | return jsonObject; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxAPIConnectionListener.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * Listener to listen to Box API connection events. 5 | */ 6 | public interface BoxAPIConnectionListener { 7 | 8 | /** 9 | * Called when the Box API connection refreshes its tokens. 10 | * 11 | *

The provided connection is guaranteed to not be auto-refreshed or modified by another listener until this 12 | * method returns.

13 | * 14 | * @param api the API connection that was refreshed. 15 | */ 16 | void onRefresh(BoxAPIConnection api); 17 | 18 | /** 19 | * Called when an error occurs while attempting to refresh the Box API connection's tokens. 20 | * 21 | *

The provided connection is guaranteed to not be auto-refreshed or modified by another listener until this 22 | * method returns.

23 | * 24 | * @param api the API connection that encountered an error. 25 | * @param error the error that occurred. 26 | */ 27 | void onError(BoxAPIConnection api, BoxAPIException error); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxCollaborationIterator.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static com.box.sdk.PagingParameters.offset; 4 | 5 | import com.eclipsesource.json.JsonObject; 6 | import java.net.URL; 7 | import java.util.Iterator; 8 | 9 | class BoxCollaborationIterator implements Iterator { 10 | private static final long LIMIT = 100; 11 | private final BoxAPIConnection api; 12 | private final JsonIterator jsonIterator; 13 | 14 | BoxCollaborationIterator(BoxAPIConnection api, URL url) { 15 | this.api = api; 16 | this.jsonIterator = new JsonIterator(api, url, offset(0, LIMIT)); 17 | } 18 | 19 | @Override 20 | public boolean hasNext() { 21 | return this.jsonIterator.hasNext(); 22 | } 23 | 24 | @Override 25 | public BoxCollaboration.Info next() { 26 | JsonObject nextJSONObject = this.jsonIterator.next(); 27 | String id = nextJSONObject.get("id").asString(); 28 | 29 | BoxCollaboration collaboration = new BoxCollaboration(this.api, id); 30 | return collaboration.new Info(nextJSONObject); 31 | } 32 | 33 | public void remove() { 34 | throw new UnsupportedOperationException(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxCollectionIterator.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static com.box.sdk.PagingParameters.offset; 4 | 5 | import com.eclipsesource.json.JsonObject; 6 | import java.net.URL; 7 | import java.util.Iterator; 8 | 9 | class BoxCollectionIterator implements Iterator { 10 | private static final long LIMIT = 100; 11 | private final BoxAPIConnection api; 12 | private final JsonIterator jsonIterator; 13 | 14 | BoxCollectionIterator(BoxAPIConnection api, URL url) { 15 | this.api = api; 16 | this.jsonIterator = new JsonIterator(api, url, offset(0, LIMIT)); 17 | } 18 | 19 | @Override 20 | public boolean hasNext() { 21 | return this.jsonIterator.hasNext(); 22 | } 23 | 24 | @Override 25 | public BoxCollection.Info next() { 26 | JsonObject nextJSONObject = this.jsonIterator.next(); 27 | String id = nextJSONObject.get("id").asString(); 28 | 29 | BoxCollection collection = new BoxCollection(this.api, id); 30 | return collection.new Info(nextJSONObject); 31 | } 32 | 33 | public void remove() { 34 | throw new UnsupportedOperationException(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxEnterprise.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | import com.eclipsesource.json.JsonValue; 5 | 6 | /** 7 | * Represents an enterprise organization on Box. 8 | */ 9 | public class BoxEnterprise extends BoxJSONObject { 10 | private String id; 11 | private String name; 12 | 13 | /** 14 | * Constructs a BoxEnterprise with default settings. 15 | */ 16 | public BoxEnterprise() { 17 | } 18 | 19 | /** 20 | * Constructs a BoxEnterprise from a JSON string. 21 | * 22 | * @param json the JSON encoded enterprise. 23 | */ 24 | public BoxEnterprise(String json) { 25 | super(json); 26 | } 27 | 28 | BoxEnterprise(JsonObject jsonObject) { 29 | super(jsonObject); 30 | } 31 | 32 | /** 33 | * Gets the ID of this enterprise. 34 | * 35 | * @return the ID of this enterprise. 36 | */ 37 | public String getID() { 38 | return this.id; 39 | } 40 | 41 | /** 42 | * Gets the name of this enterprise. 43 | * 44 | * @return the name of this enterprise. 45 | */ 46 | public String getName() { 47 | return this.name; 48 | } 49 | 50 | @Override 51 | void parseJSONMember(JsonObject.Member member) { 52 | JsonValue value = member.getValue(); 53 | String memberName = member.getName(); 54 | if (memberName.equals("id")) { 55 | this.id = value.asString(); 56 | } else if (memberName.equals("name")) { 57 | this.name = value.asString(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxGroupIterator.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static com.box.sdk.PagingParameters.offset; 4 | 5 | import com.eclipsesource.json.JsonObject; 6 | import java.net.URL; 7 | import java.util.Iterator; 8 | 9 | class BoxGroupIterator implements Iterator { 10 | private static final long LIMIT = 1000; 11 | 12 | private final BoxAPIConnection api; 13 | private final JsonIterator jsonIterator; 14 | 15 | BoxGroupIterator(BoxAPIConnection api, URL url) { 16 | this.api = api; 17 | this.jsonIterator = new JsonIterator(api, url, offset(0, LIMIT)); 18 | } 19 | 20 | public boolean hasNext() { 21 | return this.jsonIterator.hasNext(); 22 | } 23 | 24 | public BoxGroup.Info next() { 25 | JsonObject nextJSONObject = this.jsonIterator.next(); 26 | String id = nextJSONObject.get("id").asString(); 27 | 28 | BoxGroup group = new BoxGroup(this.api, id); 29 | return group.new Info(nextJSONObject); 30 | } 31 | 32 | public void remove() { 33 | throw new UnsupportedOperationException(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxMultipartRequest.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.net.URL; 4 | import okhttp3.MediaType; 5 | 6 | /** 7 | *

Used to make HTTP multipart requests to the Box API.

8 | * 9 | *

This class partially implements the HTTP multipart standard in order to upload files to Box. The body of this 10 | * request type cannot be set directly. Instead, it can be modified by adding multipart fields and setting file 11 | * contents. The body of multipart requests will not be logged since they are likely to contain binary data.

12 | */ 13 | public class BoxMultipartRequest extends AbstractBoxMultipartRequest { 14 | 15 | /** 16 | * Constructs an authenticated BoxMultipartRequest using a provided BoxAPIConnection. 17 | * 18 | * @param api an API connection for authenticating the request. 19 | * @param url the URL of the request. 20 | */ 21 | public BoxMultipartRequest(BoxAPIConnection api, URL url) { 22 | super(api, url); 23 | } 24 | 25 | @Override 26 | protected String getPartName() { 27 | return "file"; 28 | } 29 | 30 | @Override 31 | protected MediaType getPartContentType(String filename) { 32 | return MediaType.parse("application/octet-stream"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxResourceType.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Type of resource (e.g.: folder, file, comment, etc...). 12 | * 13 | * @since 2.2.1 14 | */ 15 | @Documented 16 | @Inherited 17 | @Target(ElementType.TYPE) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | public @interface BoxResourceType { 20 | 21 | // Bug in checkstyle: Unused Javadoc tag. 22 | // TODO checkstyle: need re-evaluation after checkstyle update 23 | //CHECKSTYLE:OFF 24 | 25 | /** 26 | * @return Type of resource (e.g.: folder, file, comment, etc...). 27 | */ 28 | //CHECKSTYLE:ON 29 | String value(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxSignRequestSignatureColor.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * Specific, forced color for a signature. 5 | */ 6 | public enum BoxSignRequestSignatureColor { 7 | 8 | /** 9 | * Blue signature color. 10 | */ 11 | Blue("blue"), 12 | 13 | /** 14 | * Black signature color. 15 | */ 16 | Black("black"), 17 | 18 | /** 19 | * Red signature color. 20 | */ 21 | Red("red"); 22 | 23 | private final String jsonValue; 24 | 25 | BoxSignRequestSignatureColor(String jsonValue) { 26 | this.jsonValue = jsonValue; 27 | } 28 | 29 | static BoxSignRequestSignatureColor fromJSONString(String jsonValue) { 30 | if ("blue".equals(jsonValue)) { 31 | return Blue; 32 | } else if ("black".equals(jsonValue)) { 33 | return Black; 34 | } else if ("red".equals(jsonValue)) { 35 | return Red; 36 | } 37 | throw new IllegalArgumentException("The provided JSON value isn't a valid " 38 | + "BoxSignRequestSignatureColor."); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxSignRequestSignerRole.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * Defines the role of the signer in the sign request. Signers will need to sign the document, 5 | * Approvers may just approve the document. 6 | * Finally, FinalCopyReader will only receive the finished sign request with a sign log. 7 | */ 8 | public enum BoxSignRequestSignerRole { 9 | 10 | /** 11 | * Signer role. Needs to sign the document. 12 | */ 13 | Signer("signer"), 14 | 15 | /** 16 | * Approver role. Approves the document. 17 | */ 18 | Approver("approver"), 19 | 20 | /** 21 | * Final copy reader role. Receives finished sign request with sign log. 22 | */ 23 | FinalCopyReader("final_copy_reader"); 24 | 25 | private final String jsonValue; 26 | 27 | BoxSignRequestSignerRole(String jsonValue) { 28 | this.jsonValue = jsonValue; 29 | } 30 | 31 | static BoxSignRequestSignerRole fromJSONString(String jsonValue) { 32 | if ("signer".equals(jsonValue)) { 33 | return Signer; 34 | } else if ("approver".equals(jsonValue)) { 35 | return Approver; 36 | } else if ("final_copy_reader".equals(jsonValue)) { 37 | return FinalCopyReader; 38 | } 39 | throw new IllegalArgumentException("The provided JSON value isn't a valid BoxSignRequestSignerRole."); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxSignTemplateAdditionalInfo.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.util.List; 4 | 5 | 6 | /** 7 | * Box Sign Template additional information on which fields are required 8 | * and which fields are not editable. 9 | */ 10 | public class BoxSignTemplateAdditionalInfo { 11 | private final List nonEditable; 12 | private final BoxSignTemplateAdditionalInfoRequired required; 13 | 14 | public BoxSignTemplateAdditionalInfo(List nonEditable, 15 | BoxSignTemplateAdditionalInfoRequired required) { 16 | this.nonEditable = nonEditable; 17 | this.required = required; 18 | } 19 | 20 | /** 21 | * Get non-editable fields. 22 | * 23 | * @return list of non-editable fields.\ 24 | */ 25 | public List getNonEditable() { 26 | return this.nonEditable; 27 | } 28 | 29 | /** 30 | * Gets the required fields. 31 | * 32 | * @return the required fields. 33 | */ 34 | public BoxSignTemplateAdditionalInfoRequired getRequired() { 35 | return this.required; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxSignTemplateAdditionalInfoRequired.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.util.List; 4 | 5 | 6 | /** 7 | * Box Sign Template additional information on which fields are required. 8 | */ 9 | public class BoxSignTemplateAdditionalInfoRequired { 10 | private final List> signers; 11 | 12 | /** 13 | * Constructs a BoxSignTemplateAdditionalInfoRequired object with the provided list of signers. 14 | */ 15 | public BoxSignTemplateAdditionalInfoRequired(List> signers) { 16 | this.signers = signers; 17 | } 18 | 19 | /** 20 | * Gets the required signer fields. 21 | * 22 | * @return the required signer fields. 23 | */ 24 | public List> getSigners() { 25 | return this.signers; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxUserIterator.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import static com.box.sdk.PagingParameters.offset; 4 | 5 | import com.eclipsesource.json.JsonObject; 6 | import java.net.URL; 7 | import java.util.Iterator; 8 | 9 | class BoxUserIterator implements Iterator { 10 | private static final long LIMIT = 1000; 11 | 12 | private final BoxAPIConnection api; 13 | private final JsonIterator jsonIterator; 14 | 15 | BoxUserIterator(BoxAPIConnection api, URL url) { 16 | this.api = api; 17 | this.jsonIterator = new JsonIterator(api, url, offset(0, LIMIT)); 18 | } 19 | 20 | public boolean hasNext() { 21 | return this.jsonIterator.hasNext(); 22 | } 23 | 24 | public BoxUser.Info next() { 25 | JsonObject nextJSONObject = this.jsonIterator.next(); 26 | String id = nextJSONObject.get("id").asString(); 27 | 28 | BoxUser user = new BoxUser(this.api, id); 29 | return user.new Info(nextJSONObject); 30 | } 31 | 32 | public void remove() { 33 | throw new UnsupportedOperationException(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxZipConflict.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import com.eclipsesource.json.JsonArray; 4 | import com.eclipsesource.json.JsonObject; 5 | import com.eclipsesource.json.JsonValue; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Represents a conflict that occurs between items that have the same name. 11 | */ 12 | public class BoxZipConflict extends BoxJSONObject { 13 | private List items; 14 | 15 | /** 16 | * Constructs a BoxZipDownloadStatus with default settings. 17 | */ 18 | public BoxZipConflict() { 19 | } 20 | 21 | /** 22 | * Constructs a BoxZipDownloadStatus from a JSON string. 23 | * 24 | * @param json the JSON encoded enterprise. 25 | */ 26 | public BoxZipConflict(String json) { 27 | super(json); 28 | } 29 | 30 | BoxZipConflict(JsonObject jsonObject) { 31 | super(jsonObject); 32 | } 33 | 34 | /** 35 | * Gets the items that conflict because they have the same name. 36 | * 37 | * @return the items that conflict because they have the same name. 38 | */ 39 | public List getItems() { 40 | return this.items; 41 | } 42 | 43 | @Override 44 | void parseJSONMember(JsonObject.Member member) { 45 | JsonArray value = member.getValue().asArray(); 46 | List conflictItems = new ArrayList(value.size()); 47 | for (JsonValue item : value) { 48 | conflictItems.add(new BoxZipConflictItem(item.asObject())); 49 | } 50 | this.items = conflictItems; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/BoxZipItem.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | /** 6 | * Represents a Box item to be included when creating a zip file. 7 | */ 8 | public class BoxZipItem { 9 | private String type; 10 | private String id; 11 | 12 | /** 13 | * Constructs a base BoxZipItem object. 14 | * 15 | * @param type item type, "file" or "folder". 16 | * @param id id of the the item. 17 | */ 18 | public BoxZipItem(String type, String id) { 19 | super(); 20 | this.type = type; 21 | this.id = id; 22 | } 23 | 24 | /** 25 | * Gets the item type. 26 | * 27 | * @return the type of the zip item. 28 | */ 29 | public String getType() { 30 | return this.type; 31 | } 32 | 33 | /** 34 | * Gets the item ID. 35 | * 36 | * @return the ID fo the zip item. 37 | */ 38 | public String getID() { 39 | return this.id; 40 | } 41 | 42 | /** 43 | * Gets a JSON object reprsenting this class. 44 | * 45 | * @return the JSON object reprsenting this class. 46 | */ 47 | public JsonObject getJSONObject() { 48 | JsonObject jsonObj = new JsonObject() 49 | .add("type", this.type) 50 | .add("id", this.id); 51 | return jsonObj; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/DeveloperEditionEntityType.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * Enum to represent the JWT entity type for BoxDeveloperEditionAPIConnection. 5 | */ 6 | public enum DeveloperEditionEntityType { 7 | 8 | /** 9 | * Represents the entity type enterprise. 10 | */ 11 | ENTERPRISE("enterprise"), 12 | 13 | /** 14 | * Represents the entity type user. 15 | */ 16 | USER("user"); 17 | 18 | private final String value; 19 | 20 | /** 21 | * @param value 22 | */ 23 | DeveloperEditionEntityType(String value) { 24 | this.value = value; 25 | } 26 | 27 | /** 28 | * To get the string value for the enum type. 29 | * 30 | * @return The string value for the enum type 31 | */ 32 | @Override 33 | public String toString() { 34 | return this.value; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/EncryptionAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * Enum to identify algorithm for JWT. 5 | */ 6 | public enum EncryptionAlgorithm { 7 | 8 | /** 9 | * RSA with SHA 256. 10 | */ 11 | RSA_SHA_256, 12 | 13 | /** 14 | * RSA with SHA 384. 15 | */ 16 | RSA_SHA_384, 17 | 18 | /** 19 | * RSA with SHA 512. 20 | */ 21 | RSA_SHA_512; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/EventListener.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * The listener interface for receiving events from an {@link EventStream}. 5 | */ 6 | public interface EventListener { 7 | /** 8 | * Invoked when an event is received from the API. 9 | * 10 | * @param event the received event. 11 | */ 12 | void onEvent(BoxEvent event); 13 | 14 | /** 15 | * Invoked when an updated stream position is received from the API. 16 | * 17 | * @param position of the stream. 18 | */ 19 | void onNextPosition(long position); 20 | 21 | /** 22 | * Invoked when an error occurs while waiting for events to be received. 23 | * 24 | *

When an EventStream encounters an exception, it will invoke this method on each of its listeners until one 25 | * of them returns true, indicating that the exception was handled.

26 | * 27 | * @param e the exception that was thrown while waiting for events. 28 | * @return true if the exception was handled; otherwise false. 29 | */ 30 | boolean onException(Throwable e); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/Filter.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | interface Filter { 4 | boolean shouldInclude(T object); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/IAccessTokenCache.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * Implement this interface to provide a custom access token cache implementation for your environment. 5 | * 6 | *

For production applications it is recommended to use a distributed cache like Memcached or Redis, and to 7 | * implement this interface to store and retrieve access tokens appropriately for your environment.

8 | */ 9 | public interface IAccessTokenCache { 10 | 11 | /** 12 | * Get the access token information from the cache. 13 | * 14 | * @param key key to look for. 15 | * @return access token information. 16 | */ 17 | String get(String key); 18 | 19 | /** 20 | * Store the access token information in the cache. 21 | * 22 | * @param key key to use. 23 | * @param value access token information to store. 24 | */ 25 | void put(String key, String value); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/IPrivateKeyDecryptor.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.security.PrivateKey; 4 | 5 | /** 6 | * Implement this interface to provide a custom private key decryptor. 7 | * If you require the decryption operation to be FIPS compliant, 8 | * ensure that your implementation exclusively utilizes FIPS certified libraries. 9 | */ 10 | public interface IPrivateKeyDecryptor { 11 | 12 | /** 13 | * Decrypts private key with provided passphrase using Bouncy Castle library 14 | * 15 | * @param encryptedPrivateKey Encoded private key string. 16 | * @param passphrase Private key passphrase. 17 | * @return java.security.PrivateKey instance representing decrypted private key. 18 | */ 19 | PrivateKey decryptPrivateKey(String encryptedPrivateKey, String passphrase); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/InMemoryLRUAccessTokenCache.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * Use this class to create an in-memory LRU (least recently used) access token cache to be 8 | * passed to BoxDeveloperEditionAPIConnection. 9 | */ 10 | public class InMemoryLRUAccessTokenCache implements IAccessTokenCache { 11 | 12 | private final Map cache; 13 | 14 | /** 15 | * Creates an in-memory LRU access token cache. 16 | * 17 | * @param maxEntries maximum number of entries to store. 18 | */ 19 | public InMemoryLRUAccessTokenCache(final int maxEntries) { 20 | this.cache = new LinkedHashMap(maxEntries, 0.75F, true) { 21 | private static final long serialVersionUID = -187234623489L; 22 | 23 | @Override 24 | protected boolean removeEldestEntry(java.util.Map.Entry eldest) { 25 | return size() > maxEntries; 26 | } 27 | }; 28 | } 29 | 30 | /** 31 | * Add an entry to the cache. 32 | * 33 | * @param key key to use. 34 | * @param value access token information to store. 35 | */ 36 | public void put(String key, String value) { 37 | synchronized (this.cache) { 38 | this.cache.put(key, value); 39 | } 40 | } 41 | 42 | /** 43 | * Get an entry from the cache. 44 | * 45 | * @param key key to look for. 46 | * @return access token information. 47 | */ 48 | public String get(String key) { 49 | synchronized (this.cache) { 50 | return this.cache.get(key); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/LRUCache.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.util.Iterator; 4 | import java.util.LinkedHashSet; 5 | 6 | class LRUCache { 7 | static final int MAX_SIZE = 512; 8 | 9 | private final LinkedHashSet linkedHashSet; 10 | 11 | LRUCache() { 12 | this.linkedHashSet = new LinkedHashSet(MAX_SIZE); 13 | } 14 | 15 | boolean add(E item) { 16 | boolean newItem = !this.linkedHashSet.remove(item); 17 | this.linkedHashSet.add(item); 18 | 19 | if (this.linkedHashSet.size() >= MAX_SIZE) { 20 | Iterator it = this.linkedHashSet.iterator(); 21 | it.next(); 22 | it.remove(); 23 | } 24 | 25 | return newItem; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/MetadataFieldFilter.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import com.eclipsesource.json.Json; 4 | import com.eclipsesource.json.JsonObject; 5 | import com.eclipsesource.json.JsonValue; 6 | 7 | /** 8 | * Filter for matching against a metadata field. 9 | */ 10 | public class MetadataFieldFilter { 11 | 12 | private final String field; 13 | private final JsonValue value; 14 | 15 | /** 16 | * Create a filter for matching against a string metadata field. 17 | * 18 | * @param field the field to match against. 19 | * @param value the value to match against. 20 | */ 21 | public MetadataFieldFilter(String field, String value) { 22 | 23 | this.field = field; 24 | this.value = Json.value(value); 25 | } 26 | 27 | /** 28 | * Create a filter for matching against a metadata field defined in JSON. 29 | * 30 | * @param jsonObj the JSON object to construct the filter from. 31 | */ 32 | public MetadataFieldFilter(JsonObject jsonObj) { 33 | this.field = jsonObj.get("field").asString(); 34 | this.value = jsonObj.get("value"); 35 | } 36 | 37 | /** 38 | * Get the JSON representation of the metadata field filter. 39 | * 40 | * @return the JSON object representing the filter. 41 | */ 42 | public JsonObject getJsonObject() { 43 | 44 | JsonObject obj = new JsonObject(); 45 | obj.add("field", this.field); 46 | 47 | obj.add("value", this.value); 48 | 49 | return obj; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/ProgressListener.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * The listener interface for monitoring the progress of a long-running API call. 5 | */ 6 | public interface ProgressListener { 7 | 8 | /** 9 | * Invoked when the progress of the API call changes. 10 | * In case of file uploads which are coming from a dynamic stream the file size cannot be determined and 11 | * total bytes will be reported as -1. 12 | * 13 | * @param numBytes the number of bytes completed. 14 | * @param totalBytes the total number of bytes. 15 | */ 16 | void onProgressChanged(long numBytes, long totalBytes); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/RequestBodyFromCallback.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.io.IOException; 4 | import okhttp3.MediaType; 5 | import okhttp3.RequestBody; 6 | import okio.BufferedSink; 7 | 8 | /** 9 | * 10 | */ 11 | final class RequestBodyFromCallback extends RequestBody { 12 | 13 | private final UploadFileCallback callback; 14 | private final MediaType mediaType; 15 | 16 | RequestBodyFromCallback(UploadFileCallback callback, MediaType mediaType) { 17 | this.callback = callback; 18 | this.mediaType = mediaType; 19 | } 20 | 21 | @Override 22 | public MediaType contentType() { 23 | return mediaType; 24 | } 25 | 26 | @Override 27 | public void writeTo(BufferedSink bufferedSink) throws IOException { 28 | callback.writeToStream(bufferedSink.outputStream()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/RequestInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | /** 4 | * The interface for intercepting requests to the Box API. 5 | * 6 | *

An interceptor may handle a request in any way it sees fit. It may update a request before it's sent, or it may 7 | * choose to return a custom response. If an interceptor returns a null response, then the request will continue to be 8 | * sent to the API along with any changes that the interceptor may have made to it.

9 | * 10 | *
public BoxAPIResponse onRequest(BoxAPIRequest request) {
11 |  *    request.addHeader("My-Header", "My-Value");
12 |  *
13 |  *    // Returning null means the request will be sent along with our new header.
14 |  *    return null;
15 |  * }
16 | * 17 | *

However, if a response is returned, then the request won't be sent and the interceptor's response will take the 18 | * place of the normal response.

19 | * 20 | *
public BoxAPIResponse onRequest(BoxAPIRequest request) {
21 |  *    // Returning our own response means the request won't be sent at all.
22 |  *    return new BoxAPIResponse();
23 |  * }
24 | * 25 | *

A RequestInterceptor can be very useful for testing purposes. Requests to the Box API can be intercepted and fake 26 | * responses can be returned, allowing you to effectively test your code without needing to actually communicate with 27 | * the Box API.

28 | */ 29 | public interface RequestInterceptor { 30 | /** 31 | * Invoked when a request is about to be sent to the API. 32 | * 33 | * @param request the request that is about to be sent. 34 | * @return an optional response to the request. If the response is null, then the request will continue to 35 | * be sent to the Box API. 36 | */ 37 | BoxAPIResponse onRequest(BoxAPIRequest request); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/StandardCharsets.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | import java.nio.charset.Charset; 4 | 5 | /** 6 | * Constant definitions for the standard Charsets. 7 | *

8 | * NB: Replace with java.nio.charset.StandardCharsets when we drop 1.6 support. 9 | */ 10 | public final class StandardCharsets { 11 | 12 | /** 13 | * Eight-bit UCS Transformation Format. 14 | */ 15 | public static final Charset UTF_8 = Charset.forName("UTF-8"); 16 | 17 | private StandardCharsets() { 18 | throw new UnsupportedOperationException(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/box/sdk/Time.java: -------------------------------------------------------------------------------- 1 | package com.box.sdk; 2 | 3 | class Time { 4 | private static final ThreadLocal