TokenRefresher(FirebaseApp firebaseApp) { this.firebaseApp = checkNotNull(firebaseApp); this.credentials = firebaseApp.getOptions().getCredentials(); this.state = new AtomicReference<>(State.READY); }
/** * Constructor for injecting a GooglePublicKeysManager, which is used to verify tokens are * correctly signed. This should only be used for testing to override the default key manager. */ @VisibleForTesting FirebaseAuth(FirebaseApp firebaseApp, KeyManagers keyManagers, Clock clock) { this.firebaseApp = checkNotNull(firebaseApp); this.keyManagers = checkNotNull(keyManagers); this.clock = checkNotNull(clock); this.projectId = ImplFirebaseTrampolines.getProjectId(firebaseApp); this.jsonFactory = firebaseApp.getOptions().getJsonFactory(); this.userManager = new FirebaseUserManager(firebaseApp); this.tokenFactory = new AtomicReference<>(null); this.destroyed = new AtomicBoolean(false); this.lock = new Object(); }
private FirebaseInstanceId(FirebaseApp app) { HttpTransport httpTransport = app.getOptions().getHttpTransport(); this.app = app; this.requestFactory = httpTransport.createRequestFactory(new FirebaseRequestInitializer(app)); this.jsonFactory = app.getOptions().getJsonFactory(); this.projectId = ImplFirebaseTrampolines.getProjectId(app); checkArgument(!Strings.isNullOrEmpty(projectId), "Project ID is required to access instance ID service. Use a service account credential or " + "set the project ID explicitly via FirebaseOptions. Alternatively you can also " + "set the project ID via the GOOGLE_CLOUD_PROJECT environment variable."); }
/** * Gets an instance of FirebaseDatabase for a specific FirebaseApp. * * @param app The FirebaseApp to get a FirebaseDatabase for. * @return A FirebaseDatabase instance. */ public static FirebaseDatabase getInstance(FirebaseApp app) { return getInstance(app, app.getOptions().getDatabaseUrl()); }
private FirebaseMessaging(FirebaseApp app) { HttpTransport httpTransport = app.getOptions().getHttpTransport(); this.app = app; this.requestFactory = httpTransport.createRequestFactory(new FirebaseRequestInitializer(app)); this.jsonFactory = app.getOptions().getJsonFactory(); String projectId = ImplFirebaseTrampolines.getProjectId(app); checkArgument(!Strings.isNullOrEmpty(projectId), "Project ID is required to access messaging service. Use a service account credential or " + "set the project ID explicitly via FirebaseOptions. Alternatively you can also " + "set the project ID via the GOOGLE_CLOUD_PROJECT environment variable."); this.url = String.format(FCM_URL, projectId); }
public FirebaseRequestInitializer(FirebaseApp app) { GoogleCredentials credentials = ImplFirebaseTrampolines.getCredentials(app); this.credentialsAdapter = new HttpCredentialsAdapter(credentials); this.connectTimeout = app.getOptions().getConnectTimeout(); this.readTimeout = app.getOptions().getReadTimeout(); }
/** * Returns the default cloud storage bucket associated with the current app. This is the bucket * configured via {@link com.google.firebase.FirebaseOptions} when initializing the app. If * no bucket was configured via options, this method throws an exception. * * @return a cloud storage <a href="https://googlecloudplatform.github.io/google-cloud-java/google-cloud-clients/apidocs/com/google/cloud/storage/Bucket.html">{@code Bucket}</a> * instance. * @throws IllegalArgumentException If no bucket is configured via <code>FirebaseOptions</code>, * or if the bucket does not exist. */ public Bucket bucket() { return bucket(app.getOptions().getStorageBucket()); }
public static GoogleCredentials getCredentials(@NonNull FirebaseApp app) { return app.getOptions().getCredentials(); }
public static FirestoreOptions getFirestoreOptions(@NonNull FirebaseApp app) { return app.getOptions().getFirestoreOptions(); }
/** * Creates a new FirebaseUserManager instance. * * @param app A non-null {@link FirebaseApp}. */ FirebaseUserManager(@NonNull FirebaseApp app) { checkNotNull(app, "FirebaseApp must not be null"); String projectId = ImplFirebaseTrampolines.getProjectId(app); checkArgument(!Strings.isNullOrEmpty(projectId), "Project ID is required to access the auth service. Use a service account credential or " + "set the project ID explicitly via FirebaseOptions. Alternatively you can also " + "set the project ID via the GOOGLE_CLOUD_PROJECT environment variable."); this.baseUrl = String.format(ID_TOOLKIT_URL, projectId); this.jsonFactory = app.getOptions().getJsonFactory(); HttpTransport transport = app.getOptions().getHttpTransport(); this.requestFactory = transport.createRequestFactory(new FirebaseRequestInitializer(app)); }
JvmAuthTokenProvider(FirebaseApp firebaseApp, Executor executor, boolean autoRefresh) { this.credentials = ImplFirebaseTrampolines.getCredentials(firebaseApp); this.authVariable = firebaseApp.getOptions().getDatabaseAuthVariableOverride(); this.executor = executor; if (autoRefresh) { ImplFirebaseTrampolines.startTokenRefresher(firebaseApp); } }
FirebaseProjectManagementServiceImpl(FirebaseApp app) { this.app = app; this.httpHelper = new HttpHelper( app.getOptions().getJsonFactory(), app.getOptions().getHttpTransport().createRequestFactory( new FirebaseRequestInitializer(app))); }
public static FirebaseTokenFactory fromApp( FirebaseApp firebaseApp, Clock clock) throws IOException { return new FirebaseTokenFactory( firebaseApp.getOptions().getJsonFactory(), clock, CryptoSigners.getCryptoSigner(firebaseApp)); } }
/** * Initialize a new set of key managers for the specified app using the given clock. * * @param app A {@link FirebaseApp} instance. * @param clock A {@code Clock} to be used with Google API client. * @return A new {@link KeyManagers} instance. */ public static KeyManagers getDefault(@NonNull FirebaseApp app, @NonNull Clock clock) { HttpTransport transport = app.getOptions().getHttpTransport(); return getDefault(transport, clock); }
/** * Gets the default FirebaseDatabase instance. * * @return A FirebaseDatabase instance. */ public static FirebaseDatabase getInstance() { FirebaseApp instance = FirebaseApp.getInstance(); if (instance == null) { throw new DatabaseException("You must call FirebaseApp.initialize() first."); } return getInstance(instance, instance.getOptions().getDatabaseUrl()); }
FirebaseOptions options = firebaseApp.getOptions(); HttpRequestFactory requestFactory = options.getHttpTransport().createRequestFactory( new FirebaseRequestInitializer(firebaseApp));