App Profiles

HYPR SDK for Android

Create multiple app profiles to register different RP applications or register multiple users on the same device.

Profile Types

HyprRpAppType is an enum that determines the app profile type. The available types are described here:

TypeDescription
OobOffUsed to authenticate into the web account if you don't use out-of-band setup.
Used by default in createMobileAppUnlockProfile.
WebsiteOnlyUsed to authenticate into the web account.
Used by default in getAllWebProfiles.
WorkstationOnlyUsed to authenticate into the computer.
Used by default in getAllComputerProfiles.
NoneNo app profiles are used.

Returning Lists

The sample uses the following code to return information from HYPR software. A detailed explanation of each function follows the code example.

The file containing the listed code is \app\commonlibraries\src\main\java\com\hypr\commonlibraries\HyprWrapper.kt.

fun offlineAccessInfoForComputer(context: Context, computer: HyprMachineProfileData): HyprOfflineData {
  return computer.getHyprOfflineData(context)
}

fun getAllUsersInCurProfile(context: Context): List<HyprUserProfileData> {
  return HyprApp.getDbAdapter().getCurHyprAppProfileData(context).hyprUserProfileDatas
}

fun getAllComputerProfiles(context: Context): List<HyprAppProfileData> {
  val allProfiles = HyprApp.getDbAdapter().getHyprAppProfileDatas(context)
    return allProfiles.filter { it.hyprRpAppType == HyprRpAppType.WorkstationOnly }
}

fun getAllWebProfiles(context: Context): List<HyprAppProfileData> {
  val allProfiles = HyprApp.getDbAdapter().getHyprAppProfileDatas(context)
    return allProfiles.filter { it.hyprRpAppType == HyprRpAppType.WebsiteOnly }
}

fun getCurAppProfile(context: Context): HyprAppProfileData {
  return HyprApp.getDbAdapter().getCurHyprAppProfileData(context)
}
NamePurpose
offlineAccessInfoForComputerReturns the information required to access the computer while it is offline.
getAllUsersInCurProfileReturns a list of all users, active or not, associated with the selected app profile.
getAllComputerProfilesReturns a list of devices associated with the selected app profile.
getAllWebProfilesReturns a list of web-based app profiles.
getCurAppProfileReturns the selected app profile.

Default App Profile

When the HYPR SDK for Android is initialized for the first time for Mobile App Unlock functionality, a default app profile is created. It is initialized with the following values:

AppProfileName - "App Profile 1"
HyprRpAppType - None

All other values are set to 0, an empty string, or null.

Here is the code:

fun initForMobileAppUnlock(context: Context, rpServerUrl: String, rpAppId: String, onCompletion: (String?) -> Unit) {
  initHYPR(context) { errorString ->
    if (errorString != null) {
    Log.d(LOG_TAG, "Error initializing HYPR: " + errorString)
      onCompletion(errorString)
    } else {
    Log.d(LOG_TAG, "HYPR Initialization successful")
      if (!profileExists(context, rpServerUrl, rpAppId)) {
      createMobileAppUnlockProfile(context, rpServerUrl, rpAppId)
      }
    onCompletion(null)
    }
  }
}

After initialization is finished, do one of the following:

  1. Modify the default app profile.
  2. Create a new app profile and delete the default app profile.

Create a New App Profile

Use the method createMobileAppUnlockProfile to create the new app profile with the parameters described in the table below.

The file containing the listed code is \app\commonlibraries\src\main\java\com\hypr\commonlibraries\HyprWrapper.kt.

fun createMobileAppUnlockProfile(context: Context, rpServerUrl: String, rpAppId: String) {
        val hyprAppProfileData = HyprApp.getDbAdapter().getCurHyprAppProfileData(context)
        hyprAppProfileData.setBaseDomainUrl(context, rpServerUrl)
        hyprAppProfileData.setRpAppId(context, rpAppId)
        hyprAppProfileData.setHyprRpAppType(context, HyprRpAppType.OobOff)
    }
ParameterDescription
rpServerUrlThe URL of your RP Server, e.g., https://9999-pov.hypr.com
rpAppIdThe name of the RP Application that you have created using the Control Center, e.g., HYPRDefaultApplication
HyprRpAppTypeThe version of the HYPR API that you're using.

Example:

public class MainActivity extends AppCompatActivity {

  private void createNewAppProfile() {
    Intent intent = new Intent(MainActivity.this, HyprActionActivity.class);
    
    HyprApiActionData apiActionData = new HyprApiActionData(HyprApiAction.AddAppProfile);
    apiActionData.setAddAppData(new HyprAddAppData(
      <HyprRpAppType>,
      "App Profile Name",
      "RP URL: i.e. https://9999-pov.hypr.com",
      <RP API Version>,
      "RP App ID: i.e HYPRDefaultApplication",
      "Registration Policy Name: i.e androidReg",
      "Authentication Policy Name: i.e androidAuth",
      "Step Up Authentication Policy Name: i.e androidAuthStepUp",
      "Firebase GCM Sender ID", // This is required for a Web App Profile, otherwise it can be null
      false));

    intent.putExtra(HyprActivityResultData.INTENT_KEY_ACTION_DATA, apiActionData);
    activity.startActivityForResult(intent, HYPR_ADD_APP_PROFILE_ACT_REQ_CODE);
  }
  
  // The result is returned here
  @Override
  public void onActivityResult(int requestCode,
                               int resultCode,
                               Intent data) {

    if (resultCode == HYPR_ACT_RES_CODE_SUCCESS) {
      if (requestCode == HYPR_ADD_APP_PROFILE_ACT_REQ_CODE) {
        // New app profile creation was successful
        
      }
    } else {
      if (requestCode == HYPR_ADD_APP_PROFILE_ACT_REQ_CODE) {
        // New app profile creation was not successful
        
      }
    }
  }
}

Modify an App Profile

Use the method modifyAppProfile(HyprAppProfileData appProfile) to make changes in the active profile. See the example below.

public class MainActivity extends AppCompatActivity {

  private void modifyAppProfile(HyprAppProfileData appProfile) {

    appProfile.setAppProfileName(MainActivity.this, "New Profile Name");
    appProfile.setHyprRpAppType(MainActivity.this, <HyprRpAppType>);

    // This should be true for Web and Computer app profiles
    appProfile.setOobEnabled(MainActivity.this, <boolean>);
    
    appProfile.setBaseDomainUrl(MainActivity.this, "RP URL: i.e. https://9999-pov.hypr.com");
    appProfile.setRpAppId(MainActivity.this, "RP App ID: i.e HYPRDefaultApplication");
    
    appProfile.setRpAppActionIdReg(MainActivity.this, "Registration Policy Name: i.e androidReg");
    appProfile.setRpAppActionIdAuth(MainActivity.this, "Authentication Policy Name: i.e androidAuth");
    appProfile.setRpAppActionIdAuthStepUp(MainActivity.this, "Step Up Authentication Policy Name: i.e androidAuthStepUp");

    // This is optional
    appProfile.setRpSendHeaders(MainActivity.this, <String>);

    // These are required for a Web App Profile, otherwise they don't need to be set
    appProfile.setPushAppType(MainActivity.this, <HyprPushAppType>);
    appProfile.setFirebaseGcmSender(MainActivity.this, "Firebase GCM Sender ID");

  }
}

Delete an App Profile

Use the method deleteAppProfile(String appProfileName) to delete the existing app profile. See the example below.

public class MainActivity extends AppCompatActivity {

  private void deleteAppProfile(String appProfileName) {
    Intent intent = new Intent(MainActivity.this, HyprActionActivity.class);
    
    HyprApiActionData apiActionData = new HyprApiActionData(HyprApiAction.DeleteAppProfile);
    apiActionData.setAppProfileName(appProfileName);
    
    intent.putExtra(HyprActivityResultData.INTENT_KEY_ACTION_DATA, apiActionData);
    activity.startActivityForResult(intent, HYPR_DELETE_APP_PROFILE_ACT_REQ_CODE);
  }
  
  // The result is returned here
  @Override
  public void onActivityResult(int requestCode,
                               int resultCode,
                               Intent data) {

    if (resultCode == HYPR_ACT_RES_CODE_SUCCESS) {
      if (requestCode == HYPR_DELETE_APP_PROFILE_ACT_REQ_CODE) {
        // Deleting app profile was successful
        
      }
    } else {
      if (requestCode == HYPR_DELETE_APP_PROFILE_ACT_REQ_CODE) {
        // Deleting app profile was not successful
        
      }
    }
  }
}