Skip to content
Prev Previous commit
Next Next commit
auto format
  • Loading branch information
AlmostMatt committed Aug 31, 2022
commit 04b4d1a405e63f735cada0496a43c9e9422c3e44
15 changes: 7 additions & 8 deletions app_check/src/attest/app_attest_provider_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* AppAttestCheckProvider}s. This is the default implementation.
*/
class AppAttestCheckProviderFactory : public AppCheckProviderFactory {
public:
/**
* Gets an instance of this class for installation into a {@link
* com.google.firebase.appcheck.AppCheck} instance.
*/
static AppAttestCheckProviderFactory GetInstance();

public:
/**
* Gets an instance of this class for installation into a {@link
* com.google.firebase.appcheck.AppCheck} instance.
*/
static AppAttestCheckProviderFactory GetInstance();

AppCheckProvider* CreateProvider(const App& app) override;
AppCheckProvider* CreateProvider(const App& app) override;
}
4 changes: 2 additions & 2 deletions app_check/src/include/firebase/app_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace app_check {
#ifndef FIREBASE_APP_CHECK_SRC_INCLUDE_FIREBASE_APP_CHECK_H_
#define FIREBASE_APP_CHECK_SRC_INCLUDE_FIREBASE_APP_CHECK_H_

#include "firebase/app_check/app_check_provider_factory.h"
#include "firebase/app_check/app_check_provider.h"
#include "firebase/app_check/app_check_provider_factory.h"
#include "firebase/app_check/firebase_app_check.h"

#endif // FIREBASE_APP_CHECK_SRC_INCLUDE_FIREBASE_APP_CHECK_H_
#endif // FIREBASE_APP_CHECK_SRC_INCLUDE_FIREBASE_APP_CHECK_H_

} // namespace app_check
} // namespace firebase
17 changes: 9 additions & 8 deletions app_check/src/include/firebase/app_check/app_check_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ namespace firebase {
namespace app_check {

/**
* Interface for a provider that generates {@link AppCheckToken}s. This provider can be called at
* any time by any Firebase library that depends (optionally or otherwise) on {@link
* AppCheckToken}s. This provider is responsible for determining if it can create a new token at the
* time of the call and returning that new token if it can.
* Interface for a provider that generates {@link AppCheckToken}s. This provider
* can be called at any time by any Firebase library that depends (optionally or
* otherwise) on {@link AppCheckToken}s. This provider is responsible for
* determining if it can create a new token at the time of the call and
* returning that new token if it can.
*/
class AppCheckProvider {

public:
public:
virtual ~AppCheckProvider();
/**
* Returns a {@link Future} which resolves to a valid {@link AppCheckToken} or an {@link Exception}
* in the case that an unexpected failure occurred while getting the token.
* Returns a {@link Future} which resolves to a valid {@link AppCheckToken} or
* an {@link Exception} in the case that an unexpected failure occurred while
* getting the token.
*/
virtual Future<AppCheckToken> GetToken() = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ namespace app_check {

/** Interface for a factory that generates {@link AppCheckProvider}s. */
class AppCheckProviderFactory {

public:
public:
virtual ~AppCheckProviderFactory();
/**
* Gets the {@link AppCheckProvider} associated with the given {@link FirebaseApp} instance, or
* creates one if none already exists.
* Gets the {@link AppCheckProvider} associated with the given {@link
* FirebaseApp} instance, or creates one if none already exists.
*/
virtual AppCheckProvider* CreateProvider(const App& app) = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ namespace firebase {
namespace app_check {

/**
* Implementation of an {@link AppCheckProviderFactory} that builds {@link DebugAppCheckProvider}s.
* Implementation of an {@link AppCheckProviderFactory} that builds {@link
* DebugAppCheckProvider}s.
*/
class DebugAppCheckProviderFactory : public AppCheckProviderFactory {

public:
public:
/**
* Gets an instance of this class for installation into a {@link
* com.google.firebase.appcheck.AppCheck} instance. If no debug secret is found in {@link
* android.content.SharedPreferences}, a new debug secret will be generated and printed to the
* logcat. The debug secret should then be added to the allow list in the Firebase Console.
* com.google.firebase.appcheck.AppCheck} instance. If no debug secret is
* found in {@link android.content.SharedPreferences}, a new debug secret will
* be generated and printed to the logcat. The debug secret should then be
* added to the allow list in the Firebase Console.
*/
static DebugAppCheckProviderFactory GetInstance();

Expand Down
76 changes: 40 additions & 36 deletions app_check/src/include/firebase/app_check/firebase_app_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
namespace firebase {
namespace app_check {

/// Struct to hold tokens emitted by the Firebase App Check service which are minted upon a successful
/// application verification. These tokens are the federated output of a verification flow, the
/// structure of which is independent of the mechanism by which the application was verified.
/// Struct to hold tokens emitted by the Firebase App Check service which are
/// minted upon a successful application verification. These tokens are the
/// federated output of a verification flow, the structure of which is
/// independent of the mechanism by which the application was verified.
struct AppCheckToken {

/// A Firebase App Check token.
std::string token;
std::string token;

/// A Firebase App Check token expiration date in the device local time.
int64_t expire_time_millis;
Expand All @@ -30,68 +30,72 @@ struct AppCheckToken {
class AppCheckListener {
virtual ~AppCheckListener();
/**
* This method gets invoked on the UI thread on changes to the token state. Does not trigger on
* token expiry.
* This method gets invoked on the UI thread on changes to the token state.
* Does not trigger on token expiry.
*/
virtual void OnAppCheckTokenChanged(const AppCheckToken& token) = 0;
}

class AppCheck {

public:
public:
/**
* Gets the instance of {@code AppCheck} associated with the given {@link FirebaseApp}
* instance.
* Gets the instance of {@code AppCheck} associated with the given {@link
* FirebaseApp} instance.
*/
static AppCheck* GetInstance(::firebase::App* app);

/**
* Installs the given {@link AppCheckProviderFactory}, overwriting any that were previously
* associated with this {@code AppCheck} instance. Any {@link AppCheckTokenListener}s
* attached to this {@code AppCheck} instance will be transferred from existing factories
* to the newly installed one.
* Installs the given {@link AppCheckProviderFactory}, overwriting any that
* were previously associated with this {@code AppCheck} instance. Any {@link
* AppCheckTokenListener}s attached to this {@code AppCheck} instance will be
* transferred from existing factories to the newly installed one.
*
* <p>Automatic token refreshing will only occur if the global {@code
* isDataCollectionDefaultEnabled} flag is set to true. To allow automatic token refreshing for
* Firebase App Check without changing the {@code isDataCollectionDefaultEnabled} flag for other
* Firebase SDKs, use {@link #setAppCheckProviderFactory(AppCheckProviderFactory, bool)}
* instead or call {@link #setTokenAutoRefreshEnabled(bool)} after installing the {@code
* isDataCollectionDefaultEnabled} flag is set to true. To allow automatic
* token refreshing for Firebase App Check without changing the {@code
* isDataCollectionDefaultEnabled} flag for other Firebase SDKs, use {@link
* #setAppCheckProviderFactory(AppCheckProviderFactory, bool)} instead or call
* {@link #setTokenAutoRefreshEnabled(bool)} after installing the {@code
* factory}.
*
*
* This method should be called before initializing the Firebase App.
*/
static void SetAppCheckProviderFactory(const AppCheckProviderFactory& factory) = 0;
static void SetAppCheckProviderFactory(
const AppCheckProviderFactory& factory) = 0;

/**
* Installs the given {@link AppCheckProviderFactory}, overwriting any that were previously
* associated with this {@code AppCheck} instance. Any {@link AppCheckTokenListener}s
* attached to this {@code AppCheck} instance will be transferred from existing factories
* to the newly installed one.
* Installs the given {@link AppCheckProviderFactory}, overwriting any that
* were previously associated with this {@code AppCheck} instance. Any {@link
* AppCheckTokenListener}s attached to this {@code AppCheck} instance will be
* transferred from existing factories to the newly installed one.
*
* <p>Automatic token refreshing will only occur if the {@code isTokenAutoRefreshEnabled} field is
* set to true. To use the global {@code isDataCollectionDefaultEnabled} flag for determining
* automatic token refreshing, call {@link
* <p>Automatic token refreshing will only occur if the {@code
* isTokenAutoRefreshEnabled} field is set to true. To use the global {@code
* isDataCollectionDefaultEnabled} flag for determining automatic token
* refreshing, call {@link
* #setAppCheckProviderFactory(AppCheckProviderFactory)} instead.
*
*
* This method should be called before initializing the Firebase App.
*/
static void SetAppCheckProviderFactory(
AppCheckProviderFactory* factory, bool is_token_auto_refresh_enabled) = 0;

/** Sets the {@code isTokenAutoRefreshEnabled} flag. */
static void SetTokenAutoRefreshEnabled(bool is_token_auto_refresh_enabled) = 0;
static void SetTokenAutoRefreshEnabled(bool is_token_auto_refresh_enabled) =
0;

/**
* Requests a Firebase App Check token. This method should be used ONLY if you need to authorize
* requests to a non-Firebase backend. Requests to Firebase backends are authorized automatically
* if configured.
* Requests a Firebase App Check token. This method should be used ONLY if you
* need to authorize requests to a non-Firebase backend. Requests to Firebase
* backends are authorized automatically if configured.
*/
Future<AppCheckToken> GetAppCheckToken(bool force_refresh) = 0;

/**
* Registers an {@link AppCheckListener} to changes in the token state. This method should be used
* ONLY if you need to authorize requests to a non-Firebase backend. Requests to Firebase backends
* are authorized automatically if configured.
* Registers an {@link AppCheckListener} to changes in the token state. This
* method should be used ONLY if you need to authorize requests to a
* non-Firebase backend. Requests to Firebase backends are authorized
* automatically if configured.
*/
void AddAppCheckListener(AppCheckListener* listener) = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* PlayIntegrityAppCheckProvider}s. This is the default implementation.
*/
class PlayIntegrityAppCheckProviderFactory : public AppCheckProviderFactory {
public:
/**
* Gets an instance of this class for installation into a {@link
* com.google.firebase.appcheck.AppCheck} instance.
*/
static PlayIntegrityAppCheckProviderFactory GetInstance();

public:
/**
* Gets an instance of this class for installation into a {@link
* com.google.firebase.appcheck.AppCheck} instance.
*/
static PlayIntegrityAppCheckProviderFactory GetInstance();

AppCheckProvider* CreateProvider(const App& app) override;
AppCheckProvider* CreateProvider(const App& app) override;
}
15 changes: 7 additions & 8 deletions app_check/src/safetynet/safety_net_app_check_provider_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* SafetyNetAppCheckProvider}s. This is the default implementation.
*/
class SafetyNetAppCheckProviderFactory : public AppCheckProviderFactory {
public:
/**
* Gets an instance of this class for installation into a {@link
* com.google.firebase.appcheck.AppCheck} instance.
*/
static SafetyNetAppCheckProviderFactory GetInstance();

public:
/**
* Gets an instance of this class for installation into a {@link
* com.google.firebase.appcheck.AppCheck} instance.
*/
static SafetyNetAppCheckProviderFactory GetInstance();

AppCheckProvider* CreateProvider(const App& app) override;
AppCheckProvider* CreateProvider(const App& app) override;
}