# Getting started

# Prerequisites

Before you can get started, you must first install the following software:

Minimum Android version

The minimum supported Android version for the Encap SDK is Android 7.0.

# Add the SDK to your application

Note

The Encap SDK is available from our repository. The repository is gated, therefore you require login credentials to access it.

You need to add the Encap client API to the application using Android studio and Gradle. To do this:

  1. Request your Nexus repository login credentials from us at support@signicat.com.

  2. Once you have obtained access, you can set your Nexus repository login credentials:

    1. Navigate to $HOME/.gradle/gradle.properties.
    2. Set the following credentials:
      mavenUser=YOUR_NEXUS_REPOSITORY_USER_ID
      mavenPassword=YOUR_NEXUS_REPOSITORY_PASSWORD
      
  3. Add Encap as dependency to the app's build.gradle file:

dependencies {
    implementation 'com.encapsecurity:encap-android-api:3.18.3@aar'
}
  1. Add Encap as custom repository in your project's build.gradle file.
    • For Encap SCA customers:
    allprojects {
        repositories {
            maven {
                credentials {
                    username mavenUser
                    password mavenPassword
                }
                url "https://nexus.pub.encap.no/content/repositories/encap-partner-repository"
            }
        }
    }
    
    • For MobileID customers:
    allprojects {
        repositories {
            maven {
                credentials {
                    username mavenUser
                    password mavenPassword
                }
                url "https://nexus.pub.encap.no/content/repositories/MobileID-partner"
            }
        }
    }
    

# Loading the library

Before you can use the library, it needs to be loaded. You need to do this in a way where the library is only loaded once.

For example, you could implement this in Java using the following code:

public class MyApp extends Application {
    static {
        System.loadLibrary("encap-android-native-api");
    }
}

# Create controller

The main interface of the Encap client API is the Controller. The operations that you can execute with the controller usually come in pairs, and are comprised of a start and finish call. For example startActivation() and finishActivation().

You can obtain the Encap controller instance using AndroidControllerFactory or AndroidLoggingControllerFactory, which are based on a singleton pattern. There can only be one instance of a specific controller with a certain name.

The first call will always create a controller. Any other calls after that will return the previously created instance.

The Controller can be created using AndroidControllerFactory:

if (DEBUG) {
    debugController = AndroidLoggingControllerFactory.getInstance(getBaseContext(), "BankOne");
} else {
    controller = AndroidControllerFactory.getInstance(getBaseContext(), "BankOne");
}

The log produced by AndroidLoggingControllerFactory in the code example above is available using standard Android tools.

For example, you could use the logcat tool, with tag Encap and a message level of INFO.

Notice for production

For production, you should use the no-logging factory AndroidControllerFactory and optimise/obfuscate the application so that unused classes are removed.

Note

Controllers do not share any information between themselves, so it is not possible to perform registration migrations.

A created registration will only be available on the specified controller which is identified by a name.

# Configure the controller

To configure the controller, you need to create a new instance of EncapConfig, and set that on the controller.

There are three settings that you always need to provide, whereas the other settings are optional.

For example, you could configure the controller like this:

controller.setConfig(new EncapConfig.Builder()
    .setServerUrl("https://serverurl.com")  // Required
    .setApplicationId("MyApplicationId")	// Required
	.setPublicKeyBase64(E2EE_KEY)			// Required
    .setConnectionTimeout(20000)
    .setClientOnly(false)
    .setPublicKeyHashes(hash)
    .setPushToken(token)
    .setAllowDebugData(true)
    .build());
Last updated: 29/02/2024 13:39 UTC