Show TOC

Building and Running an Android ProjectLocate this document in the navigation structure

Build and run an Android project for an X.509 certificate provider.

Context

This task references the sample provider project. Alternately, you can use these steps to build your own certificate provider project.

Procedure

  1. Create a Kapsel application with the Logon plugin, and, optionally, the authProxy plugin.
  2. Import the sample certificate provider project into Eclipse.
  3. The sample project depends on the Logon Core's jar file. You can find this either by looking in a Kapsel application that had Logon added to it (in the platforms\android\libs\ directory), or wherever you have the Kapsel SDK files (<sdk folder>\plugins\logon\android\libs). In either case, grab the maflogoncorecdvplugin-<version>.jar file and add it to the libs folder in the Eclipse project. If you are using the sample certificate from file provider, you must also add the maflogoncore-<version>.jar file.
  4. Build the project, and verify that a jar file is created in the bin folder.
  5. Add the jar file from step 3 to the libs folder of the Kapsel application.
  6. Add a clienthub.properties file to the platforms\android\res\raw\ directory. Use a clienthub.properties file identical to the one you would use for registration with a certificate from Afaria. The clienthub.properties file tells the Logon core to use a certificate for registration. Since you will register a provider, you use that that certificate rather than one from Afaria.
  7. Add a line in AndroidManifest.xml:
    <meta-data android:name="certFromFileProvider" android:value="com.example.certificatefromfileprovider.CustomCertificateProvider" />

    Insert this tag inside the application tag:

    <application android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
    <meta-data android:name="certFromFileProvider" android:value="com.example.certificatefromfileprovider.CustomCertificateProvider" />
    <other tags...>
    </application>

    The value in the tag you are adding must match the classpath and name of the class that implements the CertificateProvider interface. If you are using the file provider sample, it is as above. If you are using the system provider sample, it is "com.example.certificatefromsystemprovider.CustomCertificateProvider". If you are implementing your own provider, verify that it matches your class. Use a short, unique descriptive name for the android:name.

    If running on an Android 4.4 device or emulator, add the following permission in AndroidManifest.xml:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
  8. Modify the call to sap.Logon.init(...) in your own Javascript file, add a string parameter at the 6th position. This string must match the android:name from the meta-data tag you added to the AndroidManifest.xml in step 7. This allows the Javascript to specify the certificate provider to be used, while avoiding security concerns about specifying arbitrary classes from JavaScript.
  9. If you are using the file provider (or if you implement your own provider that displays a UI), then you also need to include the SAP UI5 view. In the sample this is the x509ProviderUI.view.js file. Move this file to \platforms\android\assets\www\smp\logon\ui\resources\. Move the i18n.provider.properties to \platforms\android\assets\www\smp\logon\i18n\.