Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_vL
Product and Topic Expert
Product and Topic Expert

Logon



If you are using SP13 or higher please see Logon SP13+


The Logon plugin manages the onboarding or registration process to the SMP 3.0 server.  When an application onboards to the SMP server, it receives a registration ID (also known as an application connection ID).  In all subsequent requests to the SMP server, the registration id is sent via a header named X-SMP-APPCID or through a cookie that is set following a successful registration.  This enables tracing functionality for each app instance.

Registering using HTTP/HTTPS POST
Registering using the Logon Plugin
Accessing the Values Stored by the Logon Plugin
SAPUI5 Used by the Logon Plugin
Customizing the Logon Plugin's UI

Registering using HTTP/HTTPS POST

The process to onboard to the SMP server can be seen by examining or trying out register.html.  Before trying it out, ensure that an application with an id of com.mycompany.logon has been configured as described in Configuring a Kapsel App in the Management Cockpit and a copy of datajs-1.1.2.min.js is placed into the same folder where register.html is loaded from.  For additional details on datajs and OData see Appendix A:  OData.
Note that since the application com.mycompany.logon uses the No Authentication Challenge provider, any user name and password will work.

The registration ID can be seen in the management cockpit following a successful registration.

If the registration fails one quick test to verify basic connectivity to the SMP 3.0 server from the device or emulator is to open the following URL from a browser on the device or emulator.

http://SMP_Server_IP_Address:8080/sapui5/ or http://SMP_Server_IP_Address:8080

If the above URL opens correctly in a browser on the machine that the SMP server is running on but not from the browser on another machine or on a mobile device there is likely something such as a firewall preventing communication over port 8080.

Another way to register with the SMP server is via REST calls using a plugin to Chrome such as the Advanced REST client.  This is explained in the following post in more detail.  SMP 3.0 : REST API Application Development.

Registering using the Logon Plugin

The SMP server integrates with common security providers such as HTTP/HTTPS Authentication, Directory Service (LDAP), or x.509 User Certificate.  The Logon plugin provides a registration screen where the user can enter values needed to connect to an SMP 3.0 server.  The SMP 3.0 server will validate the registration using one of the security providers and the connection details will be stored in the Logon plugin's secure data vault.  This data vault is separate from storage provided with the Encrypted Storage plugin and is used to store user names, passwords, keys and certificates while the Encrypted Storage plugin is better suited to storing application data.  Another feature of the Logon plugin is the ability to specify a client password policy such as password length and retry limit, which can be centrally managed.  The next sample, register2.html, provides similar functionality to the previous sample except that it uses the Logon plugin which uses native code to communicate to the SMP server and the UI portions are handled by HTML screens created using SAPUI5.  For additional details on the Logon plugin see the JavaScript file in a project that includes this plugin at

project_name\plugins\com.sap.mp.cordova.plugins.logon\www\common\modules\LogonControler.js

or the JS Documentation at Kapsel Logon API Reference.

Note, this example demonstrates using HTTP, however all production apps should use HTTPS.

Note, the Logon plugin can share credentials between apps by interfacing with Client Hub.

The Logon plugin can also receive settings or a certificate from a mobile management solution such as SAP Afaria or SAP Discovery Service.
For additional information on the underlying component that is exposed via the Logon plugin the Developing with MAF Logon section explains how to use the MAF Logon in a native application. 
Perform the following steps to create and run a new Apache Cordova project which includes the Logon plugin.  If you completed the section, Creating an Apache Cordova Project, skip the below step which creates the project.

  • Create the project.
    cordova -d create C:\Kapsel_Projects\LogonDemo com.mycompany.logon LogonDemo "{\"plugin_search_path\":\"C:/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd C:\Kapsel_Projects\LogonDemo
    cordova -d platform add android

    cordova -d create ~/Documents/Kapsel_Projects/LogonDemo com.mycompany.logon LogonDemo "{\"plugin_search_path\":\"/Users/i826567/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd ~/Documents/Kapsel_Projects/LogonDemo
    cordova -d platform add ios
  • Add the Logon plugin and optionally the console plugin so that the results of console.log can be seen when run on an iOS device in the All Output view.
    cordova -d plugin add com.sap.mp.cordova.plugins.logon
    cordova -d plugin add org.apache.cordova.console
    Note, it is possible to use Cordova 4.3.0 with SP08 of the SDK but it requires using the following format when adding Kapsel plugins.
    cordova plugin add com.sap.mp.cordova.plugins.logon --searchpath C:\SAP\MobileSDK3\KapselSDK\plugins
    or
    cordova plugin add C:\SAP\MobileSDK3\KapselSDK\plugins\logon --searchpath C:\SAP\MobileSDK3\KapselSDK\plugins
    or
    cordova plugin add com.sap.mp.cordova.plugins.logon --searchpath %KAPSEL_HOME%\plugins
  • A list of the plugins now included in the project can be seen by entering the below command.
    cordova plugins
    com.sap.mp.cordova.plugins.authproxy 3.8.1 "AuthProxy"
    com.sap.mp.cordova.plugins.corelibs 3.8.1 "CoreLibs"
    com.sap.mp.cordova.plugins.logon 3.8.1 "Logon"
    org.apache.cordova.device 0.3.0 "Device"
    org.apache.cordova.inappbrowser 0.6.0-patched "InAppBrowser"

    Notice that the plugins that the Logon plugin depends on are added if they are not present.  This is defined in
    C:\Kapsel_Projects\LogonDemo\plugins\com.sap.mp.cordova.plugins.logon\plugin.xml
  • If needed, follow the steps shown in Configuring a Kapsel App in the Management Cockpit to create an Application with the application id of
    com.mycompany.logon
  • Replace www\index.html with the contents of register2.html.  Either right-click and choose Save link as or View page source after clicking on the link and copy and paste the contents.

    Note, that the application ID is com.mycompany.logon and is passed in as a parameter to the method sap.Logon.init().  The logonSuccessCallback method stores an object containing the logon parameters into the applicationContext variable.
    function logonSuccessCallback(result) {
        alert("Successfully Registered");
        applicationContext = result;
    }
  • The Logon plugin on Android can write a lot of debugging info to the LogCat.  To reduce this, the console.log line in the method log in the following file can be commented out.
    C:\Kapsel_Projects\LogonDemo\plugins\com.sap.mp.cordova.plugins.logon\www\common\modules\Utils.js
  • Copy the files to the platform directory by running
    cordova -d prepare
    Note, if you are only using one platform when initially developing the application you can modify the platform specific versions of the file and skip the above step.
    To do this using Xcode modify the files under Staging\www.
    To do this using the Android IDE, right click on the project, choose Properties > Resource Filters and delete the two filters.  After this, the folder Assets/www appears where the platform specific files can be modified.
    Note, if you do at some point run cordova prepare, any changes made to the platform specific files will be overwritten.
  • Use the Android IDE or Xcode to deploy and run the project.

    Note, in Android, the HTML files appear under the folder named assets\www.

    Note, if there is a compile error for Android, it may be necessary to select the API level 16 or higher.


    Note, if the Afaria client is opening after calling sap.Logon.init(...), it can be disabled by modifying the file MAFLogonManagerOptions.plist. In Xcode this can be found under Resources > MAFLogonManagerNG.bundle > MAFLogonManagerOptions.plist. Set keyMAFUseAfaria to false.

    Note, if the app on iOS successfully registers in the simulator but not on the device, you may need to add the clienthubEntitlements to the Keychain Groups.  See Sharing Credentials for additional details.

    The registration screen allows a user to enter the connection information for their SAP Mobile Platform server.  The specified values are stored securely and are password protected.  The data vault these values are stored in can be locked and unlocked.  Note that as of SP03, it is possible to use the Logon plugin's data vault without using its features for registering using the sap.Logon.initPasscodeManager method. See the index.html in the Encrypted Storage plugin for a complete example.

    Unregister will delete the registration ID.

  • Note, if the server host, port or application id changes; Logon.core.deleteRegistration() must be called.
  • Note, the user name shown in the management cockpit under Registrations this time is nosec_identity.

  • Note, it is also possible to use the Logon plugin to register against a SAP Netweaver Gateway server.  To do so, simply enter the host, user name, password, port and via the context object specify "communicatorId":"GATEWAY".  Note that when registering against SAP Netweaver Gateway the client password policy can be set by modifying Resources/MAFLogonManagerNG.bundle/MAFLogonOperationContextDefaultValues.plist on iOS.

Accessing the Values Stored by the Logon Plugin

Requests to access an OData source are typically handled by the datajs JavaScript library.  These requests can be proxied through the SMP 3.0 server and when they are, the Logon plugin can be used to provide some of the values required in the request.

sUrl = applicationContext.applicationEndpointURL + "/CarrierCollection?$format=json";  //JSON format is less verbose than atom/xml
var oHeaders = {};
oHeaders['Authorization'] = "Basic " + btoa(applicationContext.registrationContext.user + ":" + applicationContext.registrationContext.password);
oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId;

Perform the following steps to modify the previously created project to add functionality which makes an OData request.

  • Replace www\index.html with the contents of register3.html.
  • Place a copy of datajs-1.1.2.min.js into the www folder.  For additional details on datajs and OData see Appendix A:  OData.
  • Modify the context variable in index.html.  Update the serverHost, user and password values.
  • Copy the files to the platform directory by running
    cordova -d prepare
  • Use the Android IDE or Xcode to deploy and run the project.
    Click on Unlock, Unregister, Register and then Read.  The app had to reregister so that the correct user name and password for the OData source was entered into the Logon plugin.

    When the app is opened, the deviceready event fires and the code in the init() method is called including a call to sap.Logon.init() which will open either the registration screen or the unlock screen.

    The read method will make an OData request to the application's endpoint and will use the user id, password and endpoint URL  (all provided from a successful registration).  It is useful to understand that one set of credentials are being used to register with the SMP server (MyUserName and MyPassword) and another set of credentials are provided by the SMP server when accessing the OData endpoint via the Technical User SSO mechanism configured in the management cockpit.  An alternate configuration would be to use the Basic SSO mechanism with an HTTP/HTTPS authentication provider and then the same user name and password provided to register with the SMP server would also be used to access the backend OData endpoint.

    Note the unlock screen appears after the app is opened after being closed or put in the background.  This ensures that any sensitive data that was displayed on the screen before the app was sent to the background cannot be viewed by someone who does not have the app's passcode.  If the setting Lock timeout is set to a value of 60, this means that if the app is in the background for one minute or more before being brought back to the foreground, the lock screen will appear.

  • Note that on iOS versions greater than 6, the status bar can overlay the contents of the WebView.  The org.apache.cordova.statusbar plugin can be added to prevent this.  See iOS 7 Status Bar Overlays the App.

SAPUI5 Used by the Logon Plugin

The Logon plugin uses the SAPUI5 library when displaying the Registration and Passcode screens.  The SAPUI5 library is located in the following folder.

C:\Kapsel_Projects\LogonDemo\platforms\android\assets\www\smp\logon\ui\resources

If your application is used when the device is always online and you wish to minimize the size of the application, it is possible to load the SAPUI5 library from the public server at https://sapui5.netweaver.ondemand.com/resources and remove the resources folder from your application.  To do this, modify iab.html to load its resources from the public server as shown below.

C:\Kapsel_Projects\LogonDemo\platforms\android\assets\www\smp\logon\ui\iab.html

<script type="text/javascript" src="https://sapui5.netweaver.ondemand.com/resources/sap/ui/thirdparty/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="https://sapui5.netweaver.ondemand.com/resources/sap/ui/thirdparty/jqueryui/jquery-ui-position.js"></script>
<script id="sap-ui-bootstrap" type="text/javascript"
     data-sap-ui-preload="none" data-sap-ui-libs="sap.m"
        data-sap-ui-theme="sap_bluecrystal" src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core-nojQuery.js"></script>

If you wish to make this change permanent so that the change persists after running cordova prepare, make the above changes to the Logon plugin directly.

C:\Kapsel_Projects\LogonDemo\plugins\com.sap.mp.cordova.plugins.logon\www\common\assets\ui

Note that when examining the files that the application has loaded, the SAPUI5 files are now being loaded from the public server.  This means that the device must be online when initially registering and online if the lock and unlock functionality it used and the first time the SAPUI5 files are loaded, the load time will be increased since the files have to loaded over a Wi-Fi or cellular network.

Alternatively if your application uses SAPUI5, you may wish to reference the already included SAPUI5 library from your application.  It may make sense to move the resources folder to the www folder and then modify the three references in the below file to use ../../../resources as shown below.

C:\Kapsel_Projects\LogonDemo\platforms\android\assets\www\smp\logon\ui\iab.html

<script type="text/javascript" src="../../../resources/sap/ui/thirdparty/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../../../resources/sap/ui/thirdparty/jqueryui/jquery-ui-position.js"></script>
<script id="sap-ui-bootstrap" type="text/javascript"
     data-sap-ui-preload="none" data-sap-ui-libs="sap.m"
        data-sap-ui-theme="sap_bluecrystal" src="../../../resources/sap-ui-core-nojQuery.js"></script>

If you wish to make this change permanent so that the change persists after running cordova prepare, make the above changes to the Logon plugin directly.

C:\Kapsel_Projects\LogonDemo\plugins\com.sap.mp.cordova.plugins.logon\www\common\assets\ui

Customizing the Logon Plugin's UI

The text that is displayed as part of the Logon's UI can be modified as the strings are loaded from the file i18n.properties.  The changes can be made to either the original copy of the file so all future projects will contain the changes or on a project by project basis.

C:\SAP\MobileSDK3\KapselSDK\plugins\logon\www\common\assets\i18n\i18n.properties
or
platforms\android\assets\www\smp\logon\i18n\i18n.properties

In addition the strings can be localized by creating additional copies of the above file for different languages.  For example to add French language support make a copy the i18n.properties file and name it i18n_fr.properties.  Make a few changes to some of the text.  The changes can be seen after changing the default language on the device or emulator.  On Android Settings > Language & input > Language > Francais.  On iOS Settings > General > International > Language > Francais.  Redeploy the app.  Note, on Android, the app will have to be removed from memory before it detects the change to the language by pressing and holding the app icon, drag it to the App Info text and then choose Force stop.


If some of the fields that are displayed are not required, they can be removed or placed in a different order.  For example, if your application does not make use of a relay server, a reverse proxy server or connect to an SMP 2.x server, some of the fields can be removed such as URL Suffix, Company ID, and Security Config.  To do so modify the file

www\plugins\com.sap.mp.cordova.plugins.logon\www\common\modules\StaticScreens.js

Find the SCR_REGISTRATION screen and reorder/hide/show fields using visible:false or simply remove unneeded entries.  Note some fields such as FLD_HOST must be present but can be set to visible:false.

fields: {
    user : {
        uiKey:'FLD_USER'
    },
    password : {
        uiKey:'FLD_PASS',
        type: 'password'
    },
    serverHost : {
        uiKey:'FLD_HOST',
    },
    serverPort : {
        uiKey:'FLD_PORT',
        type: 'number',
    }
}


Note the registration screen no longer displays these fields.

In SP03, a method was added that enables a developer to further customize the screens shown by the Logon plugin.  The following example code can be added to register3.html.  This code will enable the Registration screen and the passcode screen to be skipped.  Specifically replace the call to sap.Logon.init with the below code.

//The Logon UI can be customized by adding a custom method to handle showScreen
var logonView = sap.logon.IabUi;
logonView.onShowScreen = customShowScreen;
logonView.onShowNotification = customShowNotification;

sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context, logonView);


Add the following two methods.


function customShowScreen(screenId, screenEvents, currentContext) {
    if (screenId =="SCR_SSOPIN_SET") {
        screenEvents.onskip();
        return true;
    }


else if (screenId =="SCR_UNLOCK") {


        var context = {


            unlockPasscode: "Password1@"


        }


        screenEvents.onsubmit(context);


        return true;


    }


    else if (screenId =="SCR_REGISTRATION") {
        screenEvents.onsubmit(currentContext.registrationContext);
        return true;
    }
    else if (screenId =="SCR_SET_PASSCODE_MANDATORY") {
          var context = {
                  passcode: "Password1@",
                  passcode_CONFIRM: "Password1@"
          }
          screenEvents.onsubmit(context);
          return true;
    }
    else if (screenId =="SCR_SET_PASSCODE_OPT_ON") {
        screenEvents.ondisable();
        return true;
    }
    else if (screenId =="SCR_SET_PASSCODE_OPT_OFF") {
        var context = {};
        screenEvents.onsubmit(context);
        return true;
    }
    return false;  //skip the default value
}

function customShowNotification(screenId, notificationKey) {
    if (screenId == "SCR_SSOPIN_SET" || screenId == "SCR_UNLOCK" || screenId == "SCR_REGISTRATION" || screenId == "SCR_SET_PASSCODE_MANDATORY" || screenId == "SCR_SET_PASSCODE_OPT_ON" || screenId == "SCR_SET_PASSCODE_OPT_OFF" ) {
        alert(notificationKey);
        return true;
    }
    return false;
}







Copy the files to the platform directory by running

cordova -d prepare

Use the Android IDE or Xcode to deploy and run the project and notice that the registration and passcode screens are not shown.
Note, it is typically not a good idea to skip screens such as the registration screen that may require user intervention.

The Logon plugin's screens use the UI library named SAPUI5.  Some customization is possible by changing the CSS files.

www\smp\logon\ui\css\logonForm_debug.css
www\smp\logon\ui\resources\sap\me\themes\sap_bluecrystal

If your Kapsel app uses another UI library it may make sense to use that library to also render the UI screens of the Logon plugin to minimize the size of the application or to keep the UI throughout the application consistent.  The content of the screens are dynamically rendered in the method showScreen(uiDescriptor, context) of

www\smp\logon\ui\LogonForm.js

which is called from

www\smp\logon\ui\iab.html

The below file contains JSDoc comments that describe the parameters to the showScreen method in more detail.

C:\SAP\MobileSDK3\KapselSDK\plugins\logon\www\common\assets\ui\iab.js

The following attached iab.html file is a minimal example that demonstrates how this could be accomplished.  Replace www\smp\logon\ui\iab.html with the above file.
Delete the folders containing SAPUI5.

www\smp\logon\ui\css
www\smp\logon\ui\img
www\smp\logon\ui\resources

Delete the following two files which are now implemented in iab.html.

www\smp\logon\ui\LogonForm.js
www\smp\logon\ui\Notification.js
www\smp\logon\ui\iab.js (SP02+)

Deploy and run the project and notice that the Logon pages are now shown without a UI library.

Back to Getting Started With Kapsel

157 Comments
Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I would try adding the -d option to get additional messages.  Here is what I see.

cordova plugin -d add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

Calling plugman.fetch on plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git"

Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git" via git clone

Fetching plugin via git-clone command: git clone "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git" "C:\Users\i826567\AppData\Local\Temp\plugma

n\git\1427809700955"

Plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git" fetched.

Copying fetched plugin over "C:\Kapsel_Projects\AuthProxyDemo4\plugins\org.apache.cordova.device"...

Plugin "org.apache.cordova.device" fetched.

Calling plugman.install on plugin "C:\Kapsel_Projects\AuthProxyDemo4\plugins\org.apache.cordova.device" for platform "android" with options "{"cli_variables":{}

,"browserify":false,"searchpath":"C:/SAP/MobileSDK3/KapselSDK/plugins/"}"

Installing "org.apache.cordova.device" for android

Install start for "org.apache.cordova.device" on android.

Beginning processing of action stack for android project...

Parsing android project files...

Action stack processing complete.

Running command: C:\Kapsel_Projects\AuthProxyDemo4\platforms\android\cordova\version.bat

Command finished with error code 0: C:\Kapsel_Projects\AuthProxyDemo4\platforms\android\cordova\version.bat

Writing out android project files...

Preparing android project

Processing configuration changes for plugins.

Iterating over installed plugins: [ 'org.apache.cordova.device' ]

Writing out cordova_plugins.js...

Install complete for org.apache.cordova.device on android.

former_member204169
Participant
0 Kudos

Hi daniel.vanleeuwen

I'm following your guide, specially the Register3 example, as I need to customize the UI.

I can skip the screens like you suggest here and the app is automatically logged in with the user and password provided on my context variable.

I was try to NOT skip the USER/PASSWORD screen, as I want to manually enter that data, but I couldn't do it.

When calling

else if (screenId =="SCR_REGISTRATION") {

  showScreen("RegDiv");

  screenEvents.onsubmit(currentContext.registrationContext);

  return true;

  }

all the data is sent automatically. There is any way I can show my login screen and send that information as parameters?

If not, how can I show my own login screen inside index.html? I can customize using iab.html, but I think is not the best approach.

Regards.

Former Member
0 Kudos

Daniel & Friends,

I followed all the steps given but at last I am struck with this error."Uncaught Reference Error: sap is not defined'. on index.html. I added logon plug in properly without any errors.

My cordova version is Cordova 3.4.0-0.1.3.

I am using SMP3.0 SP03, so I used Cordova 3.4.0-0.1.3.

Can you guys pls help me in fixing this issue?

former_member204169
Participant
0 Kudos

Hi Seenu.

Which example are you using? did you added any code in there? if yes, can you share what did you do?

Former Member
0 Kudos

I followed Getting Started with Kapsel - Part 2 -- Logon.

I did not change any code in register2.html.

What happened was: when installing logon plug in, it gave an error while fetching org.apache.cordova.device. So I installed that device plug in manually.

Then I saw all the plugins required as it should be.

Also I am using Android Studio to run the application. It did not show logon plugin in its src.

It shows org.apache.cordova.device & org.apache.cordova.inappbrowser.

I am suspecting that is the problem..looking into it.

Thanks

seenu

former_member204169
Participant
0 Kudos

Try this

cordova plugin remove com.sap.mp.cordova.plugins.logon

and then

cordova plugin add com.sap.mp.cordova.plugins.logon --searchpath C:/SAP/MobileSDK3/KapselSDK/plugins/

After that, you can check if your plugin is installed with

cordova plugin ls

Former Member
0 Kudos

Thanks Manuel.

I got the similar error. Pls see the log..

Microsoft Windows [Version 6.1.7601]

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Seenu\Kapsel_Projects\LogonDemo>cd C:\Seenu\Kapsel_Projects\LogonDemo

C:\Seenu\Kapsel_Projects\LogonDemo>cordova -d plugin remove com.sap.mp.cordova.p

lugins.logon

Calling plugman.uninstall on plugin "com.sap.mp.cordova.plugins.logon" for platf

orm "android"

Uninstalling com.sap.mp.cordova.plugins.logon from android

Beginning processing of action stack for android project...

Action stack processing complete.

com.sap.mp.cordova.plugins.logon uninstalled from android.

Preparing android project

There is no directory "C:\Seenu\Kapsel_Projects\LogonDemo\platforms\android\asse

ts\www\plugins\com.sap.mp.cordova.plugins.logon"

Processing configuration changes for plugins.

Iterating over installed plugins: [ 'org.apache.cordova.device',

  'org.apache.cordova.console',

  'com.sap.mp.cordova.plugins.corelibs',

  'org.apache.cordova.inappbrowser' ]

Writing out cordova_plugins.js...

Deleting plugin com.sap.mp.cordova.plugins.logon

Found 5 removable plugins. Deleting them.

com.sap.mp.cordova.plugins.corelibs deleted.

org.apache.cordova.inappbrowser deleted.

com.sap.mp.cordova.plugins.logon deleted.

C:\Seenu\Kapsel_Projects\LogonDemo>cordova -d plugin add com.sap.mp.cordova.plug

ins.logon --searchpath C:/SAP/MobileSDK3/KapselSDK/plugins/

Calling plugman.fetch on plugin "com.sap.mp.cordova.plugins.logon"

Found com.sap.mp.cordova.plugins.logon at C:\SAP\MobileSDK3\KapselSDK\plugins\lo

gon

Copying plugin "C:\SAP\MobileSDK3\KapselSDK\plugins\logon" => "C:\Seenu\Kapsel_P

rojects\LogonDemo\plugins\com.sap.mp.cordova.plugins.logon"

Calling plugman.install on plugin "C:\Seenu\Kapsel_Projects\LogonDemo\plugins\co

m.sap.mp.cordova.plugins.logon" for platform "android" with options "{"cli_varia

bles":{},"searchpath":"C:/SAP/MobileSDK3/KapselSDK/plugins/"}"

Installing com.sap.mp.cordova.plugins.logon (android)

Dependencies detected, iterating through them...

Dependent plugin "com.sap.mp.cordova.plugins.corelibs" not fetched, retrieving t

hen installing.

Copying plugin "C:\SAP\MobileSDK3\KapselSDK\plugins\corelibs" => "C:\Seenu\Kapse

l_Projects\LogonDemo\plugins\com.sap.mp.cordova.plugins.corelibs"

Dependent plugin "com.sap.mp.cordova.plugins.corelibs" already installed on andr

oid.

Dependent plugin "org.apache.cordova.inappbrowser" not fetched, retrieving then

installing.

Copying plugin "C:\SAP\MobileSDK3\KapselSDK\plugins\logon\inappbrowser" => "C:\S

eenu\Kapsel_Projects\LogonDemo\plugins\org.apache.cordova.inappbrowser"

Dependent plugin "org.apache.cordova.inappbrowser" already installed on android.

Dependent plugin "org.apache.cordova.device" already fetched, using that version

.

Dependent plugin "org.apache.cordova.device" already installed on android.

Dependent plugin "org.apache.cordova.console" already fetched, using that versio

n.

Dependent plugin "org.apache.cordova.console" already installed on android.

Dependent plugin "org.apache.cordova.device-orientation" not fetched, retrieving

then installing.

Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-o

rientation.git" via git clone

Fetching plugin via git-clone command: git clone "https://git-wip-us.apache.org/

repos/asf/cordova-plugin-device-orientation.git" "C:\Users\SAPMEN~1\AppData\Loca

l\Temp\plugman-tmp1432632428242"

Plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientatio

n.git" fetched.

Copying fetched plugin over "C:\Seenu\Kapsel_Projects\LogonDemo\plugins\cordova-

plugin-device-orientation"...

Plugin "cordova-plugin-device-orientation" fetched.

Error: Expected fetched plugin to have ID "org.apache.cordova.device-orientation

" but got "cordova-plugin-device-orientation".


With command cordova plugins:

C:\Seenu\Kapsel_Projects\LogonDemo>cordova plugins

[ 'com.sap.mp.cordova.plugins.authproxy',

  'com.sap.mp.cordova.plugins.corelibs',

  'com.sap.mp.cordova.plugins.logon',

  'cordova-plugin-device-orientation',

  'org.apache.cordova.console',

  'org.apache.cordova.device',

  'org.apache.cordova.inappbrowser' ]

While preparing Android apk, it does not write logon plugin to the config file.

C:\Seenu\Kapsel_Projects\LogonDemo>cordova -d prepare android

cordova library for "android" already exists. No need to download. Continuing.

Generating config.xml from defaults for platform "android"

Calling plugman.prepare for platform "android"

Preparing android project

Processing configuration changes for plugins.

Iterating over installed plugins: [ 'org.apache.cordova.device',

  'org.apache.cordova.console',

  'com.sap.mp.cordova.plugins.corelibs',

  'org.apache.cordova.inappbrowser' ]

Writing out cordova_plugins.js...

Wrote out Android application name to "LogonDemo"

Wrote out Android package name to "com.mycompany.logon"

Thanks

seenu

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Which version of the SMP 3.0 SDK are you using?  You can tell by examining a plugin.xml file such as

C:\SAP\MobileSDK3\KapselSDK\plugins\logon\plugin.xml.

It will contain a version such as

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"

    id="com.sap.mp.cordova.plugins.logon"

    version="3.8.1">

This indicates it is SP08 PL01.

That is the latest available version of the Kapsel SDK.  It should be used with Apache Cordova 4.2.0.

To tell your version of Cordova type

cordova -v

Other than that, another reason why the device plugin may not have been found is if your network uses a proxy to access the internet.  If so, see the section titled Installing Apache Cordova with Node.js at Getting Started with Kapsel - Part 1

Hope that helps,

Dan van Leeuwen

Former Member
0 Kudos

Daniel,

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"

id="com.sap.mp.cordova.plugins.logon"

version="3.0.0.REL6">

Cordova 3.4.0-0.1.3

C:\SAP\MobilePlatform3\smp_product_info says

<product name="SMPServer" version="3.0.3.0" compatibilityVersions="3.0.*">

Will it work with these old versions?

If I download SMP SDK SP07, will this SDK works for SMP3.0 SP03?

Thanks

seenu

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

That might be the original 3.0 release of the SDK with no service packs.


Are you tied to using the SP03 version of the SMP server?


If so, have you tried downloading the SP03 version of the SDK?


If possible, I would recommend not mixing versions of the SDK and server.  Each release of the SDK is likely tested against the latest available SMP server rather than all previous releases.


If you are able to upgrade the server and SDK to the latest available versions that might be best.  Those are server SP07 and SDK SP08, plus any available additional PL for those SPs.

Regards,

Dan van Leeuwen

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

It is possible to reorder or hide fields shown on the registration screen.  Some fields such as the host field can be hidden using visible:false.

It is also possible to remove SAPUI5 if you are not using that framework but as mentioned  that requires customizing iab.html.

In a future release there is some consideration to simplify the Logon plugin API.

Regards,

Dan van Leeuwen

Former Member
0 Kudos

Hey Daniel,

Thnx for the great work, however I run into an issue with the MAF lib when I try to build my App for iOS7+. Is there any patch for this issue besides building it for 6.0 or 6.1?

Undefined symbols for architecture x86_64:

  "std::basic_ios<char, std::char_traits<char> >::widen(char) const", referenced from:

      -[MAFConsoleLogger logMessage:withLevel:andInfo:] in libMAFLogger.a(MAFConsoleLogger.o)

  "std::ostream::put(char)", referenced from:

      -[MAFConsoleLogger logMessage:withLevel:andInfo:] in libMAFLogger.a(MAFConsoleLogger.o)

  "std::ostream::flush()", referenced from:

      -[MAFConsoleLogger logMessage:withLevel:andInfo:] in libMAFLogger.a(MAFConsoleLogger.o)

  "std::ios_base::Init::Init()", referenced from:

      __GLOBAL__I_a in libMAFLogger.a(MAFConsoleLogger.o)

  "std::ios_base::Init::~Init()", referenced from:

      __GLOBAL__I_a in libMAFLogger.a(MAFConsoleLogger.o)

  "std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)", referenced from:

      -[MAFConsoleLogger logMessage:withLevel:andInfo:] in libMAFLogger.a(MAFConsoleLogger.o)

  "std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)", referenced from:

      -[MAFConsoleLogger logMessage:withLevel:andInfo:] in libMAFLogger.a(MAFConsoleLogger.o)

  "std::cerr", referenced from:

      -[MAFConsoleLogger logMessage:withLevel:andInfo:] in libMAFLogger.a(MAFConsoleLogger.o)

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I added the following information to the miscellaneous tips section of the guide. 

Getting Started with Kapsel - Appendix F -- Tips

A linker error may occur if the Deployment Target is changed from 6.0 to 7 or 8 on an Xcode project that contains the Logon plugin. This can be corrected by adding the library "libstdc++.6.0.9.dylib". Under the General tab for the project, click on the + sign in the Linked Frameworks and Libraries section and add "libstdc++.6.0.9.dylib".

Hopefully that helps,

Dan van Leeuwen

Former Member
0 Kudos

Works like a charm! Thnx!

Former Member
0 Kudos

Hi Daniel,

We are having the below observations regarding the SAP Logon plugin. We are not using the default SAP UI screens for registration, but are passing the required user credentials and server parameters as part of the default context passed on to sap.Logon.init function.

  • For iOS, even if the user credentials are wrong, the notification_key raised by the plugin says "ERR_REG_FAILED". Note that this is the same notification_key which is triggered when the server is not reachable. Kindly provide your inputs as for iOS, we are not able to alert the user with the correct error message.

    Note for Android, the notification_key is "ERR_REG_FAILED_UNATHORIZED" if credentials are invalid, and "ERR_REG_FAILED" when server is not reachable.

  • For Android, occasionally, Afaria client crashes when the our application is launched. The sap help blog for Logon plugin does say that for iOS, set keyMAFUseAfaria to false. Although there is no mention about anything on Android. Kindly advice for Android if there is any similar setting change required.

  • Also, in the same blog, it is said to add two entries to the keychain groups under entitlements. However, we are not able to locate this in our Xcode (v6.2). But we are able to build the application and authenticate the users against Active Directory. Just wanted to know if this will create any issue moving further.


*EDIT* - We are using plugin version 3.8.1.

Thank You!

Cheers,

Vigil George

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

<<even if the user credentials are wrong, the notification_key raised by the plugin says "ERR_REG_FAILED"


I saw this as well when I tried it today.  I will see if I can find out more details about this.



<<occasionally, Afaria client crashes when the our application is launched

Is there anything mentioned in the Android LogCat following the crash?  You may need to post the details of the Afaria crash as a new Discussion appropriately titled so that the Afaria experts can find and answer the question.


<< for iOS, set keyMAFUseAfaria to false

I am not aware of an equivalent setting on Android.


<<it is said to add two entries to the keychain groups under entitlements

These settings are related to using the ClientHub application which can be used if you have two applications that want to share the credentials being used.    See also the section titled Sharing Credentials between Application in Getting Started with Kapsel - Appendix D -- Security Part 2


Regards,


Dan van Leeuwen


former_member220979
Participant
0 Kudos

Hi Daniel,

I am using custom login screen along with "Registering using HTTP/HTTPS" approach. In SMP Cockpit, the basic SSO is configured and hence the user will able to see the Login screen once. But then how will I know that the Password expires or any other scenario where I need to show the Login screen again?

Thanks.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I believe during the registration process with the SMP server, the server instructs the client to create a set of cookies some of which persist for the session (until the app is removed from memory) and some are persistent.  The server also has a setting for the session length.  See the value

session-timeout

in

C:\SAP\MobilePlatform3\Server\config_master\org.eclipse.gemini.web.tomcat\web.xml

If you wish to monitor these a tool that I have found helpful in the past is Fiddler.  See also the section on monitoring HTTP/HTTPS requests

Getting Started with Kapsel - Appendix F -- Tips

Some of the examples in this guide simply send the credentials with each request.

//this can be provided by the authproxy plugin if intercept all requests is set to true.  It is by default on iOS but not on Android
oHeaders['Authorization'] = "Basic " + btoa(applicationContext.registrationContext.user + ":" + applicationContext.registrationContext.password);

As mentioned above, the Auth Proxy plugin when the preference is set to true in config.xml can send this header only when needed.

<preference name="SAPKapselHandleHttpRequests" value="true" />

Hope that helps,

Dan van Leeuwen

Former Member
0 Kudos

Hi Daniel,

Great content, very well documented.

I have a question about adding the certificate of the SAP Netweaver Gateway server to the SMP 3.0 server.

Do i have to do it if i m using the trial cloud version? if yes, could you please explain me how to achieve this step?

I m now missing this step , and if i try to register to the server using

Registering using HTTP/HTTPS POST

the registration fails.

Thanks in advance,

Regards,

Moo

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

There is a separate appendix that covers the HCPms trial server.  I hope that contains the info you are looking for.
Appendix M:  SAP HANA Cloud Platform Mobile Services(HCPms)

Regards,

Dan van Leeuwen

Former Member
0 Kudos

Thanks Daniel.

I changed the register.html file following that appendix.

Calling the url :

https://hcpmsadmin-sXXXXXtrial.hanatrial.ondemand.com/applications/latest/com.mycompany.logon/Connec...

returns code 503 :

Service Unavailable

No server is available to handle request for this tenant SXXXXXtrial, or the application is temporarily down for maintenance. Excuse us for the inconvenience.

I can reach the cockpit and other stuff without problems.

former_member220979
Participant
0 Kudos

Is it possible to skip the Passcode screen when register via Logon plugin, if yes then how?

Thanks,

Former Member
0 Kudos

hcpmsadmin is the cockpit URL.  Take the "admin" out to refer to the actual server URL.

hcpms-sXXXXXtrial.hanatrial.ondemand.com...

-Paul Horan-

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I believe there is a portion of this document that describes how to do that.  Search for

This code will enable the Registration screen and the passcode screen to be skipped.


Comment out the portion that deals with registration as you will want the registration screen to appear.


Hope that helps,


Dan van Leeuwen

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Once the user registers, the user name and password used for the registration process is stored in the data vault of the Logon plugin.  If you wish to have the user change their password, there is an API of the Logon plugin that can be called to change the password.

sap.Logon.changePassword


The Logon example in this section I believe simply sends the credentials with each OData request. 

oHeaders['Authorization'] = "Basic " + btoa(applicationContext.registrationContext.user + ":" + applicationContext.registrationContext.password);


I believe the DataJS library also has an option to specify the user name and password.

See

datajs - JavaScript Library for data-centric web applications - Documentation


Alternatively you could enable the AuthProxy setting to intercept all requests (see the authproxy section of the guide http://scn.sap.com/docs/DOC-49623).  It will then handle cases where a request made to the SMP server returns a 401 (unauthorized) and will respond with your credentials.  In this scenario, your code does not need to handle setting the credentials.


Hope that helps,


Dan van Leeuwen




Former Member
0 Kudos

Hi experts,

I have the following questions:

1. What do you prefer to use as gateway system : HCI Odata Provisioning or on-promise       gateway system? if you build your application on HCP.

2. Is the step of adding certificate of the sap netweaver gateway server to the SMP 3.0 server really needed?

   Also in case in a production application when you use the hana cloud connector?

3. On appendix M under paragraph Logon Plugin and Proxied Data :

   In order to use the Logon plugin to register against an SMP server that uses HTTPS,

   the mobile device or simulator will have to trust the certificate that the server is using.

    if i have a production application do i have to install the certificate on each device? assuming i will not use afaria.

Thanks in advance,

Regards,

Moo

former_member220979
Participant
0 Kudos

Hi Dan,

Thanks for the response.

I have another questoin regarding register/unregister process. Following are the high-level steps:

> User register to SMP using Password1.

> User change the password to Password2.

> User want to unregister from SMP now. At this point, do application need to pass Password1 or Password2 for unregistration?

Thanks,

Chirag.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

It may be better to ask the question regarding the gateway systems in a separate discussion so that others may more easily find it and be able to answer.

If you wish to make an HTTPS connection from either the SMP server to another server or from a browser or a kapsel app to the SMP server, the client that is initiating the connection must trust the CA that signed the server it is talking to.  This is described in more detail in the HTTPS subsection of the security appendix.

Getting Started with Kapsel - Appendix D -- Security Part 1

Hope that helps,

Dan van Leeuwen

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Are you using the Logon plugin to do the register and unregister?  Are you seeing an error message when unregistering?

The reason I ask is that the unregister method does not take a user name or password.

sap.Logon.core.deleteRegistration(logonUnregisterSuccessCallback, unRegisterErrorCallback);

The logon plugin stores the user name and password in its datavault so the user does not have to re-enter credentials when performing an unregister.

If you wish to improve the security of the application, you can set a passcode for the application so that a passcode must be entered whenever the application is started or resumed from the background after a certain time limit.

Regards,


Dan van Leeuwen

former_member220979
Participant
0 Kudos

Hi Dan,

I am using "Register/Unregister using HTTP/HTTPS POST" approach. In this approach, the password is passed as part of header. So in this case, does the unregister requires older password or new password?

Thanks.

Former Member
0 Kudos

Hi Daniel,

Thank you for the reply. Any update on the first item regarding ERR_REG_FAILED. Or does this problem still persist in the latest SMP SDK SP09 plugins as well.

Also, is it possible to revoke a registration from SMP Administration console, thereby revoking user access to the application itself?

Regards,

Vigil George

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I imagine the problem still exists in SP09.  I created an internal issue for the dev team so this problem can be tracked and addressed.  The issue number is (BCP 1570801425)

Regards,

Dan van Leeuwen

former_member220979
Participant
0 Kudos

Hi Daniel,

I have used HTTP(S) POST method to register the user to SMP. I am not able to get the user credentials (username/password) in registration success callback.

If I use "Register using Logon plugin" method, I am able to get the user credentials (username/password) in registration callback.

Do I need to set any specific parameter during HTTPS POST method to get the user credentials in success callback. Or Is there any SMP Admin cockpit setting to achieve the same.

Thanks,

Chirag.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Since you control the screen where the user enters their user name and password, I suppose you read those values from the form and then save them once you get to the successmethod.

Regards,


Dan van Leeuwen

Former Member
0 Kudos

Dan ,

I am facing sap is not defined when using

  sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context); in ui5 . plugins are added though.

please suggest

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Are you calling the method after the deviceready event?  If you call it before the Cordova plugins have finished loading that error may occur.

document.addEventListener("deviceready", myInit, false);
function myInit() {
    console.log("In deviceready/myInit");
    sap.Logon.init(...)
}
former_member220979
Participant
0 Kudos

Hi Daniel,

I did not found any blog/detail about how to implement Kerberos SSO authentication with Kapsel Logon.

Please advice.

Thanks,

Chirag.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I have not myself used Kerberos.  I don't believe the Kapsel logon plugin supports this.  It likely is possible to have the SMP server handle the Kerberos authentication so you would need to register your app with an SMP server and have it handle the authentication.

Regards,


Dan van Leeuwen

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

<<even if the user credentials are wrong, the notification_key raised by the plugin says "ERR_REG_FAILED"


I believe a fix was made for this in a yet to be released SP.  In case you wish to try it out, the change was to the file LogonController.js.


} else if (error.errorCode === '401') {

  errorText = "ERR_REG_FAILED_UNATHORIZED";

changed to

else if (((error.errorCode === '401') || (error.errorCode === '403')) || ((error.errorCode === '3') && (error.errorMessage === 'keyErrDescrMAFLogonErrorInvalidLoginData'))) {

Regards,

Dan van Leeuwen

former_member220979
Participant
0 Kudos

Thanks Dan.

former_member183212
Participant
0 Kudos

Hi Daniel,

   do you have idea on the topic,kapsel logon plugin  unlock screen keyboard hide back when first click

thanks,

Billy

ginwene_rueda
Participant
0 Kudos

Hi Daniel,

I cannot pass through the registration screen using an Android device (Android 5.1). I get an error: ERR_REG_FAILED with an errorMessage:

""LogonController.getRegistrationErrorText: {\"errorDomain\":\"MAFLogonCoreErrorDomain\",\"errorCode\":\"-1\",\"errorMessage\":\"java.lang.Exception: Read timed out\"}"", source: file:///android_asset/www/plugins/kapsel-plugin-logger/www/logger.js (653)

But when using an iOS device, there is no problem with the registration process.

Would you know what missed configuration we have in SMP or in Android for this?

Thanks,

Gin

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I would open Chrome on the device and enter the same URL you are using to reach the SMP server such as http://my_smp_server.com:8080 or https://my_smp_server.com:8081

This might not apply if the issue is a timeout ...

Are you using HTTPS?  If so does the device trust the certificate authority that signed the SMP server's certificate?

What version of Android are you using?  Older versions of Android may not support TLS 1.2 which is now enforced by the SMP server.  What version is your SMP server?

One other tool that I like to use to view the traffic between the device and the SMP server is Fiddler.  See also Monitoring HTTP and HTTPS Requests at Getting Started with Kapsel - Appendix F -- Tips

Hope that helps,

Dan van Leeuwen

former_member220979
Participant
0 Kudos

Hi Daniel,

I am working on Kapsel based application that uses Logon plugin to register the user to SMP. One of the requirement in my application is to support switch user account, so that the second user can register himself and start using the application. Switch user account will just log-off the current user, but will not unregister the user.

Step 1. User 1 is registered to SMP successfully and using the app.

Step 2. Further read/write data to backend via SMP automcatically includes following cookies: X-SMP-APPCID, X-SMP-SESSID, X-SMP-SESSIDSSO, X-SUP-APPCID into each request.

Step 3. User 2 switches the account.

Step 4. App send out the User 2 registration request to SMP. The request fails with error "The application is already registered with User 1. User 2 cannot be registered". Further investigation, I found that the REGISTRATION request has correct payload and header data, but the cookies are still User 1 cookies: X-SMP-APPCID, X-SMP-SESSID, X-SMP-SESSIDSSO, X-SUP-APPCID.

What's the correct approach of registering User 2 without unregistering User 1 from the same application?

Thanks,

Chirag.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Unfortunately the Logon plugin does not support multiple users in SP10.  I believe support for this is being worked on but am not sure when it will be available.

At the moment you would need to unregister the user and register a new user to support this use case.

Regards,

Dan van Leeuwen

former_member220979
Participant
0 Kudos

Thanks Daniel.

Vlad
Advisor
Advisor
0 Kudos

It is strange, but the file register.html doesn't work anymore. My platform (SP 10, 3.0.10.2) shows a server-side error (logs do not show anything meaningful). The only way to register the user is to create an XML POST message and send it (in other words, the server doesn't like the empty body).

What is also interesting is that you are not allowed to create as many connections as you can for the same user.

Vlad
Advisor
Advisor
0 Kudos

Is it a bug, or a feature?

former_member220979
Participant
0 Kudos

Hi Daniel,

The sap.Logon.init() fails with error : {"errorCode":"1","errorMessage":"Value does not fall within the expected range.","errorDomain":"MAFLogonCoreCDVPluginErrorDomain"}.

From this link: http://help.sap.com/saphelp_smp306sdk/helpdata/en/8b/1ea0a16d0510148a8bb619db702df1/content.htm, I can see that it's a initialization error. But I cannot find an information about the cause of error and how to fix it.

Thanks.

prakashsaurav
Active Participant
0 Kudos

Hello  Daniel,

Can you please help with below query ?

The specified item was not found.

Regards,

Prakash