Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

A few weeks back I posted a teaser here which introduced Kapsel, a set of SMP plugins for Apache Cordova. At the time, I couldn’t say too much about what we were doing as the product hadn’t been formally announced yet. It’s closer to launch, so I can share more details with you now.

Kapsel Plugins

Kapsel is a set of plugins for Apache Cordova which adds SMP capabilities to a Cordova application. The plugins provide a subset of the capabilities provided by the SMP Hybrid Web Container (HWC); this is only an initial release, so additional capabilities will come over to Kapsel over time. Kapsel consists of the following plugins (in alphabetical order just because I like sorted lists):

  • AppUpdate
  • AuthProxy
  • EncryptedStorage
  • Logger
  • Logon
  • Push
  • Settings

The following diagram illustrates how Kapsel fits into a Cordova application architecture:



Figure 1


For some plugins, the SMP server has special server components which work with the Kapsel application to accomplish certain tasks (such as application registration, authentication, application lifecycle management, push notification and remote support). The server and client application work hand in hand to implement these features.

In the sections that follow, I’ll describe each plugin.


Logon


The Logon plugin is Kapsel’s cornerstone plugin; it manages the application registration and authentication processes with/through the SMP server. Most of the Kapsel plugins rely upon services exposed through this plugin, so you will find it installed automatically when you install other plugins.


Logon is essentially a Cordova plugin wrapper around the Logon capabilities exposed by the SMP Mobile Application Framework (MAF). Logon will interact with the Afaria client (if it’s on the device) as well as the Client Hub application (another new feature of SMP which will be described elsewhere) in order to understand the environment’s security configuration and to load certificates (Afaria) and share credentials across applications (Client Hub).


I’ll show you at the end of this article how to use the Logon plugin in your applications.


AppUpdate


One of the biggest benefits of Kapsel and SMP is its ability to allow remote updating of the web application running in the Cordova container. As a developer publishes an update to the web application, the Kapsel AppUpdate plugin will manage the installation of the new version to the Kapsel container.


When the application launches or when the application resumes from having been suspended, the AppUpdate plugin will connect to the SMP server and check to see if an updated version of the application is available. If a new version of the application is available, AppUpdate will download the changes behind the scenes – making sure to only download the changes to the application (only the changed files) rather than the entire web application as it works with the HWC. Once the application has been successfully downloaded, the user is prompted before the installation is initiated and the application restarted. AppUpdate exposes methods which allow an application to manually check for updates and revert the application to its initial state.


AuthProxy


There are certain security-related tasks which the desktop browser takes care of for you, but the Cordova container does not. For example, there’s currently a bug in Cordova which causes a web application to not receive the HTTP error returned from a web server when incorrect credentials are passed to the server during authentication. Kapsel’s AuthProxy plugin provides an alternate mechanism for dealing with this particular issue and also adds capabilities that are leveraged in certain security scenarios such as Mutual Auth and in SiteMinder environments.


EncryptedStorage


Many enterprise mobile applications handle sensitive information and developers have to have a way to store the data in a secure manner. Cordova developers can use the local storage APIs exposed through modern browsers to persist application data, but it’s not secure. The Kapsel EncryptedStorage plugin adds an encrypted key/value pair storage option to Cordova which is non-blocking and uses the same API method signature as the browser’s local storage option.


Logger


No mobile application is perfect; developers need a mechanism which will allow them to collect information from a mobile application while it is running. The Kapsel Logger plugin ads the ability for an application to write log entries which can be automatically uploaded to the SMP server for analysis. Developers build in support for Logger and an administrator can remotely set the appropriate log level from the SMP server – cranking up or cranking down settings which control the amount of information which is written to the log to be remotely collected by the server.


Push & Settings


The Push and Settings plugins are used to add push notification capabilities to a Cordova application. Using the Push plugin, a developer can register an application for push notifications. Once the push registration has been completed, the plugin uses the Settings plugin to exchange application settings information with the SMP server so it knows how to manage delivery of push notifications to the application.


Kapsel CLI


For those of you who know a little bit about Apache Cordova, you may know that with Cordova 3 the Cordova development team included a node.js-based (www.nodejs.org) Command Line Interface (CLI) which dramatically simplifies the Cordova development lifecycle. Since Kapsel aligns with Cordova, the development team added a Kapsel CLI which is installed alongside the Cordova CLI and adds commands to the system for packaging a web application for distribution plus deploying the package to the SMP server.


Supported Platforms


Kapsel is part of the SAP Mobile Platform (SMP) 3 SDK and will support Android and iOS at launch. Support for additional platforms such as Microsoft Windows 8 and BlackBerry 10 are on the roadmap. Kapsel should be available in mid-November, 2013.


Kapsel supports Apache Cordova 3. As Cordova is one of the fastest moving open source projects on the planet, we’re going to have some work to do to keep up. Right now Cordova is releasing 11 versions a year: 1 major version and 10 monthly point releases in-between (the project takes a month off after a major version release which usually happens in the July timeframe). To accommodate this, the Kapsel development team is going to have to move fast to keep up. We’re still working through the plans for this, but as Cordova is updated on a (mostly) monthly-basis, we’re going to have to test against new releases and find a way to deliver updates to customers in a similar cadence as the Cordova project is working in. Stay tuned for additional details on this one.


What about the Hybrid Web Container?


Kapsel is a new hybrid application approach for the SAP Mobile Platform. Our customers have made an investment in the HWC and have many applications in production. The HWC continues to be a supported part of the platform.


Kapsel and the HWC are different; they are both hybrid containers, but are based on different technology. They do different things and they do some similar things in different ways. The HWC for example is a proprietary container that has its own APIs but also supports the Cordova APIs. Kapsel is pure Cordova with some special SMP seasoning added. The HWC delivers the entire web application during an update where Kapsel delivers only the changed files. Kapsel supports only a single web application where the HWC supported many (you can do the multiple app thing in Kapsel, but you’ll need to write a wrapper app which provides a menu and run separate sub-apps within that shell to get the multi-app approach).


With Kapsel, your mobile application consists of the container, any plugins plus your web application content. With the HWC the mobile application is full of a bunch of technology your application might never use. Kapsel applications should be smaller, have a shorter startup time and be more nimble.


My point is that customers can continue to run their existing HWC applications or they can migrate to Kapsel. We think that most customers will want to build new applications on Kapsel.


How does it work?


As you can see, Kapsel provides a broad set of capabilities which help developers build enterprise applications for Apache Cordova. Now that you know what Kapsel is and does, let me show you a bit about how all of this works.

Since the Kapsel plugins are standard, every day Cordova plugins, they install and used the way you would use any Cordova plugin. Developers can use the Cordova CLI or plugman (both part of Apache Cordova) to install the plugins into a Cordova application. Cordova’s plugman is a tool for managing the installation of Cordova plugins into an existing project. As plugman is more for plugin and native developers, so I’m going to focus instead on the CLI in the example which follows.


To use the Kapsel plugins in a Cordova application, you must first create a Cordova application. To do this using the Cordova CLI you open a terminal window, navigate to your development folder and issue the following commands:


cordova create app_name
cd app_name
cordova platform add android ios

where app_name refers to the name of your application. With that in place, add one or more Kapsel plugins as needed. For example, I know Logon is used in most use cases, so I will add it to the project by issuing the following command:


cordova plugin add \path-to-the-Kapsel-installation-folder\logon

Now if you issue the following command:


cordova plugins

The CLI will respond with the list of plugins which have been added to the application as shown below:


[ 'com.sap.mp.cordova.plugins.corelibs',
  'com.sap.mp.cordova.plugins.logon',
  'org.apache.cordova.console',
  'org.apache.cordova.device',
  'org.apache.cordova.device-orientation',
  'org.apache.cordova.dialogs',
  'org.apache.cordova.inappbrowser' ]

Notice how there is more installed than expected; in this case, the CLI added some core Cordova plugins (console, device, device-orientation, dialogs & inAppBrowser). CoreLibs is a utility plugin which is added automatically to every Kapsel project by the CLI. A developer would never need to add the plugin manually to a project.


Now, to use Logon in your application, you only have a few, simple things to do.


First of all, Kapsel uses an AppID to identify to the server which application definition on the server is being used by this application. So my application starts off by defining a variable which describes the AppID. The AppID on the server must match what’s entered here.


var appId = "com.sap.kapsel.mykapselapp";

Next, the Logon plugin needs to know a little bit about its connection to the server. It’s smart enough to figure out a lot of things, but it sure saves time if you give it a little push:


var defaultContext = {
  "serverHost" : "192.168.254.159",
  "https" : "false",
  "serverPort" : "8080",
};

What this does is essentially prepopulate fields in the registration dialog which is displayed to users during the initialization process.

All that’s left to do is make a call to the Logon plugin’s init method as shown below:


//Make call to Logon's Init method to get things registered and all setup
sap.Logon.init(logonSuccess, logonError, appId, defaultContext);

What init will do is figure out all sorts of interesting stuff about the environment’s security configuration (by asking the Afaria client and Client Hub application if available), setup and configure the DataVault, connect to the server to register the application connection and authenticate the user. As part of this process, the appropriate screens will be displayed to gather user input and manage the entire process.


The logonSuccess and logonError values passed to init are the names of callback functions which will be executed on Logon success or failure respectively. This API (and the other APIs exposed by the Kapsel plugins) operates this way because this is the way most of the Cordova APIs are implemented as well; with APIs operating asynchronously and executing success or failure via callbacks when done. Kapsel therefore works just like most any other Cordova API a developer may be using.


Logon’s screens (and associated flow) are built entirely using HTML5, so they can be customized by the developer to match the specific needs of the application and the organization.


Wrap-Up


This is just a hint of the capabilities Kapsel provides. There’s a whole lot more that I need to tell you about Kapsel, stay tuned for more information. I have a whole series of articles to write and post here to help you understand as much as possible about Kapsel. I will also be writing a series of white papers which cover several topics in greater detail.

6 Comments