App Profiles
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:
Type | Description |
---|---|
OobOff | Used to authenticate into the web account if you don't use out-of-band setup. Used by default in createMobileAppUnlockProfile . |
WebsiteOnly | Used to authenticate into the web account. Used by default in getAllWebProfiles . |
WorkstationOnly | Used to authenticate into the computer. Used by default in getAllComputerProfiles . |
None | No 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)
}
Name | Purpose |
---|---|
offlineAccessInfoForComputer | Returns the information required to access the computer while it is offline. |
getAllUsersInCurProfile | Returns a list of all users, active or not, associated with the selected app profile. |
getAllComputerProfiles | Returns a list of devices associated with the selected app profile. |
getAllWebProfiles | Returns a list of web-based app profiles. |
getCurAppProfile | Returns 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:
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)
}
Parameter | Description |
---|---|
rpServerUrl | The URL of your RP Server, e.g., https://9999-pov.hypr.com |
rpAppId | The name of the RP Application that you have created using the Control Center, e.g., HYPRDefaultApplication |
HyprRpAppType | The 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
}
}
}
}