Browse Category by Cloud
View Post

Oracle MAF: Oracle MCS as authentication provider

An usual requirement when working with Oracle Mobile Application Framework and Oracle Mobile Cloud Service is implement the login against Oracle MCS.
In this post I am going to show you how to configure Oracle MCS as an authentication provider in Oracle MAF.

  • Creating a Realm
A realm is a security context for a ser of users. We can have only one realm for each Mobile Backend, but we can have multiple Mobile Backend using the same realm.
Using one or more realm in MCS will depend on what users we will like to give access to our application.
Under Applications, we can find Mobile User Management. By default there is one realm named ‘default’, but we can create a new one by clicking on ‘New Realm’ button.
In the realm we can find some user information by default altough we can add more properties.

  • Create and configure a Mobile Backend
A Mobile Backend (MBE) is the gateway to Mobile Cloud Service. If we want to access any available resource from MCS, for example an API, we have to do it though an MBE.

We can find Mobile Backends option under Applications menu option.

Click on ‘New Mobile Backend’ to create a new one.

Once you have created the MBE head to Users option and click on ‘Change user realm’, by default the MBE has a realm but in this case we need to set the new realm we have just created. This is not the case, but we can also set a default realm for every new created MBE.

In the popup we can select any existing realm.

After that, as there is no users in the realm you can add them by clicking on ‘Add New User’ button.

You will receive an email to the email address you used to register the user.
  • Configuring a MAF Application.
The last step is to configure the MAF application. Here is a couple of things that we have to do.
First we need to create a secured page. We can do it in maf-feature.xml
The last thing is to configure the login server.
To do this, we need to open maf-aplication.xml. We can find the file in ‘Application Resources’ under descriptors/ADF META-INF folder.
Click on the add button.

In the popup we have to select HTTP Basic as Authentication type and set a name to the connection.

In HTTP Basic tab we need to configure login and logout URLs.
To build this URLs we need to know the base URL, and add to it at the end ‘/mobile/platform/users/login’ in Login URL and “/mobile/platform/users/logout” in Logout URL.
We can check the base URL in MBE Settings menu option.

The last step in the cofiguration is to add a custom header. The header name will be ‘Oracle-MobileBackend-ID’ and the value can be also found in MBE Settings menu option.

We just have to execute the application. As soon as we do it, the login page will appear.
If we set the right credentials we will access our secured page.
But if we enter wrong credentials we will se a’Invalid username or password.’ error message.



Overview of Oracle Sites Cloud Service

At the end of 2015 Oracle launched Oracle Sites Cloud Service. With this product you can create sites in no time. If you have an active account of Oracle Documents Cloud Service, it is since mid February available as a menu option.

This is the main page and the menu we can find in Sites Cloud.

The first thing we are going to do is to create a new Theme. We can base it in a preexisting template provided by Oracle, or create a new one.

We can see all and download the files of our theme.

Now we are ready to create a new Site.

When the site is created we can see that the site is by default offline, and we can also edit or rename our site.
By clicking Edit link button we can see the site composer.

Before editing we have to click on the toggle button in the top toolbar.

We can drag and drop some predefined components into our site and then configure them. For example, after dragging and dropping an image component

We can select an existing image uploaded in our Oracle Documents Cloud Service, or upload a new one.

We can also configure the structure of the site by adding new pages. We can also set sub menu options.

When we have finished our site, we can activate it by clicking in Offline link and confirming the popup.

As you can see it is so easy and fast to build a site.

The site created is also responsive and can be perfectly seen in mobile browsers.

PCS: Starting a process instance remotely

While implementing an Oracle Process Cloud Service PoC we had the requirement to allow users to start an instance using a form in their custom mobile application and also using the workspace.
We have a ‘Form Start Event’ so users can start the instance thought the workspace. We also added a ‘Message Start Event’ in order to publish it as a web service.
Having that process deployed, if we head to ‘Deployed Applications’ in workspace main page.

And click on the button in ‘Actions’ column.

We can see the web services exposed.

If we use that wsdl url in soapui we see that we have 2 operations, one for each of the start events.

Executing both, we can see that even using ‘Form Start Event’ we can start a process instance remotely as an operation is automatically created in the web service, so we can remove the ‘Message Start Event’ as we can meet both requirements just using the ‘Form Start Event’.

If we open aproval form in the workspace we can see that the data sent from soapui has been successfuly sent.

Oracle Mobile Cloud Service: Create an API that calls a REST web service

In the lasts post about Oracle Mobile Cloud Platform I already told that you can connect to a external SOAP/REST web service, but you have to do it through a connector. We have also to keep in mind that with REST API or Android/iOS SDK you cannot call directly a connector, you have to call a custom API that will make the call to that connector so we will also have to make a implementation of out custom API using node.js.
You can download this example from my Github repository.

In this post I am going to show with a quick example  how easy is to create an API that makes a call to an external REST web service.

The steps we are going to do are:

  1. Create a Mobile Backend (MBE)
  2. Create a Connector
  3. Create, design and implement an API.

Create a Mobile Backend (MBE)

A Mobile Backend is the gateway through we will make any API (custom or platform) call, so the first step is to create one.
In the Developer Portal we have to make click on Mobile Backend and in the next page we have to click on “New Mobile backend” and fill the required fields like name and description.

Create a connector
A connector will let us to make a external webservice call from MCS, so in the Developer Portal we have to navigate to Connectors.
In connectors page we have to click on “New Connector”, as type we pick REST and then we fill the name and the web service url.

In this example I have picked a public rest weather API:

api.openweathermap.org/data/2.5/weather?q=Madrid

Once we have created the connector we can skip until the last step, “Test” and just click on “Test Connector” to test our connector.

As you can see the web services give us weather data of Madrid as we put ‘Madrid’ in the url parameter.

Now we have connected MCS with a external web service, but as you can imagine we should make our connector parameterized so we don’t have to create a connector per city.

we have to make a couple of things to get it working:

First we have to edit the connector url and remove “?q=Madrid” from it.

And we have also to add a rule to our connector. To do this we have to go to rules step in our connector and click on add new rule.
In this case we are going to add a new parameter that will be associated to all the calls that we will make to this connector.
It is possible to associate a rule to a specific resource or a certain HTTP methods.

Now we are going to test that our connector works with the parameter.
We have to navigate to ‘Test’ and fill the input next to ‘Local URI’ with ‘?q=Barcelona’.
If we don’t fill the input the connector would use the default value we set in the rule.

As you can see the call has been successfuly made and the connector gives us the weather of Barcelona.

Create, design and implement an API

In the last step we are going to create an API that will call the connector.
Inside our MBE we have to create a new API.

We have to fill the name of the API and click on ‘Create’

Now that we have created the API, we have to design it.
In order to call the API anonymously so we can avoid creating any users or roles we have to head to Security and select ‘Allow Anonymous User Access’.

The next thing we have to do is define the endpoint of our API.
Our endpoint is going to have a parameter that we will define as {ciudad}. We have also to define endpoint methods.

In this case we are going to create a GET method so we have to click on ‘Add method’ button and select ‘GET’. At this point we can define the diferent responses that we want and add mock data so our mobile application developer can start building the app. 

As we are not going to use any static data and we are going to make a call to the connector we are not going to add any response.

Now we click on ‘Save’ and then head to ‘Implementation’.
Here we can implement our API logic using node.js by downloading a JavaScript Scaffold.

The JavaScript Scaffold is a zip file that contains:
  • package.json: This is a config file where we can add the API dependencies.
  • tiempoporciudad.js: This is the javascript file where we will add the logic to our API. The name is the same as the API in MCS.
  • samples.txt:  This file contains some implementation examples.
To start the implementation we have to add the connector as a depencency to our API. So we have to edit package.json and add the connector URI and connector version.
After that we will edit the lavascript file tiempoporciudad.js.
The point here is to get the parameter (ciudad) of the request and execute a GET call to the connector passing the value we get as parameter. The last thing is to include the response of the connector’s call in the API response,

Once we have our API implemented we have to put both files inside the zip that we downloaded and upload it to MCS.

At this point we have created the Mobile backend, we have connected to a external web service using a connector and we have created an API associated to the Mobile backend that makes a call to the connector.

The last step is to test our API to see if everything works fine.
We have to head to our API and click on ‘Test’ button and fill the name of the city. We will use Barcelona again to test.

If we click on ‘Test Endpoint we can see that the API returns the weather of Barcelona.

Oracle Fusion Middleware Summer Camps 2015: Mobile Cloud Service

Last week I had the opportunity to attend to Oracle Fusion Middleware Summer Camps in Lisbon that Oracle organizes for EMEA partners. This year was the fifth edition and there were many new Oracle PaaS products to choose: Integration Cloud Service, Process Cloud Service, Java Cloud Service and the one I attended, Mobile Cloud Service. 

I have to say that it was the very first in class MCS training.

Oracle Mobile Cloud Service course was delivered by Frank NimphiusGrant Ronald (Oracle Product Management Team) and Jürgen Menge (Oracle Sales Consultant).

From the first minute we could start playing with MCS and also try the functionallity with a MAF application.

If you want to know MCS functionality you can check my previous post: Oracle Mobile Cloud Service overview.


Having such great trainers, we learnt some advices, good practices and tricks when using MCS. We saw a lot of interesting things, here comes some of them:

  • Notifications

MCS offers an API that allow us to abstract of the providers and fully manages notifications.
We can also send notifications to users in a specific role or platform, schedule notifications and monitor to see if notifications have been sent.

  • Cache and offline 

Thanks to the API we have a cache in the client that allow us to manage the synchronization with policies and also working in offline mode. We can get better performance, better usability, decrease network usage and increase battery life.

  • REST API y SDKs

With REST API and the SDKs we can call MCS Platform API and the custom API that we will create to integrate our applications with external systems. In future releases a JavaScript API will be available.

  • Analytics

Besides having metrics of all the API calls that our application make, we can also create our own events and funnels. We can use these, for example, in our mobile shopping application to know the step where users leave, evaluate the process and improve it.

 I would like to thanks Jürgen Kress for the great organization of the event and all the trainers for the outstanding tranning. See you next summer camp!!

  • 1
  • 2