Show TOC

Preparing the Hybrid SDK (Kapsel) Application for Afaria ProvisioningLocate this document in the navigation structure

To prepare the Hybrid SDK (Kapsel) application to be provisioned through Afaria, provide an initial context to the Login plugin, and specify an application ID configured on SAP Mobile Platform Server with an X.509 security profile.


Specify information needed for provisioning in these files:

  • The file (for Android) or clienthub.plist file (for iOS) provide an initial context to the Login plugin and instruct the Login plugin that it is to use a certificate from Afaria for authentication.
  • The index.html file specifies an application ID that must match an application ID on the SAP Mobile Platform Server that is configured with a security profile for X.509 authentication.
  • The MAFLogonManagerOptions.plist file contains the setting, keyMAFUseAfaria, that affects the logon page when Afaria installed on a device.


  1. Create an index.html which specifies an application ID that is configured on SAP Mobile Platform Server with a security profile for X.509 authentication. The following is a sample index.html:
            <script src="datajs-1.1.1beta2.js"></script>
            <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
                applicationContext = null;
                var appId = "certAuth"; // Change this to app id on server
                function init() {
                    // Optional initial connection context
                    var context = {
                        "serverHost": "example.corp", //Place your SMP 3.0 server name here
                        "https": "false",
                        "serverPort": "8080",
                        "user": "username", //Place your user name for the OData Endpoint here
                        "password": "xxxxxxx",  //Place your password for the OData Endpoint here
                        "communicatorId": "REST",
                        "passcode": "password",
                        "unlockPasscode": "password"
                    sap.Logon.init(logonSuccessCallback, errorCallback, appId, context, sap.logon.IabUi);
                    console.log("init completed");
                function read() {
                    var url = applicationContext.applicationEndpointURL;
    				var logonCert = new sap.AuthProxy.CertificateFromLogonManager(appId);
    				var headers = {};
    				var errorCB = function(errorInfo){
    					alert("error: " + JSON.stringify(errorInfo));
    				var successCB = function(result){
    					alert("success: " + JSON.stringify(result));
                function readSuccessCallback(data, response) {
    				alert("success: " + JSON.stringify(data));
                    /*var carrierTable = document.getElementById("carrierTable");
                    for (var i = data.results.length -1; i >= 0; i--) {
                        var row = carrierTable.insertRow(1);
                        var cell1 = row.insertCell(0);
                        var cell2 = row.insertCell(1);
                        cell1.innerHTML = data.results[i].carrid;
                        cell2.innerHTML = data.results[i].CARRNAME;
                function clearTable() {
                    var carrierTable = document.getElementById("carrierTable");
                    while(carrierTable.rows.length > 1) {
                function logonSuccessCallback(result) {
                    console.log("logonSuccessCallback " + JSON.stringify(result));
                    if (result) {  //calling registerOrUnlock returns null the second time it is called.
                        applicationContext = result;
                function logonLockSuccessCallback(result) {
                    console.log("logonLockSuccessCallback " + JSON.stringify(result));
                    applicationContext = null;
                function logonUnregisterSuccessCallback(result) {
                    console.log("logonUnregisterSuccessCallback " + JSON.stringify(result));
                    applicationContext = null;
                function register() {
                    sap.Logon.registerOrUnlock(logonSuccessCallback, errorCallback);
                function unRegister() {
                    sap.Logon.core.deleteRegistration(logonUnregisterSuccessCallback, errorCallback);
                function lock() {
                function errorCallback(e) {
                    alert("An error occurred");
                function unlock() {
                document.addEventListener("deviceready", init, false);
            <h1>Logon Sample</h1>
            <button id="register" onclick="register()">Register</button>
            <button id="read" onclick="read()">Read</button>
            <button id="unregister" onclick="unRegister()">Unregister</button>
            <button id="lock" onclick="lock()">Lock</button>
            <button id="unlock" onclick="unlock()">Unlock</button>
            <table id="carrierTable"><tr><th>Carrier ID</th><th>Carrier Name</th></tr></table>
  2. In the MAFLogonManagerOptions.plist file change the value of the keyMAFUseAfaria setting to NO to support the display of the logon screen in the Hybrid SDK (Kapsel) application.