├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml ├── resources │ ├── firebase.asc.gpg │ ├── integ-service-account.json.gpg │ └── settings.xml ├── scripts │ ├── generate_changelog.sh │ ├── package_artifacts.sh │ ├── publish_artifacts.sh │ └── publish_preflight_check.sh └── workflows │ ├── ci.yml │ ├── nightly.yml │ └── release.yml ├── .gitignore ├── .opensource └── project.json ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE.txt ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── checkstyle.xml ├── pom.xml ├── prepare_release.sh └── src ├── main ├── java │ └── com │ │ └── google │ │ └── firebase │ │ ├── ErrorCode.java │ │ ├── FirebaseApp.java │ │ ├── FirebaseAppLifecycleListener.java │ │ ├── FirebaseException.java │ │ ├── FirebaseOptions.java │ │ ├── ImplFirebaseTrampolines.java │ │ ├── IncomingHttpResponse.java │ │ ├── OutgoingHttpRequest.java │ │ ├── ThreadManager.java │ │ ├── auth │ │ ├── AbstractFirebaseAuth.java │ │ ├── ActionCodeSettings.java │ │ ├── AuthErrorCode.java │ │ ├── DeleteUsersResult.java │ │ ├── EmailIdentifier.java │ │ ├── ErrorInfo.java │ │ ├── ExportedUserRecord.java │ │ ├── FirebaseAuth.java │ │ ├── FirebaseAuthException.java │ │ ├── FirebaseToken.java │ │ ├── FirebaseTokenUtils.java │ │ ├── FirebaseTokenVerifier.java │ │ ├── FirebaseTokenVerifierImpl.java │ │ ├── FirebaseUserManager.java │ │ ├── GetUsersResult.java │ │ ├── ImportUserRecord.java │ │ ├── ListProviderConfigsPage.java │ │ ├── ListUsersPage.java │ │ ├── OidcProviderConfig.java │ │ ├── PhoneIdentifier.java │ │ ├── ProviderConfig.java │ │ ├── ProviderIdentifier.java │ │ ├── ProviderUserInfo.java │ │ ├── RevocationCheckDecorator.java │ │ ├── SamlProviderConfig.java │ │ ├── SessionCookieOptions.java │ │ ├── UidIdentifier.java │ │ ├── UserIdentifier.java │ │ ├── UserImportHash.java │ │ ├── UserImportOptions.java │ │ ├── UserImportResult.java │ │ ├── UserInfo.java │ │ ├── UserMetadata.java │ │ ├── UserProvider.java │ │ ├── UserRecord.java │ │ ├── hash │ │ │ ├── Argon2.java │ │ │ ├── Bcrypt.java │ │ │ ├── Hmac.java │ │ │ ├── HmacMd5.java │ │ │ ├── HmacSha1.java │ │ │ ├── HmacSha256.java │ │ │ ├── HmacSha512.java │ │ │ ├── Md5.java │ │ │ ├── Pbkdf2Sha256.java │ │ │ ├── PbkdfSha1.java │ │ │ ├── RepeatableHash.java │ │ │ ├── Scrypt.java │ │ │ ├── Sha1.java │ │ │ ├── Sha256.java │ │ │ ├── Sha512.java │ │ │ └── StandardScrypt.java │ │ ├── internal │ │ │ ├── AuthErrorHandler.java │ │ │ ├── AuthHttpClient.java │ │ │ ├── BatchDeleteResponse.java │ │ │ ├── CryptoSigner.java │ │ │ ├── CryptoSigners.java │ │ │ ├── DownloadAccountResponse.java │ │ │ ├── FirebaseCustomAuthToken.java │ │ │ ├── FirebaseTokenFactory.java │ │ │ ├── GetAccountInfoRequest.java │ │ │ ├── GetAccountInfoResponse.java │ │ │ ├── ListOidcProviderConfigsResponse.java │ │ │ ├── ListProviderConfigsResponse.java │ │ │ ├── ListSamlProviderConfigsResponse.java │ │ │ ├── ListTenantsResponse.java │ │ │ ├── UploadAccountResponse.java │ │ │ ├── Utils.java │ │ │ └── package-info.java │ │ └── multitenancy │ │ │ ├── FirebaseTenantClient.java │ │ │ ├── ListTenantsPage.java │ │ │ ├── Tenant.java │ │ │ ├── TenantAwareFirebaseAuth.java │ │ │ └── TenantManager.java │ │ ├── cloud │ │ ├── FirestoreClient.java │ │ └── StorageClient.java │ │ ├── database │ │ ├── ChildEventListener.java │ │ ├── DataSnapshot.java │ │ ├── DatabaseError.java │ │ ├── DatabaseException.java │ │ ├── DatabaseReference.java │ │ ├── Exclude.java │ │ ├── FirebaseDatabase.java │ │ ├── GenericTypeIndicator.java │ │ ├── IgnoreExtraProperties.java │ │ ├── InternalHelpers.java │ │ ├── MutableData.java │ │ ├── OnDisconnect.java │ │ ├── PropertyName.java │ │ ├── Query.java │ │ ├── ServerValue.java │ │ ├── ThrowOnExtraProperties.java │ │ ├── Transaction.java │ │ ├── ValueEventListener.java │ │ ├── annotations │ │ │ ├── NotNull.java │ │ │ ├── Nullable.java │ │ │ └── package-info.java │ │ ├── collection │ │ │ ├── ArraySortedMap.java │ │ │ ├── ImmutableSortedMap.java │ │ │ ├── ImmutableSortedMapIterator.java │ │ │ ├── ImmutableSortedSet.java │ │ │ ├── LLRBBlackValueNode.java │ │ │ ├── LLRBEmptyNode.java │ │ │ ├── LLRBNode.java │ │ │ ├── LLRBRedValueNode.java │ │ │ ├── LLRBValueNode.java │ │ │ ├── RBTreeSortedMap.java │ │ │ ├── StandardComparator.java │ │ │ └── package-info.java │ │ ├── connection │ │ │ ├── CompoundHash.java │ │ │ ├── Connection.java │ │ │ ├── ConnectionAuthTokenProvider.java │ │ │ ├── ConnectionContext.java │ │ │ ├── ConnectionUtils.java │ │ │ ├── Constants.java │ │ │ ├── HostInfo.java │ │ │ ├── ListenHashProvider.java │ │ │ ├── NettyWebSocketClient.java │ │ │ ├── PersistentConnection.java │ │ │ ├── PersistentConnectionImpl.java │ │ │ ├── RangeMerge.java │ │ │ ├── RequestResultCallback.java │ │ │ ├── WebsocketConnection.java │ │ │ ├── package-info.java │ │ │ └── util │ │ │ │ ├── RetryHelper.java │ │ │ │ └── package-info.java │ │ ├── core │ │ │ ├── AuthTokenProvider.java │ │ │ ├── ChildEventRegistration.java │ │ │ ├── CompoundWrite.java │ │ │ ├── Constants.java │ │ │ ├── Context.java │ │ │ ├── DatabaseConfig.java │ │ │ ├── EventRegistration.java │ │ │ ├── EventRegistrationZombieListener.java │ │ │ ├── EventTarget.java │ │ │ ├── JvmAuthTokenProvider.java │ │ │ ├── JvmPlatform.java │ │ │ ├── Path.java │ │ │ ├── Platform.java │ │ │ ├── Repo.java │ │ │ ├── RepoInfo.java │ │ │ ├── RepoManager.java │ │ │ ├── RunLoop.java │ │ │ ├── ServerValues.java │ │ │ ├── SnapshotHolder.java │ │ │ ├── SparseSnapshotTree.java │ │ │ ├── SyncPoint.java │ │ │ ├── SyncTree.java │ │ │ ├── Tag.java │ │ │ ├── ThreadPoolEventTarget.java │ │ │ ├── UserWriteRecord.java │ │ │ ├── ValidationPath.java │ │ │ ├── ValueEventRegistration.java │ │ │ ├── WriteTree.java │ │ │ ├── WriteTreeRef.java │ │ │ ├── ZombieEventManager.java │ │ │ ├── operation │ │ │ │ ├── AckUserWrite.java │ │ │ │ ├── ListenComplete.java │ │ │ │ ├── Merge.java │ │ │ │ ├── Operation.java │ │ │ │ ├── OperationSource.java │ │ │ │ ├── Overwrite.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── persistence │ │ │ │ ├── CachePolicy.java │ │ │ │ ├── DefaultPersistenceManager.java │ │ │ │ ├── LRUCachePolicy.java │ │ │ │ ├── NoopPersistenceManager.java │ │ │ │ ├── PersistenceManager.java │ │ │ │ ├── PersistenceStorageEngine.java │ │ │ │ ├── PruneForest.java │ │ │ │ ├── TrackedQuery.java │ │ │ │ ├── TrackedQueryManager.java │ │ │ │ └── package-info.java │ │ │ ├── utilities │ │ │ │ ├── ImmutableTree.java │ │ │ │ ├── Predicate.java │ │ │ │ ├── Tree.java │ │ │ │ ├── TreeNode.java │ │ │ │ └── package-info.java │ │ │ └── view │ │ │ │ ├── CacheNode.java │ │ │ │ ├── CancelEvent.java │ │ │ │ ├── Change.java │ │ │ │ ├── DataEvent.java │ │ │ │ ├── Event.java │ │ │ │ ├── EventGenerator.java │ │ │ │ ├── EventRaiser.java │ │ │ │ ├── QueryParams.java │ │ │ │ ├── QuerySpec.java │ │ │ │ ├── View.java │ │ │ │ ├── ViewCache.java │ │ │ │ ├── ViewProcessor.java │ │ │ │ ├── filter │ │ │ │ ├── ChildChangeAccumulator.java │ │ │ │ ├── IndexedFilter.java │ │ │ │ ├── LimitedFilter.java │ │ │ │ ├── NodeFilter.java │ │ │ │ ├── RangedFilter.java │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ ├── snapshot │ │ │ ├── BooleanNode.java │ │ │ ├── ChildKey.java │ │ │ ├── ChildrenNode.java │ │ │ ├── CompoundHash.java │ │ │ ├── DeferredValueNode.java │ │ │ ├── DoubleNode.java │ │ │ ├── EmptyNode.java │ │ │ ├── Index.java │ │ │ ├── IndexedNode.java │ │ │ ├── KeyIndex.java │ │ │ ├── LeafNode.java │ │ │ ├── LongNode.java │ │ │ ├── NamedNode.java │ │ │ ├── Node.java │ │ │ ├── NodeUtilities.java │ │ │ ├── PathIndex.java │ │ │ ├── PriorityIndex.java │ │ │ ├── PriorityUtilities.java │ │ │ ├── RangeMerge.java │ │ │ ├── StringNode.java │ │ │ ├── ValueIndex.java │ │ │ └── package-info.java │ │ ├── util │ │ │ ├── EmulatorHelper.java │ │ │ ├── GAuthToken.java │ │ │ ├── JsonMapper.java │ │ │ └── package-info.java │ │ └── utilities │ │ │ ├── Clock.java │ │ │ ├── DefaultClock.java │ │ │ ├── DefaultRunLoop.java │ │ │ ├── NodeSizeEstimator.java │ │ │ ├── OffsetClock.java │ │ │ ├── Pair.java │ │ │ ├── ParsedUrl.java │ │ │ ├── PushIdGenerator.java │ │ │ ├── Utilities.java │ │ │ ├── Validation.java │ │ │ ├── encoding │ │ │ ├── CustomClassMapper.java │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ ├── iid │ │ ├── FirebaseInstanceId.java │ │ └── FirebaseInstanceIdException.java │ │ ├── internal │ │ ├── AbstractHttpErrorHandler.java │ │ ├── AbstractPlatformErrorHandler.java │ │ ├── ApacheHttp2AsyncEntityProducer.java │ │ ├── ApacheHttp2Request.java │ │ ├── ApacheHttp2Response.java │ │ ├── ApacheHttp2Transport.java │ │ ├── ApiClientUtils.java │ │ ├── ApplicationDefaultCredentialsProvider.java │ │ ├── CallableOperation.java │ │ ├── DateUtils.java │ │ ├── EmulatorCredentials.java │ │ ├── ErrorHandlingHttpClient.java │ │ ├── FirebaseProcessEnvironment.java │ │ ├── FirebaseRequestInitializer.java │ │ ├── FirebaseScheduledExecutor.java │ │ ├── FirebaseService.java │ │ ├── FirebaseThreadManagers.java │ │ ├── GuardedBy.java │ │ ├── HttpErrorHandler.java │ │ ├── HttpRequestInfo.java │ │ ├── ListenableFuture2ApiFuture.java │ │ ├── MockApacheHttp2AsyncClient.java │ │ ├── NonNull.java │ │ ├── Nullable.java │ │ ├── RetryConfig.java │ │ ├── RetryInitializer.java │ │ ├── RetryUnsuccessfulResponseHandler.java │ │ ├── SdkUtils.java │ │ └── package-info.java │ │ ├── messaging │ │ ├── AndroidConfig.java │ │ ├── AndroidFcmOptions.java │ │ ├── AndroidNotification.java │ │ ├── ApnsConfig.java │ │ ├── ApnsFcmOptions.java │ │ ├── Aps.java │ │ ├── ApsAlert.java │ │ ├── BatchResponse.java │ │ ├── BatchResponseImpl.java │ │ ├── CriticalSound.java │ │ ├── FcmOptions.java │ │ ├── FcmOptionsUtil.java │ │ ├── FirebaseMessaging.java │ │ ├── FirebaseMessagingClient.java │ │ ├── FirebaseMessagingClientImpl.java │ │ ├── FirebaseMessagingException.java │ │ ├── InstanceIdClient.java │ │ ├── InstanceIdClientImpl.java │ │ ├── LightSettings.java │ │ ├── LightSettingsColor.java │ │ ├── Message.java │ │ ├── MessagingErrorCode.java │ │ ├── MulticastMessage.java │ │ ├── Notification.java │ │ ├── SendResponse.java │ │ ├── TopicManagementResponse.java │ │ ├── WebpushConfig.java │ │ ├── WebpushFcmOptions.java │ │ ├── WebpushNotification.java │ │ └── internal │ │ │ ├── MessagingServiceErrorResponse.java │ │ │ ├── MessagingServiceResponse.java │ │ │ └── package-info.java │ │ ├── projectmanagement │ │ ├── AndroidApp.java │ │ ├── AndroidAppMetadata.java │ │ ├── AndroidAppService.java │ │ ├── FirebaseProjectManagement.java │ │ ├── FirebaseProjectManagementException.java │ │ ├── FirebaseProjectManagementServiceImpl.java │ │ ├── HttpHelper.java │ │ ├── IosApp.java │ │ ├── IosAppMetadata.java │ │ ├── IosAppService.java │ │ ├── Scheduler.java │ │ ├── ShaCertificate.java │ │ └── ShaCertificateType.java │ │ └── remoteconfig │ │ ├── Condition.java │ │ ├── FirebaseRemoteConfig.java │ │ ├── FirebaseRemoteConfigClient.java │ │ ├── FirebaseRemoteConfigClientImpl.java │ │ ├── FirebaseRemoteConfigException.java │ │ ├── ListVersionsOptions.java │ │ ├── ListVersionsPage.java │ │ ├── Parameter.java │ │ ├── ParameterGroup.java │ │ ├── ParameterValue.java │ │ ├── ParameterValueType.java │ │ ├── PublishOptions.java │ │ ├── RemoteConfigErrorCode.java │ │ ├── RemoteConfigUtil.java │ │ ├── TagColor.java │ │ ├── Template.java │ │ ├── User.java │ │ ├── Version.java │ │ └── internal │ │ ├── RemoteConfigServiceErrorResponse.java │ │ ├── TemplateResponse.java │ │ └── package-info.java └── resources │ └── admin_sdk.properties └── test ├── java └── com │ └── google │ └── firebase │ ├── CodeCoverageReporter.java │ ├── FirebaseAppTest.java │ ├── FirebaseExceptionTest.java │ ├── FirebaseOptionsTest.java │ ├── IncomingHttpResponseTest.java │ ├── OutgoingHttpRequestTest.java │ ├── TestOnlyImplFirebaseTrampolines.java │ ├── ThreadManagerTest.java │ ├── auth │ ├── ActionCodeSettingsTest.java │ ├── EmulatorFirebaseTokenVerifierImplTest.java │ ├── FirebaseAuthIT.java │ ├── FirebaseAuthTest.java │ ├── FirebaseCustomTokenTest.java │ ├── FirebaseTokenTest.java │ ├── FirebaseTokenUtilsTest.java │ ├── FirebaseTokenVerifierImplTest.java │ ├── FirebaseTokenVerifierImplTestUtils.java │ ├── FirebaseUserManagerTest.java │ ├── GetUsersIT.java │ ├── ImportUserRecordTest.java │ ├── ListProviderConfigsPageTest.java │ ├── ListUsersPageTest.java │ ├── MockGoogleCredentials.java │ ├── MockTokenVerifier.java │ ├── OidcProviderConfigTest.java │ ├── ProviderConfigTestUtils.java │ ├── SamlProviderConfigTest.java │ ├── TestTokenFactory.java │ ├── UserImportHashTest.java │ ├── UserImportOptionsTest.java │ ├── UserProviderTest.java │ ├── UserRecordTest.java │ ├── UserTestUtils.java │ ├── hash │ │ └── InvalidHashTest.java │ ├── internal │ │ ├── CryptoSignersTest.java │ │ ├── FirebaseTokenFactoryTest.java │ │ ├── ListOidcProviderConfigsResponseTest.java │ │ ├── ListSamlProviderConfigsResponseTest.java │ │ └── ListTenantsResponseTest.java │ └── multitenancy │ │ ├── FirebaseTenantClientTest.java │ │ ├── ListTenantsPageTest.java │ │ ├── TenantAwareFirebaseAuthIT.java │ │ ├── TenantAwareFirebaseAuthTest.java │ │ ├── TenantManagerIT.java │ │ └── TenantTest.java │ ├── cloud │ ├── FirestoreClientIT.java │ ├── FirestoreClientTest.java │ ├── StorageClientIT.java │ └── StorageClientTest.java │ ├── database │ ├── DataSnapshotTest.java │ ├── DatabaseErrorTest.java │ ├── DatabaseReferenceTest.java │ ├── EventRecord.java │ ├── FirebaseDatabaseTest.java │ ├── MapBuilder.java │ ├── MapperTest.java │ ├── MutableDataTest.java │ ├── ObjectMapTest.java │ ├── OnDisconnectTest.java │ ├── QueryTest.java │ ├── TestChildEventListener.java │ ├── TestFailure.java │ ├── TestHelpers.java │ ├── TestTokenProvider.java │ ├── UtilitiesTest.java │ ├── ValueExpectationHelper.java │ ├── collection │ │ ├── ArraySortedMapTest.java │ │ ├── ImmutableSortedSetTest.java │ │ └── RBTreeSortedMapTest.java │ ├── connection │ │ ├── ConnectionTest.java │ │ ├── ConnectionUtilsTest.java │ │ ├── ListenAggregator.java │ │ ├── PersistentConnectionTest.java │ │ └── WebsocketConnectionTest.java │ ├── core │ │ ├── CompoundWriteTest.java │ │ ├── CoreTestHelpers.java │ │ ├── JvmAuthTokenProviderTest.java │ │ ├── JvmPlatformTest.java │ │ ├── PathTest.java │ │ ├── RandomOperationGenerator.java │ │ ├── RandomViewProcessorTest.java │ │ ├── RangeMergeTest.java │ │ ├── RepoInfoTest.java │ │ ├── RepoTest.java │ │ ├── SyncPointTest.java │ │ ├── ZombieVerifier.java │ │ ├── persistence │ │ │ ├── DefaultPersistenceManagerTest.java │ │ │ ├── KeepSyncedTestIT.java │ │ │ ├── MockListenProvider.java │ │ │ ├── MockPersistenceStorageEngine.java │ │ │ ├── PruneForestTest.java │ │ │ ├── RandomPersistenceTest.java │ │ │ ├── TestCachePolicy.java │ │ │ └── TrackedQueryManagerTest.java │ │ ├── utilities │ │ │ ├── TestClock.java │ │ │ └── TreeTest.java │ │ └── view │ │ │ ├── QueryParamsTest.java │ │ │ └── ViewAccess.java │ ├── future │ │ ├── ReadFuture.java │ │ └── WriteFuture.java │ ├── integration │ │ ├── DataTestIT.java │ │ ├── EventHelper.java │ │ ├── EventTestIT.java │ │ ├── FirebaseDatabaseAuthTestIT.java │ │ ├── FirebaseDatabaseTestIT.java │ │ ├── InfoTestIT.java │ │ ├── OrderByTestIT.java │ │ ├── OrderTestIT.java │ │ ├── QueryTestIT.java │ │ ├── RealtimeTestIT.java │ │ ├── RulesClient.java │ │ ├── RulesTestIT.java │ │ ├── ShutdownExample.java │ │ └── TransactionTestIT.java │ ├── snapshot │ │ ├── CompoundHashTest.java │ │ └── NodeTest.java │ ├── util │ │ ├── EmulatorHelperTest.java │ │ ├── GAuthTokenTest.java │ │ └── JsonMapperTest.java │ └── utilities │ │ ├── DefaultRunLoopTest.java │ │ ├── NodeSizeEstimatorTest.java │ │ ├── PairTest.java │ │ ├── PushIdGeneratorTest.java │ │ ├── UtilitiesTest.java │ │ └── ValidationTest.java │ ├── iid │ ├── FirebaseInstanceIdIT.java │ └── FirebaseInstanceIdTest.java │ ├── internal │ ├── AbstractPlatformErrorHandlerTest.java │ ├── ApacheHttp2TransportIT.java │ ├── ApacheHttp2TransportTest.java │ ├── ApiClientUtilsTest.java │ ├── CallableOperationTest.java │ ├── CountingLowLevelHttpRequest.java │ ├── DateUtilsTest.java │ ├── ErrorHandlingHttpClientTest.java │ ├── FirebaseAppStoreTest.java │ ├── FirebaseRequestInitializerTest.java │ ├── FirebaseThreadManagersTest.java │ ├── MockApacheHttp2Response.java │ ├── RetryConfigTest.java │ ├── RetryInitializerTest.java │ ├── RetryUnsuccessfulResponseHandlerTest.java │ └── TestApiClientUtils.java │ ├── messaging │ ├── BatchResponseTest.java │ ├── FirebaseMessagingClientImplTest.java │ ├── FirebaseMessagingIT.java │ ├── FirebaseMessagingTest.java │ ├── InstanceIdClientImplTest.java │ ├── MessageTest.java │ ├── MulticastMessageTest.java │ └── SendResponseTest.java │ ├── projectmanagement │ ├── AndroidAppTest.java │ ├── FirebaseProjectManagementIT.java │ ├── FirebaseProjectManagementServiceImplTest.java │ ├── FirebaseProjectManagementTest.java │ ├── IosAppTest.java │ └── ShaCertificateTest.java │ ├── remoteconfig │ ├── ConditionTest.java │ ├── FirebaseRemoteConfigClientImplTest.java │ ├── FirebaseRemoteConfigIT.java │ ├── FirebaseRemoteConfigTest.java │ ├── ListVersionsPageTest.java │ ├── MockRemoteConfigClient.java │ ├── ParameterGroupTest.java │ ├── ParameterTest.java │ ├── ParameterValueTest.java │ ├── TemplateTest.java │ ├── UserTest.java │ └── VersionTest.java │ ├── snippets │ ├── FirebaseAppSnippets.java │ ├── FirebaseAuthSnippets.java │ ├── FirebaseDatabaseSnippets.java │ ├── FirebaseMessagingSnippets.java │ └── FirebaseStorageSnippets.java │ └── testing │ ├── FirebaseAppRule.java │ ├── GenericFunction.java │ ├── IntegrationTestUtils.java │ ├── MockitoTestRule.java │ ├── MultiRequestMockHttpTransport.java │ ├── ServiceAccount.java │ ├── TestResponseInterceptor.java │ └── TestUtils.java └── resources ├── createSessionCookie.json ├── createUser.json ├── deleteUser.json ├── fcm_batch_failure.txt ├── fcm_batch_success.txt ├── firebase_config.json ├── firebase_config_empty.json ├── firebase_config_invalid.json ├── firebase_config_invalid_key.json ├── firebase_config_partial.json ├── generateEmailLink.json ├── getRemoteConfig.json ├── getUser.json ├── getUserError.json ├── importUsersError.json ├── listOidc.json ├── listRemoteConfigVersions.json ├── listSaml.json ├── listTenants.json ├── listUsers.json ├── oidc.json ├── saml.json ├── service_accounts ├── editor.json ├── editor_public_key.pem ├── none.json ├── none_public_key.pem ├── owner.json ├── owner_public_key.pem ├── viewer.json └── viewer_public_key.pem ├── syncPointSpec.json └── tenant.json /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### [READ] Step 1: Are you in the right place? 11 | 12 | * For issues or feature requests related to __the code in this repository__ 13 | file a Github issue. 14 | * If this is a __feature request__ make sure the issue title starts with "FR:". 15 | * For general technical questions, post a question on [StackOverflow](http://stackoverflow.com/) 16 | with the firebase tag. 17 | * For general Firebase discussion, use the [firebase-talk](https://groups.google.com/forum/#!forum/firebase-talk) 18 | google group. 19 | * For help troubleshooting your application that does not fall under one 20 | of the above categories, reach out to the personalized 21 | [Firebase support channel](https://firebase.google.com/support/). 22 | 23 | ### [REQUIRED] Step 2: Describe your environment 24 | 25 | * Operating System version: _____ 26 | * Firebase SDK version: _____ 27 | * Library version: _____ 28 | * Firebase Product: _____ (auth, database, storage, etc) 29 | 30 | ### [REQUIRED] Step 3: Describe the problem 31 | 32 | #### Steps to reproduce: 33 | 34 | What happened? How can we make the problem occur? 35 | This could be a description, log/console output, etc. 36 | 37 | #### Relevant Code: 38 | 39 | ``` 40 | // TODO(you): code here to reproduce the problem 41 | ``` 42 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '[FR]' 5 | labels: 'type: feature request' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.github/resources/firebase.asc.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebase/firebase-admin-java/4f73761203316c3d84b9993aebb960c784f561bb/.github/resources/firebase.asc.gpg -------------------------------------------------------------------------------- /.github/resources/integ-service-account.json.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebase/firebase-admin-java/4f73761203316c3d84b9993aebb960c784f561bb/.github/resources/integ-service-account.json.gpg -------------------------------------------------------------------------------- /.github/resources/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | false 7 | 8 | 9 | 10 | ossrh 11 | ${env.NEXUS_OSSRH_USERNAME} 12 | ${env.NEXUS_OSSRH_PASSWORD} 13 | 14 | 15 | 16 | 17 | 18 | release 19 | 20 | true 21 | 22 | 23 | gpg 24 | 0A05D8FAD4287A36C53BE07714D6B82AEB1DD39C 25 | ${env.GPG_PASSPHRASE} 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /.github/scripts/package_artifacts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2020 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | set -u 19 | 20 | gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" \ 21 | --output integration_cert.json .github/resources/integ-service-account.json.gpg 22 | 23 | echo "${FIREBASE_API_KEY}" > integration_apikey.txt 24 | 25 | # Does the following: 26 | # 1. Runs the Checkstyle plugin (validate phase) 27 | # 2. Compiles the source (compile phase) 28 | # 3. Runs the unit tests (test phase) 29 | # 4. Packages the artifacts - src, bin, javadocs (package phase) 30 | # 5. Runs the integration tests (verify phase) 31 | mvn -DtrimStackTrace=false -B clean verify 32 | 33 | # Maven target directory can consist of many files. Just copy the jar artifacts 34 | # into a new directory for upload. 35 | mkdir -p dist 36 | cp target/*.jar dist/ 37 | -------------------------------------------------------------------------------- /.github/scripts/publish_artifacts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2020 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | set -u 19 | 20 | gpg --quiet --batch --yes --decrypt --passphrase="${GPG_PRIVATE_KEY}" \ 21 | --output firebase.asc .github/resources/firebase.asc.gpg 22 | 23 | gpg --import --no-tty --batch --yes firebase.asc 24 | 25 | # Does the following: 26 | # 1. Compiles the source (compile phase) 27 | # 2. Packages the artifacts - src, bin, javadocs (package phase) 28 | # 3. Signs the artifacts (verify phase) 29 | # 4. Publishes artifacts via Nexus (deploy phase) 30 | mvn -B clean deploy \ 31 | -Dcheckstyle.skip \ 32 | -DskipTests \ 33 | -Prelease \ 34 | --settings .github/resources/settings.xml 35 | 36 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | name: Continuous Integration 15 | 16 | on: pull_request 17 | 18 | jobs: 19 | build: 20 | runs-on: ubuntu-latest 21 | 22 | strategy: 23 | matrix: 24 | java-version: [8, 11, 17] 25 | 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - name: Set up JDK 30 | uses: actions/setup-java@v4 31 | with: 32 | distribution: 'zulu' 33 | java-version: ${{ matrix.java-version }} 34 | 35 | # Does the following: 36 | # 1. Runs the Checkstyle plugin (validate phase) 37 | # 2. Compiles the source (compile phase) 38 | # 3. Runs the unit tests (test phase) 39 | - name: Build with Maven 40 | run: mvn -B clean test 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ 3 | .settings/ 4 | *.iml 5 | .classpath 6 | .project 7 | .checkstyle 8 | .factorypath 9 | .vscode/ 10 | release.properties 11 | integration_cert.json 12 | integration_apikey.txt 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /.opensource/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Firebase Admin SDK - Java", 3 | "platforms": [ 4 | "Java", 5 | "Admin" 6 | ], 7 | "content": "README.md", 8 | "pages": [], 9 | "related": [ 10 | "firebase/firebase-admin-dotnet", 11 | "firebase/firebase-admin-go", 12 | "firebase/firebase-admin-node", 13 | "firebase/firebase-admin-python" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Firebase Admin Java SDK 2 | Copyright 2019 Google Inc. 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Hey there! So you want to contribute to a Firebase SDK? 2 | Before you file this pull request, please read these guidelines: 3 | 4 | ### Discussion 5 | 6 | * Read the contribution guidelines (CONTRIBUTING.md). 7 | * If this has been discussed in an issue, make sure to link to the issue here. 8 | If not, go file an issue about this **before creating a pull request** to discuss. 9 | 10 | ### Testing 11 | 12 | * Make sure all existing tests in the repository pass after your change. 13 | * If you fixed a bug or added a feature, add a new test to cover your code. 14 | 15 | ### API Changes 16 | 17 | * At this time we cannot accept changes that affect the public API. If you'd like to help 18 | us make Firebase APIs better, please propose your change in an issue so that we 19 | can discuss it together. 20 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/FirebaseAppLifecycleListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase; 18 | 19 | /** 20 | * A listener which gets notified when {@link com.google.firebase.FirebaseApp} gets deleted. 21 | */ 22 | @Deprecated 23 | interface FirebaseAppLifecycleListener { 24 | 25 | /** 26 | * Gets called when {@link FirebaseApp#delete()} is called. {@link FirebaseApp} public methods 27 | * start throwing after delete is called, so name and options are passed in to be able to identify 28 | * the instance. 29 | */ 30 | void onDeleted(String firebaseAppName, FirebaseOptions options); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/EmailIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import com.google.firebase.auth.internal.GetAccountInfoRequest; 20 | import com.google.firebase.internal.NonNull; 21 | 22 | /** 23 | * Used for looking up an account by email. 24 | * 25 | * @see {FirebaseAuth#getUsers} 26 | */ 27 | public final class EmailIdentifier extends UserIdentifier { 28 | private final String email; 29 | 30 | public EmailIdentifier(@NonNull String email) { 31 | UserRecord.checkEmail(email); 32 | this.email = email; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "EmailIdentifier(" + email + ")"; 38 | } 39 | 40 | @Override 41 | void populate(@NonNull GetAccountInfoRequest payload) { 42 | payload.addEmail(email); 43 | } 44 | 45 | @Override 46 | boolean matches(@NonNull UserRecord userRecord) { 47 | return email.equals(userRecord.getEmail()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/ErrorInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Represents an error encountered while importing an {@link ImportUserRecord}. 23 | */ 24 | public final class ErrorInfo { 25 | 26 | private final int index; 27 | private final String reason; 28 | 29 | ErrorInfo(int index, String reason) { 30 | this.index = index; 31 | this.reason = reason; 32 | } 33 | 34 | /** 35 | * The index of the failed user in the list passed to the 36 | * {@link FirebaseAuth#importUsersAsync(List, UserImportOptions)} method. 37 | * 38 | * @return an integer index. 39 | */ 40 | public int getIndex() { 41 | return index; 42 | } 43 | 44 | /** 45 | * A string describing the error. 46 | * 47 | * @return A string error message. 48 | */ 49 | public String getReason() { 50 | return reason; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/FirebaseAuthException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import com.google.firebase.ErrorCode; 20 | import com.google.firebase.FirebaseException; 21 | import com.google.firebase.IncomingHttpResponse; 22 | import com.google.firebase.internal.NonNull; 23 | import com.google.firebase.internal.Nullable; 24 | 25 | /** 26 | * Generic exception related to Firebase Authentication. Check the error code and message for more 27 | * details. 28 | */ 29 | public class FirebaseAuthException extends FirebaseException { 30 | 31 | private final AuthErrorCode errorCode; 32 | 33 | public FirebaseAuthException( 34 | @NonNull ErrorCode errorCode, 35 | @NonNull String message, 36 | Throwable cause, 37 | IncomingHttpResponse response, 38 | AuthErrorCode authErrorCode) { 39 | super(errorCode, message, cause, response); 40 | this.errorCode = authErrorCode; 41 | } 42 | 43 | public FirebaseAuthException(FirebaseException base) { 44 | this(base.getErrorCode(), base.getMessage(), base.getCause(), base.getHttpResponse(), null); 45 | } 46 | 47 | @Nullable 48 | public AuthErrorCode getAuthErrorCode() { 49 | return errorCode; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/FirebaseTokenVerifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | /** 20 | * An interface for verifying Firebase token strings. Exists mainly to facilitate easy testing 21 | * and extension/decoration of the token verification functionality. 22 | */ 23 | interface FirebaseTokenVerifier { 24 | 25 | /** 26 | * Verifies that the given token string is a valid Firebase JWT. 27 | * 28 | * @param token The token string to be verified. 29 | * @return A decoded representation of the input token string. 30 | * @throws FirebaseAuthException If the input token string fails to verify due to any reason. 31 | */ 32 | FirebaseToken verifyToken(String token) throws FirebaseAuthException; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/GetUsersResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import static com.google.common.base.Preconditions.checkNotNull; 20 | 21 | import com.google.firebase.internal.NonNull; 22 | import java.util.Set; 23 | 24 | /** 25 | * Represents the result of the {@link FirebaseAuth#getUsersAsync(Collection)} API. 26 | */ 27 | public final class GetUsersResult { 28 | private final Set users; 29 | private final Set notFound; 30 | 31 | GetUsersResult(@NonNull Set users, @NonNull Set notFound) { 32 | this.users = checkNotNull(users); 33 | this.notFound = checkNotNull(notFound); 34 | } 35 | 36 | /** 37 | * Set of user records corresponding to the set of users that were requested. Only users 38 | * that were found are listed here. The result set is unordered. 39 | */ 40 | @NonNull 41 | public Set getUsers() { 42 | return this.users; 43 | } 44 | 45 | /** 46 | * Set of identifiers that were requested, but not found. 47 | */ 48 | @NonNull 49 | public Set getNotFound() { 50 | return this.notFound; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/PhoneIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import com.google.firebase.auth.internal.GetAccountInfoRequest; 20 | import com.google.firebase.internal.NonNull; 21 | 22 | /** 23 | * Used for looking up an account by phone number. 24 | * 25 | * @see {FirebaseAuth#getUsers} 26 | */ 27 | public final class PhoneIdentifier extends UserIdentifier { 28 | private final String phoneNumber; 29 | 30 | public PhoneIdentifier(@NonNull String phoneNumber) { 31 | UserRecord.checkPhoneNumber(phoneNumber); 32 | this.phoneNumber = phoneNumber; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "PhoneIdentifier(" + phoneNumber + ")"; 38 | } 39 | 40 | @Override 41 | void populate(@NonNull GetAccountInfoRequest payload) { 42 | payload.addPhoneNumber(phoneNumber); 43 | } 44 | 45 | @Override 46 | boolean matches(@NonNull UserRecord userRecord) { 47 | return phoneNumber.equals(userRecord.getPhoneNumber()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/ProviderIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import com.google.firebase.auth.internal.GetAccountInfoRequest; 20 | import com.google.firebase.internal.NonNull; 21 | 22 | /** 23 | * Used for looking up an account by provider. 24 | * 25 | * @see {FirebaseAuth#getUsers} 26 | */ 27 | public final class ProviderIdentifier extends UserIdentifier { 28 | private final String providerId; 29 | private final String providerUid; 30 | 31 | public ProviderIdentifier(@NonNull String providerId, @NonNull String providerUid) { 32 | UserRecord.checkProvider(providerId, providerUid); 33 | this.providerId = providerId; 34 | this.providerUid = providerUid; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "ProviderIdentifier(" + providerId + ", " + providerUid + ")"; 40 | } 41 | 42 | @Override 43 | void populate(@NonNull GetAccountInfoRequest payload) { 44 | payload.addFederatedUserId(providerId, providerUid); 45 | } 46 | 47 | @Override 48 | boolean matches(@NonNull UserRecord userRecord) { 49 | for (UserInfo userInfo : userRecord.getProviderData()) { 50 | if (providerId.equals(userInfo.getProviderId()) && providerUid.equals(userInfo.getUid())) { 51 | return true; 52 | } 53 | } 54 | return false; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/UidIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import com.google.firebase.auth.internal.GetAccountInfoRequest; 20 | import com.google.firebase.internal.NonNull; 21 | 22 | /** 23 | * Used for looking up an account by uid. 24 | * 25 | * @see {FirebaseAuth#getUsers} 26 | */ 27 | public final class UidIdentifier extends UserIdentifier { 28 | private final String uid; 29 | 30 | public UidIdentifier(@NonNull String uid) { 31 | UserRecord.checkUid(uid); 32 | this.uid = uid; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "UidIdentifier(" + uid + ")"; 38 | } 39 | 40 | @Override 41 | void populate(@NonNull GetAccountInfoRequest payload) { 42 | payload.addUid(uid); 43 | } 44 | 45 | @Override 46 | boolean matches(@NonNull UserRecord userRecord) { 47 | return uid.equals(userRecord.getUid()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/UserIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import com.google.firebase.auth.internal.GetAccountInfoRequest; 20 | import com.google.firebase.internal.NonNull; 21 | 22 | /** 23 | * Identifies a user to be looked up. 24 | */ 25 | public abstract class UserIdentifier { 26 | public abstract String toString(); 27 | 28 | abstract void populate(@NonNull GetAccountInfoRequest payload); 29 | 30 | abstract boolean matches(@NonNull UserRecord userRecord); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/Bcrypt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | import com.google.common.collect.ImmutableMap; 20 | import com.google.firebase.auth.UserImportHash; 21 | import java.util.Map; 22 | 23 | /** 24 | * Represents the Bcrypt password hashing algorithm. Can be used as an instance of 25 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 26 | */ 27 | public final class Bcrypt extends UserImportHash { 28 | 29 | private Bcrypt() { 30 | super("BCRYPT"); 31 | } 32 | 33 | public static Bcrypt getInstance() { 34 | return new Bcrypt(); 35 | } 36 | 37 | @Override 38 | protected Map getOptions() { 39 | return ImmutableMap.of(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/Hmac.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | import static com.google.common.base.Preconditions.checkArgument; 20 | 21 | import com.google.common.collect.ImmutableMap; 22 | import com.google.common.io.BaseEncoding; 23 | import com.google.firebase.auth.UserImportHash; 24 | import java.util.Map; 25 | 26 | abstract class Hmac extends UserImportHash { 27 | 28 | private final String key; 29 | 30 | Hmac(String name, Builder builder) { 31 | super(name); 32 | checkArgument(builder.key != null && builder.key.length > 0, 33 | "A non-empty key is required for HMAC algorithms"); 34 | this.key = BaseEncoding.base64().encode(builder.key); 35 | } 36 | 37 | @Override 38 | protected final Map getOptions() { 39 | return ImmutableMap.of("signerKey", key); 40 | } 41 | 42 | abstract static class Builder { 43 | private byte[] key; 44 | 45 | protected abstract T getInstance(); 46 | 47 | /** 48 | * Sets the signer key for the HMAC hash algorithm. Required field. 49 | * 50 | * @param key Signer key as a byte array. 51 | * @return This builder. 52 | */ 53 | public T setKey(byte[] key) { 54 | this.key = key; 55 | return getInstance(); 56 | } 57 | 58 | public abstract U build(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/HmacMd5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the HMAC MD5 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class HmacMd5 extends Hmac { 24 | 25 | private HmacMd5(Builder builder) { 26 | super("HMAC_MD5", builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends Hmac.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public HmacMd5 build() { 43 | return new HmacMd5(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/HmacSha1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the HMAC SHA1 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class HmacSha1 extends Hmac { 24 | 25 | private HmacSha1(Builder builder) { 26 | super("HMAC_SHA1", builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends Hmac.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public HmacSha1 build() { 43 | return new HmacSha1(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/HmacSha256.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the HMAC SHA256 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class HmacSha256 extends Hmac { 24 | 25 | private HmacSha256(Builder builder) { 26 | super("HMAC_SHA256", builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends Hmac.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public HmacSha256 build() { 43 | return new HmacSha256(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/HmacSha512.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the HMAC SHA512 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class HmacSha512 extends Hmac { 24 | 25 | private HmacSha512(Builder builder) { 26 | super("HMAC_SHA512", builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends Hmac.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public HmacSha512 build() { 43 | return new HmacSha512(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/Md5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the MD5 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class Md5 extends RepeatableHash { 24 | 25 | private Md5(Builder builder) { 26 | super("MD5", 0, 8192, builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends RepeatableHash.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public Md5 build() { 43 | return new Md5(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/Pbkdf2Sha256.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the PBKDF2 SHA256 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class Pbkdf2Sha256 extends RepeatableHash { 24 | 25 | private Pbkdf2Sha256(Builder builder) { 26 | super("PBKDF2_SHA256", 0, 120000, builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends RepeatableHash.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public Pbkdf2Sha256 build() { 43 | return new Pbkdf2Sha256(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/PbkdfSha1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the PBKDF SHA1 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class PbkdfSha1 extends RepeatableHash { 24 | 25 | private PbkdfSha1(Builder builder) { 26 | super("PBKDF_SHA1", 0, 120000, builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends RepeatableHash.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public PbkdfSha1 build() { 43 | return new PbkdfSha1(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/Sha1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the SHA1 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class Sha1 extends RepeatableHash { 24 | 25 | private Sha1(Builder builder) { 26 | super("SHA1", 1, 8192, builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends RepeatableHash.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public Sha1 build() { 43 | return new Sha1(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/Sha256.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the SHA256 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class Sha256 extends RepeatableHash { 24 | 25 | private Sha256(Builder builder) { 26 | super("SHA256", 1, 8192, builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends RepeatableHash.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public Sha256 build() { 43 | return new Sha256(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/hash/Sha512.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.hash; 18 | 19 | /** 20 | * Represents the SHA512 password hashing algorithm. Can be used as an instance of 21 | * {@link com.google.firebase.auth.UserImportHash} when importing users. 22 | */ 23 | public final class Sha512 extends RepeatableHash { 24 | 25 | private Sha512(Builder builder) { 26 | super("SHA512", 1, 8192, builder); 27 | } 28 | 29 | public static Builder builder() { 30 | return new Builder(); 31 | } 32 | 33 | public static class Builder extends RepeatableHash.Builder { 34 | 35 | private Builder() {} 36 | 37 | @Override 38 | protected Builder getInstance() { 39 | return this; 40 | } 41 | 42 | public Sha512 build() { 43 | return new Sha512(this); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/BatchDeleteResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.internal; 18 | 19 | import com.google.api.client.util.Key; 20 | import java.util.List; 21 | 22 | /** 23 | * Represents the response from Google identity Toolkit for a batch delete request. 24 | */ 25 | public class BatchDeleteResponse { 26 | 27 | @Key("errors") 28 | private List errors; 29 | 30 | public List getErrors() { 31 | return errors; 32 | } 33 | 34 | public static class ErrorInfo { 35 | @Key("index") 36 | private int index; 37 | 38 | @Key("message") 39 | private String message; 40 | 41 | // A 'localId' field also exists here, but is not currently exposed in the Admin SDK. 42 | 43 | public int getIndex() { 44 | return index; 45 | } 46 | 47 | public String getMessage() { 48 | return message; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/CryptoSigner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.internal; 18 | 19 | import com.google.firebase.auth.FirebaseAuthException; 20 | import com.google.firebase.internal.NonNull; 21 | import java.io.IOException; 22 | 23 | /** 24 | * Represents an object that can be used to cryptographically sign data. Mainly used for signing 25 | * custom JWT tokens issued to Firebase users. 26 | * 27 | *

See {@link com.google.firebase.auth.FirebaseAuth#createCustomToken(String)}. 28 | */ 29 | interface CryptoSigner { 30 | 31 | /** 32 | * Signs the given payload. 33 | * 34 | * @param payload Data to be signed 35 | * @return Signature as a byte array 36 | * @throws FirebaseAuthException If an error occurs during signing 37 | */ 38 | @NonNull 39 | byte[] sign(@NonNull byte[] payload) throws FirebaseAuthException; 40 | 41 | /** 42 | * Returns the client email of the service account used to sign payloads. 43 | * 44 | * @return A service account client email 45 | */ 46 | @NonNull 47 | String getAccount(); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/DownloadAccountResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.internal; 18 | 19 | import com.google.api.client.util.Key; 20 | import java.util.List; 21 | 22 | /** 23 | * JSON data binding for downloadAccountResponse messages sent by Google identity toolkit service. 24 | */ 25 | public class DownloadAccountResponse { 26 | 27 | @Key("users") 28 | private List users; 29 | 30 | @Key("nextPageToken") 31 | private String pageToken; 32 | 33 | public List getUsers() { 34 | return users; 35 | } 36 | 37 | public boolean hasUsers() { 38 | return users != null && !users.isEmpty(); 39 | } 40 | 41 | public String getPageToken() { 42 | return pageToken; 43 | } 44 | 45 | /** 46 | * JSON data binding for exported user records. 47 | */ 48 | public static final class User extends GetAccountInfoResponse.User { 49 | 50 | @Key("passwordHash") 51 | private String passwordHash; 52 | 53 | @Key("salt") 54 | private String passwordSalt; 55 | 56 | public String getPasswordHash() { 57 | return passwordHash; 58 | } 59 | 60 | public String getPasswordSalt() { 61 | return passwordSalt; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/ListProviderConfigsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.internal; 18 | 19 | import com.google.firebase.auth.ProviderConfig; 20 | import java.util.List; 21 | 22 | /** 23 | * Interface for config list response messages sent by Google identity toolkit service. 24 | */ 25 | public interface ListProviderConfigsResponse { 26 | 27 | public List getProviderConfigs(); 28 | 29 | public boolean hasProviderConfigs(); 30 | 31 | public String getPageToken(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/ListTenantsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.internal; 18 | 19 | import com.google.api.client.util.Key; 20 | import com.google.common.annotations.VisibleForTesting; 21 | import com.google.common.collect.ImmutableList; 22 | import com.google.firebase.auth.multitenancy.Tenant; 23 | import java.util.List; 24 | 25 | /** 26 | * JSON data binding for ListTenantsResponse messages sent by Google identity toolkit service. 27 | */ 28 | public final class ListTenantsResponse { 29 | 30 | @Key("tenants") 31 | private List tenants; 32 | 33 | @Key("pageToken") 34 | private String pageToken; 35 | 36 | @VisibleForTesting 37 | public ListTenantsResponse(List tenants, String pageToken) { 38 | this.tenants = tenants; 39 | this.pageToken = pageToken; 40 | } 41 | 42 | public ListTenantsResponse() { } 43 | 44 | public List getTenants() { 45 | return tenants == null ? ImmutableList.of() : tenants; 46 | } 47 | 48 | public boolean hasTenants() { 49 | return tenants != null && !tenants.isEmpty(); 50 | } 51 | 52 | public String getPageToken() { 53 | return pageToken == null ? "" : pageToken; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/UploadAccountResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.internal; 18 | 19 | import com.google.api.client.util.Key; 20 | import java.util.List; 21 | 22 | /** 23 | * Represents the response from identity toolkit for a user import request. 24 | */ 25 | public class UploadAccountResponse { 26 | 27 | @Key("error") 28 | private List errors; 29 | 30 | public List getErrors() { 31 | return errors; 32 | } 33 | 34 | public static class ErrorInfo { 35 | @Key("index") 36 | private int index; 37 | 38 | @Key("message") 39 | private String message; 40 | 41 | public int getIndex() { 42 | return index; 43 | } 44 | 45 | public String getMessage() { 46 | return message; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth.internal; 18 | 19 | import com.google.common.annotations.VisibleForTesting; 20 | import com.google.common.base.Strings; 21 | import com.google.firebase.internal.FirebaseProcessEnvironment; 22 | 23 | public class Utils { 24 | @VisibleForTesting 25 | public static final String AUTH_EMULATOR_HOST = "FIREBASE_AUTH_EMULATOR_HOST"; 26 | 27 | public static boolean isEmulatorMode() { 28 | return !Strings.isNullOrEmpty(getEmulatorHost()); 29 | } 30 | 31 | public static String getEmulatorHost() { 32 | return FirebaseProcessEnvironment.getenv(AUTH_EMULATOR_HOST); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/auth/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.auth.internal; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/DatabaseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | /** 20 | * This error is thrown when the Firebase Database library is unable to operate on the input it has 21 | * been given. 22 | */ 23 | public class DatabaseException extends RuntimeException { 24 | 25 | /** 26 | * For internal use 27 | * 28 | * @hide 29 | * @param message A human readable description of the error 30 | */ 31 | public DatabaseException(String message) { 32 | super(message); 33 | } 34 | 35 | /** 36 | * For internal use 37 | * 38 | * @hide 39 | * @param message A human readable description of the error 40 | * @param cause The underlying cause for this error 41 | */ 42 | public DatabaseException(String message, Throwable cause) { 43 | super(message, cause); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/Exclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** Marks a field as excluded from the Database. */ 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target({ElementType.METHOD, ElementType.FIELD}) 27 | public @interface Exclude {} 28 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/IgnoreExtraProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Properties that don't map to class fields are ignored when serializing to a class annotated with 26 | * this annotation. 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target({ElementType.TYPE}) 30 | public @interface IgnoreExtraProperties {} 31 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/PropertyName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** Marks a field to be renamed when serialized. */ 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target({ElementType.METHOD, ElementType.FIELD}) 27 | public @interface PropertyName { 28 | 29 | String value(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/ServerValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | // Server values 20 | 21 | import com.google.firebase.database.core.ServerValues; 22 | 23 | import java.util.Collections; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | /** Contains placeholder values to use when writing data to the Firebase Database. */ 28 | public class ServerValue { 29 | 30 | /** 31 | * A placeholder value for auto-populating the current timestamp (time since the Unix epoch, in 32 | * milliseconds) by the Firebase Database servers. 33 | */ 34 | public static final Map TIMESTAMP = createServerValuePlaceholder("timestamp"); 35 | 36 | private static Map createServerValuePlaceholder(String key) { 37 | Map result = new HashMap<>(); 38 | result.put(ServerValues.NAME_SUBKEY_SERVERVALUE, key); 39 | return Collections.unmodifiableMap(result); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/ThrowOnExtraProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Properties that don't map to class fields when serializing to a class annotated with this 26 | * annotation cause an exception to be thrown. 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target({ElementType.TYPE}) 30 | public @interface ThrowOnExtraProperties {} 31 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/ValueEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | /** 20 | * Classes implementing this interface can be used to receive events about data changes at a 21 | * location. Attach the listener to a location user {@link 22 | * DatabaseReference#addValueEventListener(ValueEventListener)}. 23 | */ 24 | public interface ValueEventListener { 25 | 26 | /** 27 | * This method will be called with a snapshot of the data at this location. It will also be called 28 | * each time that data changes. 29 | * 30 | * @param snapshot The current data at the location 31 | */ 32 | void onDataChange(DataSnapshot snapshot); 33 | 34 | /** 35 | * This method will be triggered in the event that this listener either failed at the server, or 36 | * is removed as a result of the security and Firebase Database rules. For more information on 37 | * securing your data, see: 38 | * 39 | * Security Quickstart 40 | * 41 | * @param error A description of the error that occurred 42 | */ 43 | void onCancelled(DatabaseError error); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/annotations/NotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An element annotated with this class indicates that it cannot be null. This is used by lint tools 26 | * to ensure callers properly check for null values before sending values as parameters. It can also 27 | * be used on return values to indicate to the caller that the return cannot be null so therefore no 28 | * null checks need to be made. 29 | */ 30 | @Retention(RetentionPolicy.CLASS) 31 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) 32 | public @interface NotNull { 33 | 34 | String value() default ""; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/annotations/Nullable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.annotations; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * An element annotated with this class indicates that it can be null. This is used by lint tools to 26 | * inform callers that they may send in null values as parameters. It can also be used on return 27 | * values to indicate to the caller that he or she must check for null. 28 | */ 29 | @Retention(RetentionPolicy.CLASS) 30 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) 31 | public @interface Nullable { 32 | 33 | String value() default ""; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/annotations/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.annotations; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/collection/LLRBBlackValueNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.collection; 18 | 19 | public class LLRBBlackValueNode extends LLRBValueNode { 20 | 21 | LLRBBlackValueNode(K key, V value, LLRBNode left, LLRBNode right) { 22 | super(key, value, left, right); 23 | } 24 | 25 | @Override 26 | protected Color getColor() { 27 | return Color.BLACK; 28 | } 29 | 30 | @Override 31 | public boolean isRed() { 32 | return false; 33 | } 34 | 35 | @Override 36 | protected LLRBValueNode copy(K key, V value, LLRBNode left, LLRBNode right) { 37 | K newKey = key == null ? this.getKey() : key; 38 | V newValue = value == null ? this.getValue() : value; 39 | LLRBNode newLeft = left == null ? this.getLeft() : left; 40 | LLRBNode newRight = right == null ? this.getRight() : right; 41 | return new LLRBBlackValueNode<>(newKey, newValue, newLeft, newRight); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/collection/LLRBRedValueNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.collection; 18 | 19 | import static com.google.firebase.database.collection.LLRBNode.Color.RED; 20 | 21 | public class LLRBRedValueNode extends LLRBValueNode { 22 | 23 | LLRBRedValueNode(K key, V value) { 24 | super(key, value, LLRBEmptyNode.getInstance(), LLRBEmptyNode.getInstance()); 25 | } 26 | 27 | LLRBRedValueNode(K key, V value, LLRBNode left, LLRBNode right) { 28 | super(key, value, left, right); 29 | } 30 | 31 | @Override 32 | protected Color getColor() { 33 | return RED; 34 | } 35 | 36 | @Override 37 | public boolean isRed() { 38 | return true; 39 | } 40 | 41 | @Override 42 | protected LLRBValueNode copy(K key, V value, LLRBNode left, LLRBNode right) { 43 | K newKey = key == null ? this.getKey() : key; 44 | V newValue = value == null ? this.getValue() : value; 45 | LLRBNode newLeft = left == null ? this.getLeft() : left; 46 | LLRBNode newRight = right == null ? this.getRight() : right; 47 | return new LLRBRedValueNode<>(newKey, newValue, newLeft, newRight); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/collection/StandardComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.collection; 18 | 19 | import java.util.Comparator; 20 | 21 | public class StandardComparator> implements Comparator { 22 | 23 | private static StandardComparator INSTANCE = new StandardComparator(); 24 | 25 | private StandardComparator() {} 26 | 27 | @SuppressWarnings("unchecked") 28 | public static > StandardComparator getComparator(Class clazz) { 29 | return INSTANCE; 30 | } 31 | 32 | @Override 33 | public int compare(A o1, A o2) { 34 | return o1.compareTo(o2); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/collection/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.collection; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/CompoundHash.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.connection; 18 | 19 | import java.util.Collections; 20 | import java.util.List; 21 | 22 | public class CompoundHash { 23 | 24 | private final List> posts; 25 | private final List hashes; 26 | 27 | public CompoundHash(List> posts, List hashes) { 28 | if (posts.size() != hashes.size() - 1) { 29 | throw new IllegalArgumentException( 30 | "Number of posts need to be n-1 for n hashes in " + "CompoundHash"); 31 | } 32 | this.posts = posts; 33 | this.hashes = hashes; 34 | } 35 | 36 | public List> getPosts() { 37 | return Collections.unmodifiableList(this.posts); 38 | } 39 | 40 | public List getHashes() { 41 | return Collections.unmodifiableList(this.hashes); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/ConnectionAuthTokenProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.connection; 18 | 19 | public interface ConnectionAuthTokenProvider { 20 | 21 | /** 22 | * Gets the token that should currently be used for authenticated requests. 23 | * 24 | * @param forceRefresh Pass true to get a new, up-to-date token rather than a (potentially 25 | * expired) cached token. 26 | * @param callback Callback to be notified after operation completes. 27 | */ 28 | void getToken(boolean forceRefresh, GetTokenCallback callback); 29 | 30 | interface GetTokenCallback { 31 | 32 | /** 33 | * Called if the getToken operation completed successfully. Token may be null if there is no 34 | * auth state currently. 35 | */ 36 | void onSuccess(String token); 37 | 38 | /** 39 | * Called if the getToken operation fails. 40 | * 41 | *

TODO: Figure out sane way to plumb errors through. 42 | */ 43 | void onError(String error); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.connection; 18 | 19 | class Constants { 20 | 21 | public static final String DOT_INFO_SERVERTIME_OFFSET = "serverTimeOffset"; 22 | 23 | public static final String WIRE_PROTOCOL_VERSION = "5"; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/ListenHashProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.connection; 18 | 19 | public interface ListenHashProvider { 20 | 21 | String getSimpleHash(); 22 | 23 | boolean shouldIncludeCompoundHash(); 24 | 25 | CompoundHash getCompoundHash(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/RangeMerge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.connection; 18 | 19 | import java.util.List; 20 | 21 | public class RangeMerge { 22 | 23 | private final List optExclusiveStart; 24 | private final List optInclusiveEnd; 25 | private final Object snap; 26 | 27 | public RangeMerge(List optExclusiveStart, List optInclusiveEnd, Object snap) { 28 | this.optExclusiveStart = optExclusiveStart; 29 | this.optInclusiveEnd = optInclusiveEnd; 30 | this.snap = snap; 31 | } 32 | 33 | public List getOptExclusiveStart() { 34 | return this.optExclusiveStart; 35 | } 36 | 37 | public List getOptInclusiveEnd() { 38 | return this.optInclusiveEnd; 39 | } 40 | 41 | public Object getSnap() { 42 | return this.snap; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/RequestResultCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.connection; 18 | 19 | public interface RequestResultCallback { 20 | 21 | void onRequestResult(String optErrorCode, String optErrorMessage); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.connection; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/connection/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.connection.util; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | import com.google.firebase.database.snapshot.ChildKey; 20 | 21 | public class Constants { 22 | 23 | public static final ChildKey DOT_INFO = ChildKey.fromString(".info"); 24 | public static final ChildKey DOT_INFO_SERVERTIME_OFFSET = ChildKey.fromString("serverTimeOffset"); 25 | public static final ChildKey DOT_INFO_AUTHENTICATED = ChildKey.fromString("authenticated"); 26 | public static final ChildKey DOT_INFO_CONNECTED = ChildKey.fromString("connected"); 27 | 28 | public static final String WIRE_PROTOCOL_VERSION = "5"; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/EventRegistrationZombieListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | public interface EventRegistrationZombieListener { 20 | 21 | void onZombied(EventRegistration zombiedInstance); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/EventTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | /** 20 | * This interface defines the operations required for the Firebase Database library to fire 21 | * callbacks. Most users should not need this interface, it is only applicable if you are 22 | * customizing the way in which callbacks are triggered. 23 | */ 24 | public interface EventTarget { 25 | 26 | /** 27 | * This method will be called from the library's event loop whenever there is a new callback to be 28 | * triggered. 29 | * 30 | * @param r The callback to be run 31 | */ 32 | void postEvent(Runnable r); 33 | 34 | void shutdown(); 35 | 36 | void restart(); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/Platform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | import com.google.firebase.database.connection.ConnectionContext; 20 | import com.google.firebase.database.connection.HostInfo; 21 | import com.google.firebase.database.connection.PersistentConnection; 22 | import com.google.firebase.database.core.persistence.PersistenceManager; 23 | 24 | import java.util.concurrent.ScheduledExecutorService; 25 | 26 | public interface Platform { 27 | 28 | String DEVICE = "AdminJava"; 29 | 30 | EventTarget newEventTarget(Context ctx); 31 | 32 | RunLoop newRunLoop(Context ctx); 33 | 34 | AuthTokenProvider newAuthTokenProvider(ScheduledExecutorService executorService); 35 | 36 | PersistentConnection newPersistentConnection( 37 | Context context, 38 | ConnectionContext connectionContext, 39 | HostInfo info, 40 | PersistentConnection.Delegate delegate); 41 | 42 | String getUserAgent(Context ctx); 43 | 44 | String getPlatformVersion(); 45 | 46 | PersistenceManager createPersistenceManager(Context ctx, String firebaseId); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/RunLoop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | import java.util.concurrent.ScheduledFuture; 20 | 21 | /** 22 | * This interface defines the required functionality for the Firebase Database library's run loop. 23 | * Most users will not need this interface. However, if you are customizing how the Firebase 24 | * Database schedules its internal operations this is the interface that should be implemented. 25 | */ 26 | @SuppressWarnings("rawtypes") 27 | public interface RunLoop { 28 | 29 | /** 30 | * Append this operation to the queue. 31 | * 32 | * @param r The operation to run 33 | */ 34 | void scheduleNow(Runnable r); 35 | 36 | /** 37 | * Schedule this operation to run after the specified delay. 38 | * 39 | * @param r The operation to run 40 | * @param milliseconds The delay, in milliseconds 41 | * @return A Future that can be used to cancel the operation if it has not yet started executing 42 | */ 43 | ScheduledFuture schedule(Runnable r, long milliseconds); 44 | 45 | void shutdown(); 46 | 47 | void restart(); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/SnapshotHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | import com.google.firebase.database.snapshot.EmptyNode; 20 | import com.google.firebase.database.snapshot.Node; 21 | 22 | public class SnapshotHolder { 23 | 24 | private Node rootNode; 25 | 26 | SnapshotHolder() { 27 | rootNode = EmptyNode.Empty(); 28 | } 29 | 30 | public SnapshotHolder(Node node) { 31 | rootNode = node; 32 | } 33 | 34 | public Node getRootNode() { 35 | return rootNode; 36 | } 37 | 38 | public Node getNode(Path path) { 39 | return rootNode.getChild(path); 40 | } 41 | 42 | public void update(Path path, Node node) { 43 | rootNode = rootNode.updateChild(path, node); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/Tag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | public class Tag { 20 | 21 | private final long tagNumber; 22 | 23 | public Tag(long tagNumber) { 24 | this.tagNumber = tagNumber; 25 | } 26 | 27 | public long getTagNumber() { 28 | return this.tagNumber; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Tag{" + "tagNumber=" + tagNumber + '}'; 34 | } 35 | 36 | @Override 37 | public boolean equals(Object o) { 38 | if (this == o) { 39 | return true; 40 | } 41 | if (o == null || getClass() != o.getClass()) { 42 | return false; 43 | } 44 | 45 | Tag tag = (Tag) o; 46 | 47 | if (tagNumber != tag.tagNumber) { 48 | return false; 49 | } 50 | 51 | return true; 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return (int) (tagNumber ^ (tagNumber >>> 32)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/operation/ListenComplete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.operation; 18 | 19 | import com.google.firebase.database.core.Path; 20 | import com.google.firebase.database.snapshot.ChildKey; 21 | 22 | public class ListenComplete extends Operation { 23 | 24 | public ListenComplete(OperationSource source, Path path) { 25 | super(OperationType.ListenComplete, source, path); 26 | assert !source.isFromUser() : "Can't have a listen complete from a user source"; 27 | } 28 | 29 | @Override 30 | public Operation operationForChild(ChildKey childKey) { 31 | if (this.path.isEmpty()) { 32 | return new ListenComplete(this.source, Path.getEmptyPath()); 33 | } else { 34 | return new ListenComplete(this.source, this.path.popFront()); 35 | } 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return String.format("ListenComplete { path=%s, source=%s }", getPath(), getSource()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/operation/Operation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.operation; 18 | 19 | import com.google.firebase.database.core.Path; 20 | import com.google.firebase.database.snapshot.ChildKey; 21 | 22 | public abstract class Operation { 23 | 24 | protected final OperationType type; 25 | protected final OperationSource source; 26 | protected final Path path; 27 | 28 | protected Operation(OperationType type, OperationSource source, Path path) { 29 | this.type = type; 30 | this.source = source; 31 | this.path = path; 32 | } 33 | 34 | public Path getPath() { 35 | return this.path; 36 | } 37 | 38 | public OperationSource getSource() { 39 | return this.source; 40 | } 41 | 42 | public OperationType getType() { 43 | return this.type; 44 | } 45 | 46 | public abstract Operation operationForChild(ChildKey childKey); 47 | 48 | public enum OperationType { 49 | Overwrite, 50 | Merge, 51 | AckUserWrite, 52 | ListenComplete 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/operation/Overwrite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.operation; 18 | 19 | import com.google.firebase.database.core.Path; 20 | import com.google.firebase.database.snapshot.ChildKey; 21 | import com.google.firebase.database.snapshot.Node; 22 | 23 | public class Overwrite extends Operation { 24 | 25 | private final Node snapshot; 26 | 27 | public Overwrite(OperationSource source, Path path, Node snapshot) { 28 | super(OperationType.Overwrite, source, path); 29 | this.snapshot = snapshot; 30 | } 31 | 32 | public Node getSnapshot() { 33 | return this.snapshot; 34 | } 35 | 36 | @Override 37 | public Operation operationForChild(ChildKey childKey) { 38 | if (this.path.isEmpty()) { 39 | return new Overwrite( 40 | this.source, Path.getEmptyPath(), this.snapshot.getImmediateChild(childKey)); 41 | } else { 42 | return new Overwrite(this.source, this.path.popFront(), this.snapshot); 43 | } 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return String.format( 49 | "Overwrite { path=%s, source=%s, snapshot=%s }", getPath(), getSource(), this.snapshot); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/operation/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.core.operation; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.core; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/persistence/CachePolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.persistence; 18 | 19 | public interface CachePolicy { 20 | 21 | CachePolicy NONE = 22 | new CachePolicy() { 23 | @Override 24 | public boolean shouldPrune(long currentSizeBytes, long countOfPrunableQueries) { 25 | return false; 26 | } 27 | 28 | @Override 29 | public boolean shouldCheckCacheSize(long serverUpdatesSinceLastCheck) { 30 | return false; 31 | } 32 | 33 | @Override 34 | public float getPercentOfQueriesToPruneAtOnce() { 35 | return 0; 36 | } 37 | 38 | @Override 39 | public long getMaxNumberOfQueriesToKeep() { 40 | return Long.MAX_VALUE; 41 | } 42 | }; 43 | 44 | boolean shouldPrune(long currentSizeBytes, long countOfPrunableQueries); 45 | 46 | boolean shouldCheckCacheSize(long serverUpdatesSinceLastCheck); 47 | 48 | float getPercentOfQueriesToPruneAtOnce(); 49 | 50 | long getMaxNumberOfQueriesToKeep(); 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/persistence/LRUCachePolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.persistence; 18 | 19 | public class LRUCachePolicy implements CachePolicy { 20 | 21 | private static final long SERVER_UPDATES_BETWEEN_CACHE_SIZE_CHECKS = 1000; 22 | private static final long MAX_NUMBER_OF_PRUNABLE_QUERIES_TO_KEEP = 1000; 23 | private static final float PERCENT_OF_QUERIES_TO_PRUNE_AT_ONCE = 24 | 0.2f; // 20% at a time until we're below our max. 25 | 26 | public final long maxSizeBytes; 27 | 28 | public LRUCachePolicy(long maxSizeBytes) { 29 | this.maxSizeBytes = maxSizeBytes; 30 | } 31 | 32 | @Override 33 | public boolean shouldPrune(long currentSizeBytes, long countOfPrunableQueries) { 34 | return currentSizeBytes > maxSizeBytes 35 | || countOfPrunableQueries > MAX_NUMBER_OF_PRUNABLE_QUERIES_TO_KEEP; 36 | } 37 | 38 | @Override 39 | public boolean shouldCheckCacheSize(long serverUpdatesSinceLastCheck) { 40 | return serverUpdatesSinceLastCheck > SERVER_UPDATES_BETWEEN_CACHE_SIZE_CHECKS; 41 | } 42 | 43 | @Override 44 | public float getPercentOfQueriesToPruneAtOnce() { 45 | return PERCENT_OF_QUERIES_TO_PRUNE_AT_ONCE; 46 | } 47 | 48 | @Override 49 | public long getMaxNumberOfQueriesToKeep() { 50 | return MAX_NUMBER_OF_PRUNABLE_QUERIES_TO_KEEP; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/persistence/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.core.persistence; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/utilities/Predicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.utilities; 18 | 19 | public interface Predicate { 20 | 21 | Predicate TRUE = 22 | new Predicate() { 23 | @Override 24 | public boolean evaluate(Object object) { 25 | return true; 26 | } 27 | }; 28 | 29 | boolean evaluate(T object); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/utilities/TreeNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.utilities; 18 | 19 | import com.google.firebase.database.snapshot.ChildKey; 20 | 21 | import java.util.HashMap; 22 | import java.util.Iterator; 23 | import java.util.Map; 24 | 25 | public class TreeNode { 26 | 27 | public Map> children; 28 | public T value; 29 | 30 | public TreeNode() { 31 | children = new HashMap<>(); 32 | } 33 | 34 | String toString(String prefix) { 35 | String result = prefix + ": " + value + "\n"; 36 | if (children.isEmpty()) { 37 | return result + prefix + ""; 38 | } else { 39 | Iterator>> iter = children.entrySet().iterator(); 40 | while (iter.hasNext()) { 41 | Map.Entry> entry = iter.next(); 42 | result += prefix + entry.getKey() + ":\n" + entry.getValue().toString(prefix + "\t") + "\n"; 43 | } 44 | } 45 | return result; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/utilities/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.core.utilities; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/view/CancelEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.view; 18 | 19 | import com.google.firebase.database.DatabaseError; 20 | import com.google.firebase.database.core.EventRegistration; 21 | import com.google.firebase.database.core.Path; 22 | 23 | public class CancelEvent implements Event { 24 | 25 | private final Path path; 26 | private final EventRegistration eventRegistration; 27 | private final DatabaseError error; 28 | 29 | public CancelEvent(EventRegistration eventRegistration, DatabaseError error, Path path) { 30 | this.eventRegistration = eventRegistration; 31 | this.path = path; 32 | this.error = error; 33 | } 34 | 35 | @Override 36 | public Path getPath() { 37 | return this.path; 38 | } 39 | 40 | @Override 41 | public void fire() { 42 | this.eventRegistration.fireCancelEvent(this.error); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return this.getPath() + ":" + "CANCEL"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/view/Event.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.view; 18 | 19 | import com.google.firebase.database.core.Path; 20 | 21 | public interface Event { 22 | 23 | Path getPath(); 24 | 25 | void fire(); 26 | 27 | @Override 28 | String toString(); 29 | 30 | enum EventType { 31 | // The order is important here and reflects the order events should be raised in 32 | CHILD_REMOVED, 33 | CHILD_ADDED, 34 | CHILD_MOVED, 35 | CHILD_CHANGED, 36 | VALUE 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/view/ViewCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.view; 18 | 19 | import com.google.firebase.database.snapshot.IndexedNode; 20 | import com.google.firebase.database.snapshot.Node; 21 | 22 | public class ViewCache { 23 | 24 | private final CacheNode eventSnap; 25 | private final CacheNode serverSnap; 26 | 27 | public ViewCache(CacheNode eventSnap, CacheNode serverSnap) { 28 | this.eventSnap = eventSnap; 29 | this.serverSnap = serverSnap; 30 | } 31 | 32 | public ViewCache updateEventSnap(IndexedNode eventSnap, boolean complete, boolean filtered) { 33 | return new ViewCache(new CacheNode(eventSnap, complete, filtered), this.serverSnap); 34 | } 35 | 36 | public ViewCache updateServerSnap(IndexedNode serverSnap, boolean complete, boolean filtered) { 37 | return new ViewCache(this.eventSnap, new CacheNode(serverSnap, complete, filtered)); 38 | } 39 | 40 | public CacheNode getEventCache() { 41 | return this.eventSnap; 42 | } 43 | 44 | public Node getCompleteEventSnap() { 45 | return (this.eventSnap.isFullyInitialized()) ? this.eventSnap.getNode() : null; 46 | } 47 | 48 | public CacheNode getServerCache() { 49 | return this.serverSnap; 50 | } 51 | 52 | public Node getCompleteServerSnap() { 53 | return this.serverSnap.isFullyInitialized() ? this.serverSnap.getNode() : null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/view/filter/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.core.view.filter; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/core/view/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.core.view; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/snapshot/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.snapshot; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.util; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/utilities/Clock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.utilities; 18 | 19 | // Abstract clock that can be replaced in unit tests. 20 | public interface Clock { 21 | 22 | long millis(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/utilities/DefaultClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.utilities; 18 | 19 | public class DefaultClock implements Clock { 20 | 21 | @Override 22 | public long millis() { 23 | return System.currentTimeMillis(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/utilities/OffsetClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.utilities; 18 | 19 | public class OffsetClock implements Clock { 20 | 21 | private final Clock baseClock; 22 | private long offset = 0; 23 | 24 | public OffsetClock(Clock baseClock, long offset) { 25 | this.baseClock = baseClock; 26 | this.offset = offset; 27 | } 28 | 29 | public void setOffset(long offset) { 30 | this.offset = offset; 31 | } 32 | 33 | @Override 34 | public long millis() { 35 | return baseClock.millis() + offset; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/utilities/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.utilities; 18 | 19 | public class Pair { 20 | 21 | private final T first; 22 | private final U second; 23 | 24 | public Pair(T first, U second) { 25 | this.first = first; 26 | this.second = second; 27 | } 28 | 29 | public T getFirst() { 30 | return first; 31 | } 32 | 33 | public U getSecond() { 34 | return second; 35 | } 36 | 37 | @Override 38 | @SuppressWarnings("rawtypes") 39 | public boolean equals(Object o) { 40 | if (this == o) { 41 | return true; 42 | } 43 | if (o == null || getClass() != o.getClass()) { 44 | return false; 45 | } 46 | 47 | Pair pair = (Pair) o; 48 | 49 | if (first != null ? !first.equals(pair.first) : pair.first != null) { 50 | return false; 51 | } 52 | if (second != null ? !second.equals(pair.second) : pair.second != null) { 53 | return false; 54 | } 55 | 56 | return true; 57 | } 58 | 59 | @Override 60 | public int hashCode() { 61 | int result = first != null ? first.hashCode() : 0; 62 | result = 31 * result + (second != null ? second.hashCode() : 0); 63 | return result; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return "Pair(" + first + "," + second + ")"; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/utilities/ParsedUrl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.utilities; 18 | 19 | import com.google.firebase.database.core.Path; 20 | import com.google.firebase.database.core.RepoInfo; 21 | 22 | /** User: greg Date: 5/15/13 Time: 1:18 PM */ 23 | public class ParsedUrl { 24 | 25 | public RepoInfo repoInfo; 26 | public Path path; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/utilities/encoding/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.utilities.encoding; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/database/utilities/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.database.utilities; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/iid/FirebaseInstanceIdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.iid; 18 | 19 | import com.google.firebase.FirebaseException; 20 | 21 | /** 22 | * Represents an exception encountered while interacting with the Firebase instance ID service. 23 | */ 24 | public final class FirebaseInstanceIdException extends FirebaseException { 25 | 26 | FirebaseInstanceIdException(FirebaseException base, String message) { 27 | super(base.getErrorCode(), message, base.getCause(), base.getHttpResponse()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/ApplicationDefaultCredentialsProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | import com.google.auth.oauth2.GoogleCredentials; 20 | import java.io.IOException; 21 | 22 | /** 23 | * Provides a hook to override application default credentials (ADC) lookup for tests. ADC has 24 | * a dependency on environment variables, and Java famously doesn't support environment variable 25 | * manipulation at runtime. With this class, the test cases that require ADC has a way to register 26 | * their own mock credentials as ADC. 27 | * 28 | *

Once we are able to upgrade to Mockito 3.x (requires Java 8+), we can drop this class 29 | * altogether, and use Mockito tools to mock the behavior of the GoogleCredentials static methods. 30 | */ 31 | public class ApplicationDefaultCredentialsProvider { 32 | 33 | private static GoogleCredentials cachedCredentials; 34 | 35 | public static GoogleCredentials getApplicationDefault() throws IOException { 36 | if (cachedCredentials != null) { 37 | return cachedCredentials; 38 | } 39 | 40 | return GoogleCredentials.getApplicationDefault(); 41 | } 42 | 43 | public static void setApplicationDefault(GoogleCredentials credentials) { 44 | cachedCredentials = credentials; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/CallableOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | import static com.google.common.base.Preconditions.checkNotNull; 20 | 21 | import com.google.api.core.ApiFuture; 22 | import com.google.firebase.FirebaseApp; 23 | import com.google.firebase.ImplFirebaseTrampolines; 24 | import java.util.concurrent.Callable; 25 | 26 | /** 27 | * An operation that can be invoked synchronously or asynchronously. Subclasses can specify 28 | * the return type and a specific exception type to be thrown. 29 | */ 30 | public abstract class CallableOperation implements Callable { 31 | 32 | protected abstract T execute() throws V; 33 | 34 | @Override 35 | public final T call() throws V { 36 | return execute(); 37 | } 38 | 39 | /** 40 | * Run this operation asynchronously on the main thread pool of the specified {@link FirebaseApp}. 41 | * 42 | * @param app A non-null {@link FirebaseApp}. 43 | * @return An {@code ApiFuture}. 44 | */ 45 | public final ApiFuture callAsync(@NonNull FirebaseApp app) { 46 | checkNotNull(app); 47 | return ImplFirebaseTrampolines.submitCallable(app, this); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/EmulatorCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | import com.google.auth.oauth2.AccessToken; 20 | import com.google.auth.oauth2.GoogleCredentials; 21 | import com.google.common.collect.ImmutableMap; 22 | 23 | import java.io.IOException; 24 | import java.util.Date; 25 | import java.util.List; 26 | import java.util.Map; 27 | import java.util.concurrent.TimeUnit; 28 | 29 | /** 30 | * A Mock Credentials implementation that can be used with the Emulator Suite 31 | */ 32 | public final class EmulatorCredentials extends GoogleCredentials { 33 | 34 | public EmulatorCredentials() { 35 | super(newToken()); 36 | } 37 | 38 | private static AccessToken newToken() { 39 | return new AccessToken("owner", 40 | new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1))); 41 | } 42 | 43 | @Override 44 | public AccessToken refreshAccessToken() { 45 | return newToken(); 46 | } 47 | 48 | @Override 49 | public Map> getRequestMetadata() throws IOException { 50 | return ImmutableMap.of(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/FirebaseProcessEnvironment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | import com.google.common.base.Strings; 20 | import java.util.Map; 21 | import java.util.concurrent.ConcurrentHashMap; 22 | 23 | /** 24 | * A utility for overriding environment variables during tests. 25 | */ 26 | public class FirebaseProcessEnvironment { 27 | 28 | private static final Map localCache = new ConcurrentHashMap<>(); 29 | 30 | public static String getenv(String name) { 31 | String cachedValue = localCache.get(name); 32 | if (!Strings.isNullOrEmpty(cachedValue)) { 33 | return cachedValue; 34 | } 35 | 36 | return System.getenv(name); 37 | } 38 | 39 | public static void setenv(String name, String value) { 40 | localCache.put(name, value); 41 | } 42 | 43 | public static void clearCache() { 44 | localCache.clear(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/GuardedBy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | /** Indicates that the given field can only be accessed when holding a particular lock. */ 20 | // TODO: Remove this if we can find a safe alternative or take the dependency. 21 | public @interface GuardedBy { 22 | 23 | /** Name of the variable guarded by this annotation. */ 24 | String value(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/HttpErrorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | import com.google.api.client.http.HttpResponseException; 20 | import com.google.firebase.FirebaseException; 21 | import com.google.firebase.IncomingHttpResponse; 22 | import java.io.IOException; 23 | 24 | /** 25 | * An interface for handling all sorts of exceptions that may occur while making an HTTP call and 26 | * converting them into some instance of FirebaseException. 27 | */ 28 | public interface HttpErrorHandler { 29 | 30 | /** 31 | * Handle any low-level transport and initialization errors. 32 | */ 33 | T handleIOException(IOException e); 34 | 35 | /** 36 | * Handle HTTP response exceptions (caused by HTTP error responses). 37 | */ 38 | T handleHttpResponseException(HttpResponseException e, IncomingHttpResponse response); 39 | 40 | /** 41 | * Handle any errors that may occur while parsing the response payload. 42 | */ 43 | T handleParseException(IOException e, IncomingHttpResponse response); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/ListenableFuture2ApiFuture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | import com.google.api.core.ApiFuture; 20 | import com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture; 21 | import com.google.common.util.concurrent.ListenableFuture; 22 | 23 | /** 24 | * Adapter from Guava ListenableFuture to GAX ApiFuture. 25 | */ 26 | public class ListenableFuture2ApiFuture extends SimpleForwardingListenableFuture implements 27 | ApiFuture { 28 | 29 | public ListenableFuture2ApiFuture(ListenableFuture delegate) { 30 | super(delegate); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/NonNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | /** Indicates that a value cannot be null. */ 20 | public @interface NonNull {} 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/Nullable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.internal; 18 | 19 | /** Indicates that a value may be null. */ 20 | public @interface Nullable {} 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.internal; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/BatchResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.messaging; 18 | 19 | import com.google.firebase.internal.NonNull; 20 | import java.util.List; 21 | 22 | /** 23 | * Response from an operation that sends FCM messages to multiple recipients. 24 | * See {@link FirebaseMessaging#sendAll(List)} and {@link 25 | * FirebaseMessaging#sendMulticast(MulticastMessage)}. 26 | */ 27 | public interface BatchResponse { 28 | 29 | @NonNull 30 | List getResponses(); 31 | 32 | int getSuccessCount(); 33 | 34 | int getFailureCount(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/BatchResponseImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.messaging; 18 | 19 | import com.google.common.collect.ImmutableList; 20 | import com.google.firebase.internal.NonNull; 21 | 22 | import java.util.List; 23 | 24 | /** 25 | * Response from an operation that sends FCM messages to multiple recipients. 26 | * See {@link FirebaseMessaging#sendAll(List)} and {@link 27 | * FirebaseMessaging#sendMulticast(MulticastMessage)}. 28 | */ 29 | class BatchResponseImpl implements BatchResponse { 30 | 31 | private final List responses; 32 | private final int successCount; 33 | 34 | BatchResponseImpl(List responses) { 35 | this.responses = ImmutableList.copyOf(responses); 36 | int successCount = 0; 37 | for (SendResponse response : this.responses) { 38 | if (response.isSuccessful()) { 39 | successCount++; 40 | } 41 | } 42 | this.successCount = successCount; 43 | } 44 | 45 | @NonNull 46 | public List getResponses() { 47 | return responses; 48 | } 49 | 50 | public int getSuccessCount() { 51 | return successCount; 52 | } 53 | 54 | public int getFailureCount() { 55 | return responses.size() - successCount; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/FcmOptionsUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | package com.google.firebase.messaging; 16 | 17 | import static com.google.common.base.Preconditions.checkArgument; 18 | 19 | import java.util.regex.Pattern; 20 | 21 | final class FcmOptionsUtil { 22 | 23 | /** 24 | * Pattern matching a valid analytics labels. 25 | */ 26 | private static final Pattern ANALYTICS_LABEL_REGEX = Pattern.compile("^[a-zA-Z0-9-_.~%]{0,50}$"); 27 | 28 | /** 29 | * Returns false if the supplied {@code analyticsLabel} has a disallowed format. 30 | */ 31 | private static boolean isValid(String analyticsLabel) { 32 | return ANALYTICS_LABEL_REGEX.matcher(analyticsLabel).matches(); 33 | } 34 | 35 | /** 36 | * Validates the format of the supplied label. 37 | * 38 | * @throws IllegalArgumentException If the label is non-null and has a disallowed format. 39 | */ 40 | static void checkAnalyticsLabel(String analyticsLabel) { 41 | checkArgument( 42 | analyticsLabel == null || isValid(analyticsLabel), 43 | "Analytics label must have format matching'^[a-zA-Z0-9-_.~%]{1,50}$"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/FirebaseMessagingClient.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.messaging; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * An interface for sending Firebase Cloud Messaging (FCM) messages. 7 | */ 8 | interface FirebaseMessagingClient { 9 | 10 | /** 11 | * Sends the given message with FCM. 12 | * 13 | * @param message A non-null {@link Message} to be sent. 14 | * @param dryRun A boolean indicating whether to perform a dry run (validation only) of the send. 15 | * @return A message ID string. 16 | * @throws FirebaseMessagingException If an error occurs while handing the message off to FCM for 17 | * delivery. 18 | */ 19 | String send(Message message, boolean dryRun) throws FirebaseMessagingException; 20 | 21 | /** 22 | * Sends all the messages in the given list with FCM. 23 | * 24 | * @param messages A non-null, non-empty list of messages. 25 | * @param dryRun A boolean indicating whether to perform a dry run (validation only) of the send. 26 | * @return A {@link BatchResponse} indicating the result of the operation. 27 | * @throws FirebaseMessagingException If an error occurs while handing the messages off to FCM for 28 | * delivery. 29 | */ 30 | BatchResponse sendAll(List messages, boolean dryRun) throws FirebaseMessagingException; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/InstanceIdClient.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.messaging; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * An interface for managing FCM topic subscriptions. 7 | */ 8 | interface InstanceIdClient { 9 | 10 | /** 11 | * Subscribes a list of registration tokens to a topic. 12 | * 13 | * @param registrationTokens A non-null, non-empty list of device registration tokens. 14 | * @param topic Name of the topic to subscribe to. May contain the {@code /topics/} prefix. 15 | * @return A {@link TopicManagementResponse}. 16 | */ 17 | TopicManagementResponse subscribeToTopic( 18 | String topic, List registrationTokens) throws FirebaseMessagingException; 19 | 20 | /** 21 | * Unsubscribes a list of registration tokens from a topic. 22 | * 23 | * @param registrationTokens A non-null, non-empty list of device registration tokens. 24 | * @param topic Name of the topic to unsubscribe from. May contain the {@code /topics/} prefix. 25 | * @return A {@link TopicManagementResponse}. 26 | */ 27 | TopicManagementResponse unsubscribeFromTopic( 28 | String topic, List registrationTokens) throws FirebaseMessagingException; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/MessagingErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.messaging; 2 | 3 | /** 4 | * Error codes that can be raised by the Cloud Messaging APIs. 5 | */ 6 | public enum MessagingErrorCode { 7 | 8 | /** 9 | * APNs certificate or web push auth key was invalid or missing. 10 | */ 11 | THIRD_PARTY_AUTH_ERROR, 12 | 13 | /** 14 | * One or more arguments specified in the request were invalid. 15 | */ 16 | INVALID_ARGUMENT, 17 | 18 | /** 19 | * Internal server error. 20 | */ 21 | INTERNAL, 22 | 23 | /** 24 | * Sending limit exceeded for the message target. 25 | */ 26 | QUOTA_EXCEEDED, 27 | 28 | /** 29 | * The authenticated sender ID is different from the sender ID for the registration token. 30 | */ 31 | SENDER_ID_MISMATCH, 32 | 33 | /** 34 | * Cloud Messaging service is temporarily unavailable. 35 | */ 36 | UNAVAILABLE, 37 | 38 | /** 39 | * App instance was unregistered from FCM. This usually means that the token used is no longer 40 | * valid and a new one must be used. 41 | */ 42 | UNREGISTERED, 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/WebpushFcmOptions.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.messaging; 2 | 3 | import com.google.api.client.util.Key; 4 | 5 | /** 6 | * Represents options for features provided by the FCM SDK for Web. 7 | * Can be included in {@link WebpushConfig}. Instances of this class are thread-safe and immutable. 8 | */ 9 | public final class WebpushFcmOptions { 10 | 11 | @Key("link") 12 | private final String link; 13 | 14 | private WebpushFcmOptions(Builder builder) { 15 | this.link = builder.link; 16 | } 17 | 18 | /** 19 | * Creates a new {@code WebpushFcmOptions} using given link. 20 | * 21 | * @param link The link to open when the user clicks on the notification. 22 | * For all URL values, HTTPS is required. 23 | */ 24 | public static WebpushFcmOptions withLink(String link) { 25 | return new Builder().setLink(link).build(); 26 | } 27 | 28 | /** 29 | * Creates a new {@link WebpushFcmOptions.Builder}. 30 | * 31 | * @return An {@link WebpushFcmOptions.Builder} instance. 32 | */ 33 | public static Builder builder() { 34 | return new WebpushFcmOptions.Builder(); 35 | } 36 | 37 | public static class Builder { 38 | 39 | private String link; 40 | 41 | private Builder() {} 42 | 43 | /** 44 | * @param link The link to open when the user clicks on the notification. 45 | * For all URL values, HTTPS is required. 46 | * @return This builder 47 | */ 48 | public Builder setLink(String link) { 49 | this.link = link; 50 | return this; 51 | } 52 | 53 | /** 54 | * Creates a new {@link WebpushFcmOptions} instance from the parameters set on this builder. 55 | * 56 | * @return A new {@link WebpushFcmOptions} instance. 57 | */ 58 | public WebpushFcmOptions build() { 59 | return new WebpushFcmOptions(this); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/internal/MessagingServiceResponse.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.messaging.internal; 2 | 3 | import com.google.api.client.util.Key; 4 | 5 | /** 6 | * The DTO for parsing success responses from the FCM service. 7 | */ 8 | public class MessagingServiceResponse { 9 | 10 | @Key("name") 11 | private String messageId; 12 | 13 | public String getMessageId() { 14 | return this.messageId; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/messaging/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.messaging.internal; 21 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/projectmanagement/FirebaseProjectManagementException.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.google.firebase.projectmanagement; 17 | 18 | import com.google.firebase.ErrorCode; 19 | import com.google.firebase.FirebaseException; 20 | import com.google.firebase.IncomingHttpResponse; 21 | import com.google.firebase.database.annotations.Nullable; 22 | import com.google.firebase.internal.NonNull; 23 | 24 | /** 25 | * An exception encountered while interacting with the Firebase Project Management Service. 26 | */ 27 | public final class FirebaseProjectManagementException extends FirebaseException { 28 | 29 | FirebaseProjectManagementException(@NonNull FirebaseException base) { 30 | this(base, base.getMessage()); 31 | } 32 | 33 | FirebaseProjectManagementException(@NonNull FirebaseException base, @NonNull String message) { 34 | super(base.getErrorCode(), message, base.getCause(), base.getHttpResponse()); 35 | } 36 | 37 | FirebaseProjectManagementException( 38 | @NonNull ErrorCode code, @NonNull String message, @Nullable IncomingHttpResponse response) { 39 | super(code, message, null, response); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/projectmanagement/Scheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.projectmanagement; 18 | 19 | /** 20 | * Schedules a task to be executed after a specified delay. 21 | */ 22 | interface Scheduler { 23 | 24 | void schedule(Runnable runnable, long delayMillis); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/projectmanagement/ShaCertificateType.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.google.firebase.projectmanagement; 17 | 18 | /** 19 | * Enum denoting types of SHA certificates currently supported by Firebase. 20 | */ 21 | public enum ShaCertificateType { 22 | /** Certificate generated by SHA-1 hashing algorithm. */ 23 | SHA_1, 24 | /** Certificate generated by SHA-256 hashing algorithm. */ 25 | SHA_256 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.remoteconfig; 18 | 19 | import com.google.firebase.remoteconfig.internal.TemplateResponse.ListVersionsResponse; 20 | 21 | /** 22 | * An interface for managing Firebase Remote Config templates. 23 | */ 24 | interface FirebaseRemoteConfigClient { 25 | 26 | /** 27 | * Gets the current active version of the Remote Config template. 28 | * 29 | * @return A {@link Template}. 30 | * @throws FirebaseRemoteConfigException If an error occurs while getting the template. 31 | */ 32 | Template getTemplate() throws FirebaseRemoteConfigException; 33 | 34 | Template getTemplateAtVersion(String versionNumber) throws FirebaseRemoteConfigException; 35 | 36 | Template publishTemplate(Template template, boolean validateOnly, 37 | boolean forcePublish) throws FirebaseRemoteConfigException; 38 | 39 | Template rollback(String versionNumber) throws FirebaseRemoteConfigException; 40 | 41 | ListVersionsResponse listVersions( 42 | ListVersionsOptions options) throws FirebaseRemoteConfigException; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/remoteconfig/ParameterValueType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.remoteconfig; 18 | 19 | /** 20 | * Data types that are associated with parameter values. 21 | */ 22 | public enum ParameterValueType { 23 | STRING("STRING"), 24 | BOOLEAN("BOOLEAN"), 25 | NUMBER("NUMBER"), 26 | JSON("JSON"); 27 | 28 | private final String valueType; 29 | 30 | ParameterValueType(String valueType) { 31 | this.valueType = valueType; 32 | } 33 | 34 | public String getValueType() { 35 | return valueType; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/remoteconfig/PublishOptions.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.remoteconfig; 2 | 3 | /** 4 | * An internal class for publish template options. 5 | */ 6 | final class PublishOptions { 7 | 8 | private boolean validateOnly; 9 | private boolean forcePublish; 10 | 11 | PublishOptions() { 12 | validateOnly = false; 13 | forcePublish = false; 14 | } 15 | 16 | public PublishOptions setForcePublish(boolean forcePublish) { 17 | this.forcePublish = forcePublish; 18 | return this; 19 | } 20 | 21 | public PublishOptions setValidateOnly(boolean validateOnly) { 22 | this.validateOnly = validateOnly; 23 | return this; 24 | } 25 | 26 | public boolean isForcePublish() { 27 | return forcePublish; 28 | } 29 | 30 | public boolean isValidateOnly() { 31 | return validateOnly; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/remoteconfig/RemoteConfigErrorCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.remoteconfig; 18 | 19 | /** 20 | * Error codes that can be raised by the Remote Config APIs. 21 | */ 22 | public enum RemoteConfigErrorCode { 23 | 24 | /** 25 | * One or more arguments specified in the request were invalid. 26 | */ 27 | INVALID_ARGUMENT, 28 | 29 | /** 30 | * Internal server error. 31 | */ 32 | INTERNAL, 33 | 34 | /** 35 | * Request cannot be executed in the current system state, such as deleting a non-empty 36 | * directory. 37 | */ 38 | FAILED_PRECONDITION, 39 | 40 | /** 41 | * User is not authenticated. 42 | */ 43 | UNAUTHENTICATED, 44 | 45 | /** 46 | * The resource that a client tried to create already exists. 47 | */ 48 | ALREADY_EXISTS, 49 | 50 | /** 51 | * Failed to validate Remote Config data. 52 | */ 53 | VALIDATION_ERROR, 54 | 55 | /** 56 | * The current version specified in an update request 57 | * did not match the actual version in the database. 58 | */ 59 | VERSION_MISMATCH, 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/remoteconfig/TagColor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.remoteconfig; 18 | 19 | /** 20 | * Colors that are associated with conditions for display purposes in the Firebase Console. 21 | */ 22 | public enum TagColor { 23 | BLUE("BLUE"), 24 | BROWN("BROWN"), 25 | CYAN("CYAN"), 26 | DEEP_ORANGE("DEEP_ORANGE"), 27 | GREEN("GREEN"), 28 | INDIGO("INDIGO"), 29 | LIME("LIME"), 30 | ORANGE("ORANGE"), 31 | PINK("PINK"), 32 | PURPLE("PURPLE"), 33 | TEAL("TEAL"), 34 | UNSPECIFIED("CONDITION_DISPLAY_COLOR_UNSPECIFIED"); 35 | 36 | private final String color; 37 | 38 | TagColor(String color) { 39 | this.color = color; 40 | } 41 | 42 | public String getColor() { 43 | return color; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/google/firebase/remoteconfig/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @hide 19 | */ 20 | package com.google.firebase.remoteconfig.internal; 21 | -------------------------------------------------------------------------------- /src/main/resources/admin_sdk.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | sdk.version=${project.version} 18 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/auth/MockGoogleCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import com.google.auth.oauth2.AccessToken; 20 | import com.google.auth.oauth2.GoogleCredentials; 21 | import java.io.IOException; 22 | import java.util.Date; 23 | import java.util.concurrent.TimeUnit; 24 | 25 | /** 26 | * A flexible GoogleCredentials implementation fortesting purposes. 27 | */ 28 | public class MockGoogleCredentials extends GoogleCredentials { 29 | 30 | private String tokenValue; 31 | private long expiryTime; 32 | 33 | public MockGoogleCredentials() { 34 | this(null); 35 | } 36 | 37 | public MockGoogleCredentials(String tokenValue) { 38 | this(tokenValue, System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1)); 39 | } 40 | 41 | public MockGoogleCredentials(String tokenValue, long expiryTime) { 42 | this.tokenValue = tokenValue; 43 | this.expiryTime = expiryTime; 44 | } 45 | 46 | @Override 47 | public AccessToken refreshAccessToken() throws IOException { 48 | return new AccessToken(tokenValue, new Date(expiryTime)); 49 | } 50 | 51 | public void setExpiryTime(long expiryTime) { 52 | this.expiryTime = expiryTime; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/auth/UserImportOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.auth; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | import static org.junit.Assert.assertSame; 21 | 22 | import com.google.common.collect.ImmutableMap; 23 | import com.google.common.io.BaseEncoding; 24 | import com.google.firebase.auth.hash.HmacSha512; 25 | import java.util.Map; 26 | import org.junit.Test; 27 | 28 | public class UserImportOptionsTest { 29 | 30 | @Test(expected = NullPointerException.class) 31 | public void testEmptyOptions() { 32 | UserImportOptions.builder().build(); 33 | } 34 | 35 | @Test 36 | public void testHash() { 37 | HmacSha512 hash = HmacSha512.builder() 38 | .setKey("key".getBytes()) 39 | .build(); 40 | UserImportOptions options = UserImportOptions.builder() 41 | .setHash(hash) 42 | .build(); 43 | Map expected = ImmutableMap.of( 44 | "hashAlgorithm", "HMAC_SHA512", 45 | "signerKey", BaseEncoding.base64Url().encode("key".getBytes()) 46 | ); 47 | assertEquals(expected, options.getProperties()); 48 | assertSame(hash, options.getHash()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/cloud/FirestoreClientIT.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.cloud; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | import static org.junit.Assert.assertNotNull; 6 | 7 | import com.google.cloud.firestore.DocumentReference; 8 | import com.google.cloud.firestore.Firestore; 9 | import com.google.cloud.firestore.WriteResult; 10 | import com.google.common.collect.ImmutableMap; 11 | import com.google.firebase.testing.IntegrationTestUtils; 12 | import java.util.Map; 13 | import org.junit.Test; 14 | 15 | public class FirestoreClientIT { 16 | 17 | @Test 18 | public void testFirestoreAccess() throws Exception { 19 | Firestore firestore = FirestoreClient.getFirestore(IntegrationTestUtils.ensureDefaultApp()); 20 | DocumentReference reference = firestore.collection("cities").document("Mountain View"); 21 | ImmutableMap expected = ImmutableMap.of( 22 | "name", "Mountain View", 23 | "country", "USA", 24 | "population", 77846L, 25 | "capital", false 26 | ); 27 | WriteResult result = reference.set(expected).get(); 28 | assertNotNull(result); 29 | 30 | Map data = reference.get().get().getData(); 31 | assertEquals(expected.size(), data.size()); 32 | for (Map.Entry entry : expected.entrySet()) { 33 | assertEquals(entry.getValue(), data.get(entry.getKey())); 34 | } 35 | 36 | reference.delete().get(); 37 | assertFalse(reference.get().get().exists()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/DatabaseErrorTest.java: -------------------------------------------------------------------------------- 1 | package com.google.firebase.database; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertTrue; 5 | import static org.junit.Assert.fail; 6 | 7 | import org.junit.Test; 8 | 9 | public class DatabaseErrorTest { 10 | 11 | @Test 12 | public void testFromCode() { 13 | DatabaseError error = DatabaseError.fromCode(DatabaseError.DATA_STALE); 14 | assertEquals(DatabaseError.DATA_STALE, error.getCode()); 15 | assertEquals("The transaction needs to be run again with current data", error.getMessage()); 16 | assertEquals("", error.getDetails()); 17 | assertEquals("DatabaseError: " + error.getMessage(), error.toString()); 18 | 19 | try { 20 | DatabaseError.fromCode(19191); 21 | fail("No error thrown for unknown error code"); 22 | } catch (IllegalArgumentException expected) { 23 | // expected 24 | } 25 | } 26 | 27 | @Test 28 | public void testFromException() { 29 | DatabaseError error = DatabaseError.fromException(new RuntimeException("_test_")); 30 | assertEquals(DatabaseError.USER_CODE_EXCEPTION, error.getCode()); 31 | assertTrue(error.getMessage().contains("_test_")); 32 | assertEquals("", error.getDetails()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/EventRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | import com.google.firebase.database.core.view.Event; 20 | 21 | public class EventRecord { 22 | 23 | private DataSnapshot snapshot; 24 | private Event.EventType eventType; 25 | private String previousChild; 26 | 27 | public EventRecord(DataSnapshot snapshot, Event.EventType eventType, String previousChild) { 28 | this.snapshot = snapshot; 29 | this.eventType = eventType; 30 | this.previousChild = previousChild; 31 | } 32 | 33 | public DataSnapshot getSnapshot() { 34 | return snapshot; 35 | } 36 | 37 | public Event.EventType getEventType() { 38 | return eventType; 39 | } 40 | 41 | public String getPreviousChild() { 42 | return previousChild; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "Event: " + eventType + " at " + snapshot.getRef().toString(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/MapBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | public class MapBuilder { 23 | 24 | private Map map = new HashMap<>(); 25 | 26 | public MapBuilder put(String key, Object value) { 27 | map.put(key, value); 28 | return this; 29 | } 30 | 31 | public Map build() { 32 | return map; 33 | } 34 | 35 | public static Map of(String k1, Object v1) { 36 | return new MapBuilder().put(k1, v1).build(); 37 | } 38 | 39 | public static Map of(String k1, Object v1, String k2, Object v2) { 40 | return new MapBuilder().put(k1, v1).put(k2, v2).build(); 41 | } 42 | 43 | public static Map of(String k1, Object v1, String k2, Object v2, String k3, 44 | Object v3) { 45 | return new MapBuilder().put(k1, v1).put(k2, v2).put(k3, v3).build(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/TestChildEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | import org.junit.Assert; 20 | 21 | public class TestChildEventListener implements ChildEventListener { 22 | 23 | @Override 24 | public void onChildAdded(DataSnapshot snapshot, String previousChildName) { 25 | Assert.fail("onChildAdded called, but was not expected in Test!"); 26 | } 27 | 28 | @Override 29 | public void onChildChanged(DataSnapshot snapshot, String previousChildName) { 30 | Assert.fail("onChildChanged called, but was not expected in Test!"); 31 | } 32 | 33 | @Override 34 | public void onChildRemoved(DataSnapshot snapshot) { 35 | Assert.fail("onChildRemoved called, but was not expected in Test!"); 36 | } 37 | 38 | @Override 39 | public void onChildMoved(DataSnapshot snapshot, String previousChildName) { 40 | Assert.fail("onChildMoved called, but was not expected in Test!"); 41 | } 42 | 43 | @Override 44 | public void onCancelled(DatabaseError error) { 45 | Assert.fail("onCancelled called, but was not expected in Test!"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/TestFailure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database; 18 | 19 | public class TestFailure extends Exception { 20 | 21 | public TestFailure(Throwable e) { 22 | super(e); 23 | } 24 | 25 | public TestFailure(String message) { 26 | super(message); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/core/CoreTestHelpers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | import com.google.firebase.database.connection.PersistentConnection; 20 | import java.lang.Thread.UncaughtExceptionHandler; 21 | 22 | public class CoreTestHelpers { 23 | 24 | public static void freezeContext(Context context) { 25 | context.freeze(); 26 | } 27 | 28 | public static PersistentConnection getRepoConnection(Repo repo) { 29 | return repo.getConnection(); 30 | } 31 | 32 | public static void setEventTargetExceptionHandler(Context context, 33 | UncaughtExceptionHandler handler) { 34 | ThreadPoolEventTarget eventTarget = (ThreadPoolEventTarget) context.getEventTarget(); 35 | eventTarget.setExceptionHandler(handler); 36 | } 37 | 38 | public static UncaughtExceptionHandler getEventTargetExceptionHandler(Context context) { 39 | ThreadPoolEventTarget eventTarget = (ThreadPoolEventTarget) context.getEventTarget(); 40 | return eventTarget.getExceptionHandler(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/core/RepoInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | 21 | import java.net.URI; 22 | import org.junit.Test; 23 | 24 | public class RepoInfoTest { 25 | 26 | @Test 27 | public void getConnectionURLTestOverloadWorks() { 28 | final String repo = "tests"; 29 | final String server = "admin-java-sdk.firebaseio.com"; 30 | 31 | RepoInfo info = new RepoInfo(); 32 | info.host = repo + "." + server; 33 | info.internalHost = info.host; 34 | info.secure = false; 35 | info.namespace = repo; 36 | URI url = info.getConnectionURL(null); 37 | assertEquals("ws://tests.admin-java-sdk.firebaseio.com/.ws?ns=tests&v=5", 38 | url.toString()); 39 | url = info.getConnectionURL("test"); 40 | assertEquals("ws://tests.admin-java-sdk.firebaseio.com/.ws?ns=tests&v=5&ls=test", 41 | url.toString()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/core/persistence/MockListenProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.persistence; 18 | 19 | import com.google.firebase.database.connection.ListenHashProvider; 20 | import com.google.firebase.database.core.SyncTree; 21 | import com.google.firebase.database.core.Tag; 22 | import com.google.firebase.database.core.view.QuerySpec; 23 | import java.util.HashSet; 24 | import java.util.Set; 25 | 26 | public class MockListenProvider implements SyncTree.ListenProvider { 27 | 28 | private Set listens = new HashSet<>(); 29 | 30 | @Override 31 | public void startListening( 32 | QuerySpec query, 33 | Tag tag, 34 | ListenHashProvider hash, 35 | SyncTree.CompletionListener onListenComplete) { 36 | listens.add(query); 37 | } 38 | 39 | @Override 40 | public void stopListening(QuerySpec query, Tag tag) { 41 | listens.remove(query); 42 | } 43 | 44 | public boolean hasListen(QuerySpec query) { 45 | return listens.contains(query); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/core/persistence/TestCachePolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.persistence; 18 | 19 | public class TestCachePolicy implements CachePolicy { 20 | 21 | private final float percentToPruneAtOnce; 22 | private final long maxNumberToKeep; 23 | private boolean timeToPrune = false; 24 | 25 | public TestCachePolicy(float percentToPruneAtOnce, long maxNumberToKeep) { 26 | this.percentToPruneAtOnce = percentToPruneAtOnce; 27 | this.maxNumberToKeep = maxNumberToKeep; 28 | } 29 | 30 | public void pruneOnNextServerUpdate() { 31 | timeToPrune = true; 32 | } 33 | 34 | @Override 35 | public boolean shouldPrune(long currentSizeBytes, long countOfPrunableQueries) { 36 | if (timeToPrune) { 37 | timeToPrune = false; 38 | return true; 39 | } else { 40 | return false; 41 | } 42 | } 43 | 44 | @Override 45 | public boolean shouldCheckCacheSize(long serverUpdatesSinceLastCheck) { 46 | return true; 47 | } 48 | 49 | @Override 50 | public float getPercentOfQueriesToPruneAtOnce() { 51 | return percentToPruneAtOnce; 52 | } 53 | 54 | @Override 55 | public long getMaxNumberOfQueriesToKeep() { 56 | return maxNumberToKeep; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/core/utilities/TestClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.utilities; 18 | 19 | import com.google.firebase.database.utilities.Clock; 20 | 21 | public class TestClock implements Clock { 22 | 23 | private long now = 1; 24 | 25 | @Override 26 | public long millis() { 27 | return now; 28 | } 29 | 30 | public long tick() { 31 | now++; 32 | return now; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/core/view/QueryParamsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.view; 18 | 19 | import static com.google.firebase.database.TestHelpers.ck; 20 | import static org.junit.Assert.assertEquals; 21 | import static org.junit.Assert.assertTrue; 22 | 23 | import com.google.firebase.database.snapshot.EmptyNode; 24 | import java.util.Map; 25 | import org.junit.Test; 26 | 27 | public class QueryParamsTest { 28 | 29 | @Test 30 | public void startAtNullIsSerializable() { 31 | QueryParams params = QueryParams.DEFAULT_PARAMS; 32 | params = params.startAt(EmptyNode.Empty(), ck("key")); 33 | Map serialized = params.getWireProtocolParams(); 34 | QueryParams parsed = QueryParams.fromQueryObject(serialized); 35 | assertEquals(params, parsed); 36 | assertTrue(params.hasStart()); 37 | } 38 | 39 | @Test 40 | public void endAtNullIsSerializable() { 41 | QueryParams params = QueryParams.DEFAULT_PARAMS; 42 | params = params.endAt(EmptyNode.Empty(), ck("key")); 43 | Map serialized = params.getWireProtocolParams(); 44 | QueryParams parsed = QueryParams.fromQueryObject(serialized); 45 | assertEquals(params, parsed); 46 | assertTrue(params.hasEnd()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/database/core/view/ViewAccess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.database.core.view; 18 | 19 | import com.google.firebase.database.core.EventRegistration; 20 | import java.util.List; 21 | 22 | public class ViewAccess { 23 | 24 | // Provides test access to event registrations on a view. 25 | public static List getEventRegistrations(View view) { 26 | return view.getEventRegistrations(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/iid/FirebaseInstanceIdIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.iid; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | import static org.junit.Assert.assertTrue; 21 | 22 | import com.google.firebase.testing.IntegrationTestUtils; 23 | import java.util.concurrent.ExecutionException; 24 | import org.junit.BeforeClass; 25 | import org.junit.Test; 26 | 27 | public class FirebaseInstanceIdIT { 28 | 29 | @BeforeClass 30 | public static void setUpClass() throws Exception { 31 | IntegrationTestUtils.ensureDefaultApp(); 32 | } 33 | 34 | @Test 35 | public void testDeleteNonExisting() throws Exception { 36 | FirebaseInstanceId instanceId = FirebaseInstanceId.getInstance(); 37 | try { 38 | // instance ids have to conform to /[cdef][A-Za-z0-9_-]{9}[AEIMQUYcgkosw048]/ 39 | instanceId.deleteInstanceIdAsync("fictive-ID0").get(); 40 | } catch (ExecutionException e) { 41 | assertTrue(e.getCause() instanceof FirebaseInstanceIdException); 42 | assertEquals("Instance ID \"fictive-ID0\": Failed to find the instance ID.", 43 | e.getCause().getMessage()); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/testing/FirebaseAppRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.testing; 18 | 19 | import com.google.firebase.TestOnlyImplFirebaseTrampolines; 20 | import org.junit.rules.TestRule; 21 | import org.junit.runner.Description; 22 | import org.junit.runners.model.Statement; 23 | 24 | /** Makes sure that all FirebaseApp state is cleared before and after tests. */ 25 | public class FirebaseAppRule implements TestRule { 26 | 27 | @Override 28 | public Statement apply(final Statement base, Description description) { 29 | return new Statement() { 30 | @Override 31 | public void evaluate() throws Throwable { 32 | resetState(); 33 | try { 34 | base.evaluate(); 35 | } finally { 36 | resetState(); 37 | } 38 | } 39 | }; 40 | } 41 | 42 | private void resetState() { 43 | TestOnlyImplFirebaseTrampolines.clearInstancesForTest(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/testing/GenericFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.testing; 18 | 19 | /** 20 | * A generic operation that can be called with arbitrary arguments. 21 | */ 22 | public interface GenericFunction { 23 | 24 | T call(Object ...args) throws Exception; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/testing/MockitoTestRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.testing; 18 | 19 | import org.junit.rules.MethodRule; 20 | import org.junit.runners.model.FrameworkMethod; 21 | import org.junit.runners.model.Statement; 22 | import org.mockito.Mockito; 23 | import org.mockito.MockitoAnnotations; 24 | 25 | /** 26 | * Test rule that calls {@link MockitoAnnotations#initMocks} before the test and {@link 27 | * Mockito#validateMockitoUsage()} after. 28 | */ 29 | public class MockitoTestRule implements MethodRule { 30 | 31 | @Override 32 | public Statement apply(final Statement base, FrameworkMethod method, final Object target) { 33 | return new Statement() { 34 | @Override 35 | public void evaluate() throws Throwable { 36 | MockitoAnnotations.initMocks(target); 37 | try { 38 | base.evaluate(); 39 | } finally { 40 | Mockito.validateMockitoUsage(); 41 | } 42 | } 43 | }; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/testing/MultiRequestMockHttpTransport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.testing; 18 | 19 | import com.google.api.client.http.LowLevelHttpRequest; 20 | import com.google.api.client.testing.http.MockHttpTransport; 21 | import com.google.api.client.testing.http.MockLowLevelHttpRequest; 22 | import com.google.api.client.testing.http.MockLowLevelHttpResponse; 23 | import com.google.common.collect.ImmutableList; 24 | import java.io.IOException; 25 | import java.util.LinkedList; 26 | import java.util.List; 27 | import java.util.Queue; 28 | 29 | /** 30 | * A mock HttpTransport that can simulate multiple (sequential) HTTP interactions. This can be 31 | * used when an SDK operation makes multiple backend calls. 32 | */ 33 | public class MultiRequestMockHttpTransport extends MockHttpTransport { 34 | 35 | private final Queue responses; 36 | 37 | public MultiRequestMockHttpTransport(List responses) { 38 | this.responses = new LinkedList<>(responses); 39 | } 40 | 41 | @Override 42 | public LowLevelHttpRequest buildRequest(String method, String url) throws IOException { 43 | LowLevelHttpRequest request = super.buildRequest(method, url); 44 | ((MockLowLevelHttpRequest) request).setResponse(responses.remove()); 45 | return request; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/com/google/firebase/testing/TestResponseInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.firebase.testing; 18 | 19 | import static org.junit.Assert.assertNotNull; 20 | 21 | import com.google.api.client.http.HttpRequest; 22 | import com.google.api.client.http.HttpResponse; 23 | import com.google.api.client.http.HttpResponseInterceptor; 24 | import java.io.IOException; 25 | 26 | /** 27 | * Can be used to intercept HTTP requests and responses made by the SDK during tests. 28 | */ 29 | public class TestResponseInterceptor implements HttpResponseInterceptor { 30 | 31 | private HttpResponse response; 32 | 33 | @Override 34 | public void interceptResponse(HttpResponse response) { 35 | this.response = response; 36 | } 37 | 38 | public HttpResponse getResponse() { 39 | return response; 40 | } 41 | 42 | public HttpRequest getLastRequest() { 43 | assertNotNull(response); 44 | return response.getRequest(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/resources/createSessionCookie.json: -------------------------------------------------------------------------------- 1 | { 2 | "sessionCookie": "MockCookieString" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/createUser.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "identitytoolkit#SignupNewUserResponse", 3 | "localId": "testuser" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/deleteUser.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind" : "identitytoolkit#DeleteUserResponse" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/fcm_batch_success.txt: -------------------------------------------------------------------------------- 1 | --test_boundary 2 | Content-Type: application/http 3 | Content-ID: response-1 4 | 5 | HTTP/1.1 200 OK 6 | Content-Type: application/json; charset=UTF-8 7 | Vary: Origin 8 | Vary: X-Origin 9 | Vary: Referer 10 | 11 | { 12 | "name": "projects/test-project/messages/1" 13 | } 14 | 15 | --test_boundary 16 | Content-Type: application/http 17 | Content-ID: response-2 18 | 19 | HTTP/1.1 200 OK 20 | Content-Type: application/json; charset=UTF-8 21 | Vary: Origin 22 | Vary: X-Origin 23 | Vary: Referer 24 | 25 | { 26 | "name": "projects/test-project/messages/2" 27 | } 28 | 29 | --test_boundary-- -------------------------------------------------------------------------------- /src/test/resources/firebase_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "databaseAuthVariableOverride": {"uid": "testuser"}, 3 | "databaseUrl": "https://hipster-chat.firebaseio.mock", 4 | "projectId": "hipster-chat-mock", 5 | "storageBucket": "hipster-chat.appspot.mock" 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/firebase_config_empty.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebase/firebase-admin-java/4f73761203316c3d84b9993aebb960c784f561bb/src/test/resources/firebase_config_empty.json -------------------------------------------------------------------------------- /src/test/resources/firebase_config_invalid.json: -------------------------------------------------------------------------------- 1 | baaaaad 2 | -------------------------------------------------------------------------------- /src/test/resources/firebase_config_invalid_key.json: -------------------------------------------------------------------------------- 1 | { 2 | "databaseUareL": "https://hipster-chat.firebaseio.mock", 3 | "projectId": "hipster-chat-mock" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/firebase_config_partial.json: -------------------------------------------------------------------------------- 1 | { 2 | "databaseUrl": "https://hipster-chat.firebaseio.mock", 3 | "projectId": "hipster-chat-mock" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/generateEmailLink.json: -------------------------------------------------------------------------------- 1 | { 2 | "oobLink": "https://mock-oob-link.for.auth.tests", 3 | "email": "test@example.com" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/getRemoteConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "conditions": [ 3 | { 4 | "name": "ios_en", 5 | "expression": "device.os == 'ios' && device.country in ['us', 'uk']", 6 | "tagColor": "INDIGO" 7 | }, 8 | { 9 | "name": "android_en", 10 | "expression": "device.os == 'android' && device.country in ['us', 'uk']" 11 | } 12 | ], 13 | "parameters": { 14 | "welcome_message_text": { 15 | "defaultValue": { 16 | "value": "welcome to app" 17 | }, 18 | "conditionalValues": { 19 | "ios_en": { 20 | "value": "welcome to app en" 21 | } 22 | }, 23 | "description": "text for welcome message!", 24 | "valueType": "STRING" 25 | }, 26 | "header_text": { 27 | "defaultValue": { 28 | "useInAppDefault": true 29 | }, 30 | "valueType": "STRING" 31 | } 32 | }, 33 | "parameterGroups": { 34 | "new menu": { 35 | "description": "New Menu", 36 | "parameters": { 37 | "pumpkin_spice_season": { 38 | "defaultValue": { 39 | "value": "true" 40 | }, 41 | "description": "Whether it's currently pumpkin spice season.", 42 | "valueType": "BOOLEAN" 43 | } 44 | } 45 | } 46 | }, 47 | "version": { 48 | "versionNumber": "17", 49 | "updateOrigin": "ADMIN_SDK_NODE", 50 | "updateType": "INCREMENTAL_UPDATE", 51 | "updateUser": { 52 | "email": "firebase-user@account.com", 53 | "name": "dev-admin", 54 | "imageUrl": "http://image.jpg" 55 | }, 56 | "updateTime": "2020-11-15T06:57:26.342763941Z", 57 | "description": "promo config" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/resources/getUser.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind" : "identitytoolkit#GetAccountInfoResponse", 3 | "users" : [ { 4 | "localId" : "testuser", 5 | "email" : "testuser@example.com", 6 | "phoneNumber" : "+1234567890", 7 | "emailVerified" : true, 8 | "displayName" : "Test User", 9 | "providerUserInfo" : [ { 10 | "providerId" : "password", 11 | "displayName" : "Test User", 12 | "photoUrl" : "http://www.example.com/testuser/photo.png", 13 | "federatedId" : "testuser@example.com", 14 | "email" : "testuser@example.com", 15 | "rawId" : "testuser@example.com" 16 | }, { 17 | "providerId" : "phone", 18 | "phoneNumber" : "+1234567890", 19 | "rawId" : "+1234567890" 20 | }, { 21 | "providerId" : "google.com", 22 | "rawId" : "google_uid" 23 | } ], 24 | "photoUrl" : "http://www.example.com/testuser/photo.png", 25 | "passwordHash" : "passwordhash", 26 | "passwordUpdatedAt" : 1.494364393E+12, 27 | "validSince" : "1494364393", 28 | "disabled" : false, 29 | "createdAt" : "1234567890", 30 | "customAttributes" : "{\"admin\": true, \"package\": \"gold\"}", 31 | "tenantId": "testTenant" 32 | } ] 33 | } 34 | -------------------------------------------------------------------------------- /src/test/resources/getUserError.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind" : "identitytoolkit#GetAccountInfoResponse" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/importUsersError.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": [ 3 | {"index": 0, "message": "Some error occurred in user1"}, 4 | {"index": 2, "message": "Another error occurred in user3"} 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/listOidc.json: -------------------------------------------------------------------------------- 1 | { 2 | "oauthIdpConfigs" : [ { 3 | "name": "projects/projectId/oauthIdpConfigs/oidc.provider-id1", 4 | "displayName" : "DISPLAY_NAME", 5 | "enabled" : true, 6 | "clientId" : "CLIENT_ID", 7 | "clientSecret" : "CLIENT_SECRET", 8 | "issuer" : "https://oidc.com/issuer", 9 | "responseType" : { 10 | "code": true, 11 | "idToken": false 12 | } 13 | }, { 14 | "name": "projects/projectId/oauthIdpConfigs/oidc.provider-id2", 15 | "displayName" : "DISPLAY_NAME", 16 | "enabled" : true, 17 | "clientId" : "CLIENT_ID", 18 | "clientSecret" : "CLIENT_SECRET", 19 | "issuer" : "https://oidc.com/issuer", 20 | "responseType" : { 21 | "code": true, 22 | "idToken": false 23 | } 24 | } ] 25 | } 26 | -------------------------------------------------------------------------------- /src/test/resources/listRemoteConfigVersions.json: -------------------------------------------------------------------------------- 1 | { 2 | "versions": [ 3 | { 4 | "versionNumber": "32", 5 | "updateTime": "2020-11-24T19:10:35.506793Z", 6 | "updateUser": { 7 | "email": "admin@email.com", 8 | "imageUrl": "https://photo.jpg" 9 | }, 10 | "description": "Rollback to version 29", 11 | "updateOrigin": "REST_API", 12 | "updateType": "ROLLBACK", 13 | "rollbackSource": "29" 14 | }, 15 | { 16 | "versionNumber": "31", 17 | "updateTime": "2020-11-24T19:09:40.249437Z", 18 | "updateUser": { 19 | "email": "admin@email.com", 20 | "imageUrl": "https://photo.jpg" 21 | }, 22 | "description": "new template", 23 | "updateOrigin": "REST_API", 24 | "updateType": "INCREMENTAL_UPDATE" 25 | }, 26 | { 27 | "versionNumber": "30", 28 | "updateTime": "2020-11-24T19:08:30.613942Z", 29 | "updateUser": { 30 | "email": "admin@email.com", 31 | "imageUrl": "https://photo.jpg" 32 | }, 33 | "description": "new template", 34 | "updateOrigin": "REST_API", 35 | "updateType": "INCREMENTAL_UPDATE" 36 | }, 37 | { 38 | "versionNumber": "29", 39 | "updateTime": "2020-11-12T22:12:02.180181Z", 40 | "updateUser": { 41 | "email": "admin@email.com", 42 | "imageUrl": "https://photo.jpg" 43 | }, 44 | "description": "new template", 45 | "updateOrigin": "REST_API", 46 | "updateType": "INCREMENTAL_UPDATE" 47 | } 48 | ], 49 | "nextPageToken": "28" 50 | } 51 | -------------------------------------------------------------------------------- /src/test/resources/listSaml.json: -------------------------------------------------------------------------------- 1 | { 2 | "inboundSamlConfigs" : [ { 3 | "name": "projects/projectId/inboundSamlConfigs/saml.provider-id1", 4 | "displayName" : "DISPLAY_NAME", 5 | "enabled" : true, 6 | "idpConfig": { 7 | "idpEntityId": "IDP_ENTITY_ID", 8 | "ssoUrl": "https://example.com/login", 9 | "idpCertificates": [ 10 | { "x509Certificate": "certificate1" }, 11 | { "x509Certificate": "certificate2" } 12 | ] 13 | }, 14 | "spConfig": { 15 | "spEntityId": "RP_ENTITY_ID", 16 | "callbackUri": "https://projectId.firebaseapp.com/__/auth/handler" 17 | } 18 | }, { 19 | "name": "projects/projectId/inboundSamlConfigs/saml.provider-id2", 20 | "displayName" : "DISPLAY_NAME", 21 | "enabled" : true, 22 | "idpConfig": { 23 | "idpEntityId": "IDP_ENTITY_ID", 24 | "ssoUrl": "https://example.com/login", 25 | "idpCertificates": [ 26 | { "x509Certificate": "certificate1" }, 27 | { "x509Certificate": "certificate2" } 28 | ] 29 | }, 30 | "spConfig": { 31 | "spEntityId": "RP_ENTITY_ID", 32 | "callbackUri": "https://projectId.firebaseapp.com/__/auth/handler" 33 | } 34 | } ] 35 | } 36 | -------------------------------------------------------------------------------- /src/test/resources/listTenants.json: -------------------------------------------------------------------------------- 1 | { 2 | "tenants" : [ { 3 | "name" : "TENANT_1", 4 | "displayName" : "DISPLAY_NAME", 5 | "allowPasswordSignup" : true, 6 | "enableEmailLinkSignin" : false, 7 | "disableAuth" : true, 8 | "enableAnonymousUser" : false 9 | }, { 10 | "name" : "TENANT_2", 11 | "displayName" : "DISPLAY_NAME", 12 | "allowPasswordSignup" : true, 13 | "enableEmailLinkSignin" : false, 14 | "disableAuth" : true, 15 | "enableAnonymousUser" : false 16 | } ] 17 | } 18 | -------------------------------------------------------------------------------- /src/test/resources/oidc.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "projects/projectId/oauthIdpConfigs/oidc.provider-id", 3 | "displayName" : "DISPLAY_NAME", 4 | "enabled" : true, 5 | "clientId" : "CLIENT_ID", 6 | "clientSecret" : "CLIENT_SECRET", 7 | "issuer" : "https://oidc.com/issuer", 8 | "responseType" : { 9 | "code": true, 10 | "idToken": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/saml.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "projects/projectId/inboundSamlConfigs/saml.provider-id", 3 | "displayName": "DISPLAY_NAME", 4 | "enabled": true, 5 | "idpConfig": { 6 | "idpEntityId": "IDP_ENTITY_ID", 7 | "ssoUrl": "https://example.com/login", 8 | "idpCertificates": [ 9 | { "x509Certificate": "certificate1" }, 10 | { "x509Certificate": "certificate2" } 11 | ] 12 | }, 13 | "spConfig": { 14 | "spEntityId": "RP_ENTITY_ID", 15 | "callbackUri": "https://projectId.firebaseapp.com/__/auth/handler" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/resources/service_accounts/editor_public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEFTCCAv2gAwIBAgIJALLYfi2oN8cPMA0GCSqGSIb3DQEBCwUAMIGgMQswCQYD 3 | VQQGEwJVUzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxDzAN 4 | BgNVBAoMBkdvb2dsZTERMA8GA1UECwwIRmlyZWJhc2UxHDAaBgNVBAMME2ZpcmVi 5 | YXNlLmdvb2dsZS5jb20xKjAoBgkqhkiG9w0BCQEWG3N1cHBvcnRAZmlyZWJhc2Uu 6 | Z29vZ2xlLmNvbTAeFw0xNzAzMjIwMDM4MzRaFw0yNzAzMjAwMDM4MzRaMIGgMQsw 7 | CQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcx 8 | DzANBgNVBAoMBkdvb2dsZTERMA8GA1UECwwIRmlyZWJhc2UxHDAaBgNVBAMME2Zp 9 | cmViYXNlLmdvb2dsZS5jb20xKjAoBgkqhkiG9w0BCQEWG3N1cHBvcnRAZmlyZWJh 10 | c2UuZ29vZ2xlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCR 11 | DXEXr/nl2Sr4YVi4ldy89jLzvp2kER6OfYN72jUJ24Mnbjfy+JK5ayeXOhYopF3b 12 | STW/0K7AB0siVgrvI90/Qq7osG4nRgJNltEblYk1bKYx1E7CBxMcfXrljNFKJhr2 13 | JKKl2oXYTy/81YlUibfkbfGxy7DL6W/EarkyG/YimN0jFdrQqHzZsgkoFW4Iav8u 14 | 5SjkbVfyEYLlrOkdtn25G9K9jAmKDQG2fXap20SBTWQQu4rWLVKExK3rEVnMhTId 15 | M3wCCcnFjiZVSwy6pGNkpiMfLu37srAoNcHKEmaErbg6tNp2RDMNXcfBxsxNIcp6 16 | R5ZaESwcriLjgHzAgmMCAwEAAaNQME4wHQYDVR0OBBYEFGmG5dc2YEEDbFA2+SBS 17 | A13S5l4VMB8GA1UdIwQYMBaAFGmG5dc2YEEDbFA2+SBSA13S5l4VMAwGA1UdEwQF 18 | MAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAEmICKB6kq/Y++JKHZg88JS4nlWzIFh 19 | NBrfyCnMQiL9mmllEXQIhK25xleQwQGsBF2odDj+8H9CG/lwWLmyC5+TryFjWrhn 20 | Hlt8QJb8E4dIZkYAxDL/ii6tXfFTjvrXsTcY2moD6ZoOoxahVOjVfwkHup0ONn2v 21 | sCL/11FneR0jhgruXKoqrKspgNVuYp+t4IKnnePpeGJb/I3SyS9GUXlScV/uWyRw 22 | LdIoR2teEWcWeNrMLmth0NSa3AF3gd9+HTaGpESsusG4qPamqiSM7+INAeTo4k8b 23 | lbqLwo3Ju6cNGGlDSsDXIUahpCdKnqxBALytITmIcHwsR4vYaDP4iOE= 24 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /src/test/resources/service_accounts/none_public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDWjCCAkICCQCA3L1QEogHVDANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJV 3 | UzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxETAPBgNVBAoM 4 | CEZpcmViYXNlMREwDwYDVQQLDAhGaXJlYmFzZTEVMBMGA1UEAwwMZmlyZWJhc2Uu 5 | Y29tMB4XDTE3MDQwNjAxMTkyMloXDTI3MDQwNDAxMTkyMlowbzELMAkGA1UEBhMC 6 | VVMxCzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MREwDwYDVQQK 7 | DAhGaXJlYmFzZTERMA8GA1UECwwIRmlyZWJhc2UxFTATBgNVBAMMDGZpcmViYXNl 8 | LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOuptiRIzqyLFheA 9 | KWPjju8H/ThHBQXKRznie1vK9vKZQ4mDIBQks2MQiKDrQ4hem93C3/HPLG+aeziK 10 | 9uZbEmkA0ENTOJS3sDAuRgARDGR9w/vY8WJIY2QU+vHNlYQZwrcTiyVoR7rF0VrQ 11 | C558hwNLAgyZE/v7bS6dOEnDWMIbitBNue4TAz/hTmYrWdcLezebN/yn0gdnleIQ 12 | EHEpZjVz0vLpU3ANHvHGHywt8QmYbnsL6IlFktSWgBapCWdEzS8rlnoyYzCdKllb 13 | sqBgSXXdYQyFHhloJnkbLk77nHgOjfrfjn2hsNtYrruCtzH+q0WfJCrwdUMrIj0l 14 | mlWnBHUCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAvSURgqhl8Zvuyig6TbOwP8kv 15 | 81AvvQg7hHbkbfhhy192EEtNR+6Oj8Yf4gVR+2TskJRLRDiwFh0JVw2I9TTufjwn 16 | Ap9hTocd2NeW28bU3LKymzoxNzOHDmanh7Kw/JzWEanACA6UzbOcjvu1pEu9fBSU 17 | ySar8QCjRv31tC5qWCYcPp/2kEjW3IxhzddfaJF3Xa4TDOP9TOxAyDERIxdpR7f4 18 | 2hpao94nzoabhUkF51nPNzbAxrJ+KSuPKR2uZwbVtc0M81FIPYqxk6uvay3L0Ymg 19 | 4Stjj49xeGQZoCMHC8nFK1WOTwIXWeR7oq2cmXtTDxPgJezEsBocsTOmV3o/AQ== 20 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /src/test/resources/service_accounts/owner_public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDBjCCAe4CCQDmUV5g1nU+bzANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB 3 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 4 | cyBQdHkgTHRkMB4XDTE3MDQwNjAxMjIxM1oXDTI3MDQwNDAxMjIxM1owRTELMAkG 5 | A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 6 | IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB 7 | AMjjgWYE/lSQ8CFzJdmvWL3LcUuUc6YYMIB5PidUbyKdacNq4RLsJACBW9OPHfE2 8 | 5MSxzOYULRVe3EJF8wgX5pdoDhnzGTtQUvBvVFZrbbXudWnKCQSo+s/RyRCjr2kg 9 | tIcCScO265Ku5CkohkrbF+2OYqY5OYvqpazzWFKu3FK5KFuZxxqRUtgp7dvo1tKn 10 | 9e2I/zb393UewPHTf8P0DjBPw9BB6IDfTjqjw4pNEEDLBAm0P6UQtLDZY9QdGmmK 11 | lpJuDaWfpLNaVbkH4CsMzQck1g3IcOZZs14ZF2nwuj6sJsv0UlSyVD/xa6o6b2jP 12 | kO4viWU0An8BE42VWYPeBP8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAWED2Cf4g 13 | dqmDsvD1kFSAp7i+pd30pmZ2XsbQPAu9dQQYOkdARvLxsyXQPG0ih8UmDJ57ZxxG 14 | qFrOxnLaS0i4b9N24PI99zgfvfzm/w9twj/qP1b/CPz9BfHGpIn37mw16/GMdYWg 15 | 5G5FrU0g/2cGOLQ2sfIjy6nffcJWiAa0Z9V4rD216Dmx6niHCAkYBl4yhs+Erh2Q 16 | H6RrJ0kgz6dM2fL7WYV063PjohC4FsSphY06A4fFrXzenghiGreanCRJZh5ggoQS 17 | uquPcVdPKl0+LZsN3u9jdO+sWcEiHRTbwtJ9JFsWmMEyF3oXt2G0Ag1aad31gO0Q 18 | UiHEZJWhLSI+/g== 19 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /src/test/resources/service_accounts/viewer_public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDBjCCAe4CCQC+fVEjGSDrNDANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB 3 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 4 | cyBQdHkgTHRkMB4XDTE3MDQwNjAxMjYzN1oXDTI3MDQwNDAxMjYzN1owRTELMAkG 5 | A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 6 | IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB 7 | AOvactXthcfkFooFDM7g5YdeOefBt/zaqwdkaa2orpCDxJhE2TN6uGRzv7yjPncF 8 | /9caGgv7wDjocwbsXTanIDJ5kURyWpYAZl7PK8AO9HYqEIMMWceSnTC3iDgFGFYJ 9 | zvT25ArVuFZDMyEdnfUAoBMkfBazhIQ+sv0k/hUtq5QqklzbW9AuswSRdCDhjQ/G 10 | ypSbrMxja/JXDq1mZG1hqvOc7FeLh8qK9TU9BFLns3s4GmBv1/Cjpm4WLd3yqKLI 11 | iIZeHmWqXQQ84+BrsUzFQHz2kbTl/bBthruZnvnrGqc64IM3l7ufLlIuSM+V0CD7 12 | gxE/9fNJzQuSTGeA5Xr8YaUCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAi7qkPFxS 13 | TMnt+rd8GNCtdxStwDtB/by7LExqKC9BoFsOpI1xuHRIskQ/7ZOmOjRGhJnGsdko 14 | UuGJ4MmRThVs/+IZ5iffL5GlrbV/zUrJHcy3sUGlBFXC/TGwa59pAJ7R5vt4n6Rd 15 | prPOikzU/jpL0GO6lwjpzRhvvaFAhMd0hHOonSujIo+MkzAJa0mDUX/ywIj53PN5 16 | miqQmJCHvQMPUHF6H9yotawi5Kb56CBRzl+BL526aAf6nZdJkn+u48pw3jomNW0O 17 | eUniGP7/QzugQ3vE/sw24U/2n/2m+5Hw+4UFokbCN5HIiFqiqU8quq0Hjol7qc9/ 18 | SbdhexQ7imvMfA== 19 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /src/test/resources/tenant.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "TENANT_1", 3 | "displayName" : "DISPLAY_NAME", 4 | "allowPasswordSignup" : true, 5 | "enableEmailLinkSignin" : false, 6 | "disableAuth" : true, 7 | "enableAnonymousUser" : false 8 | } 9 | --------------------------------------------------------------------------------