Android Authenticators

HYPR SDK for Android

build.gradle

The recommended way to install the library for Android is using the build system Gradle.

Do not add custom module dependencies to app/build.gradle. Depending on which authenticators you plan to use, you must add custom library dependencies to app/**<module_name>**/build.gradle.

The following code is a copy of app/build.gradle installed by default during the Quick Start:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        kotlin_version = '1.4.32'
    }
    repositories {
        google()
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    buildscript {

        repositories {
            flatDir {
                dirs 'libs'
            }
            google()
            jcenter()
            mavenLocal()
            if (project.hasProperty('REPO_URL')) maven { url "${REPO_URL}/groups/public" }
            mavenCentral()
        }
    }
    repositories {
        flatDir {
            dirs 'libs'
        }
        if (project.hasProperty('REPO_URL')) maven { url "${REPO_URL}/groups/public" }
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

CustomHyprDbAdapter

Extend a CustomHyprDbAdapter subclass from the existing HyprDbAdapter class to provide helper methods for user management.

public class CustomHyprDbAdapter extends HyprDbAdapter {
    /**
     * Called after a new App Profile is created.
     * Put any DB customizations here for the new App Profile.
     *
     * @param context    current context
     * @param appProfile appProfile object that was just created
     */
    @Override
    public void onNewAppProfileCreated(@NonNull final Context context,
                                       @NonNull HyprAppProfileData appProfile) {
        // customizations go here
    }
}

πŸ“˜

App Profiles

To learn more about App Profiles, see the App Profiles page.

App

Create an App subclass extending the MultiDexApplication class. This will perform the HYPR Setup, which will initialize the HYPR crypto library and initialize your CustomHyprDbAdapter class mentioned above.

public class App extends MultiDexApplication {

    private static CustomHyprDbAdapter sHyprDbAdapter;
    private static boolean             sIsHyprInitComplete = false;

    @Override
    public void onCreate() {
        super.onCreate();
        sHyprDbAdapter = new CustomHyprDbAdapter();

        // HYPR Setup - Initializes the HYPR Crytpo Library
        HyprInit.getInstance().initTrustData(this, new HyprInit.InitTrustDataCallback() {
            @Override
            public void onInstallComplete() {
                Log.d("App", "onInstallComplete");
                sIsHyprInitComplete = true;
                Toast.makeText(App.this, "Crypto Initialization Complete", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onInstallError(@NonNull String error,
                                       @Nullable Throwable throwable) {
                Log.e("App", "onInstallError " + error);
            }
        }, sHyprDbAdapter);
    }

    public static CustomHyprDbAdapter getHyprDbAdapter() {
        return sHyprDbAdapter;
    }

    public static boolean isSetupComplete() {
        return sIsHyprInitComplete;
    }
}

AndroidManifest.xml

Modify the Android manifest. If Android is to use your MultiDexApplication subclass mentioned above, include the App class in AndroidManifest.xml as shown below; otherwise, continue.

<manifest>
  <application
    android:name="<your file path to>/App">
</manifest>