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); } }
void startTokenRefresher() { synchronized (lock) { checkNotDeleted(); // TODO: Provide an option to disable this altogether. tokenRefresher.start(); } }
/** * Initializes a named {@link FirebaseApp} instance using the given options. * * @param options represents the global {@link FirebaseOptions} * @param name unique name for the app. It is an error to initialize an app with an already * existing name. Starting and ending whitespace characters in the name are ignored (trimmed). * @return an instance of {@link FirebaseApp} * @throws IllegalStateException if an app with the same name has already been initialized. */ public static FirebaseApp initializeApp(FirebaseOptions options, String name) { return initializeApp(options, name, DEFAULT_TOKEN_REFRESHER_FACTORY); }
/** * 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()); }
/** * 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()); }
/** * Creates an empty builder. * * @return A new builder instance. */ public static Builder builder() { return new Builder(); }
public FirebaseRequestInitializer(FirebaseApp app) { GoogleCredentials credentials = ImplFirebaseTrampolines.getCredentials(app); this.credentialsAdapter = new HttpCredentialsAdapter(credentials); this.connectTimeout = app.getOptions().getConnectTimeout(); this.readTimeout = app.getOptions().getReadTimeout(); }
/** * 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); }
/** * 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()); }
@NonNull final FirebaseExecutors getFirebaseExecutors(@NonNull FirebaseApp app) { return new FirebaseExecutors(getExecutor(app)); }
public static FirestoreOptions getFirestoreOptions(@NonNull FirebaseApp app) { return app.getOptions().getFirestoreOptions(); }
public static GoogleCredentials getCredentials(@NonNull FirebaseApp app) { return app.getOptions().getCredentials(); }
/** Default constructor. */ private FirebaseApp(String name, FirebaseOptions options, TokenRefresher.Factory factory) { checkArgument(!Strings.isNullOrEmpty(name)); this.name = name; this.options = checkNotNull(options); this.tokenRefresher = checkNotNull(factory).create(this); this.threadManager = options.getThreadManager(); this.executors = this.threadManager.getFirebaseExecutors(this); }
TokenRefresher(FirebaseApp firebaseApp) { this.firebaseApp = checkNotNull(firebaseApp); this.credentials = firebaseApp.getOptions().getCredentials(); this.state = new AtomicReference<>(State.READY); }
/** * Builds the {@link FirebaseOptions} instance from the previously set options. * * @return A {@link FirebaseOptions} instance created from the previously set options. */ public FirebaseOptions build() { return new FirebaseOptions(this); } }
TokenRefresher create(FirebaseApp app) { return new TokenRefresher(app); } }
ScheduledExecutorService getScheduledExecutorService() { return ensureScheduledExecutorService(); }
ThreadFactory getThreadFactory() { return threadManager.getThreadFactory(); }
/** * Initializes the default {@link FirebaseApp} instance using the given options. * * @throws IllegalStateException if the default app has already been initialized. */ public static FirebaseApp initializeApp(FirebaseOptions options) { return initializeApp(options, DEFAULT_APP_NAME); }
/** * Initializes the default {@link FirebaseApp} instance using Google Application Default * Credentials. Also attempts to load additional {@link FirebaseOptions} from the environment * by looking up the {@code FIREBASE_CONFIG} environment variable. If the value of * the variable starts with <code>'{'</code>, it is parsed as a JSON object. Otherwise it is * treated as a file name and the JSON content is read from the corresponding file. * * @throws IllegalStateException if the default app has already been initialized. * @throws IllegalArgumentException if an error occurs while loading options from the environment. */ public static FirebaseApp initializeApp() { return initializeApp(DEFAULT_APP_NAME); }