Package org.opencabstandard.provider

Java interface files that define the contracts for OpenCab providers.

Overview

An OpenCab provider is a mechanism for communicating between two Android apps running on the same device. One app will be the OpenCab provider app and will implement an Android ContentProvider that implements the appropriate Contract class. The second app will be the OpenCab consumer app and will make calls to the ContentProvider supplied by the provider app.

The Contract and Abstract classes can be found here. You will want to add the relevant classes to your Android project.

For example, an app that will be an OpenCab Identity provider will contain a ContentProvider that implements the IdentityContract. The OpenCab consumer app will make calls to the ContentProvider supplied by the OpenCab provider app. In this example the consumer app may use the results from ContentProvider to SSO into the consumer app with credentials from the provider app.

To aid in implementing the ContentProvider, we have created abstract implementations that handle much of the work for you. For the Identity provider, you may extend the AbstractIdentityProvider class as follows:

 
     public class MyIdentityProvider extends AbstractIdentityProvider {
          @Override
          public IdentityContract.LoginCredentials getLoginCredentials(String version) {
              // Your logic goes here
          }

          @Override
          public ArrayList<IdentityContract.Driver> getActiveDrivers(String version) {
              // Your logic goes here
          }
     }
 
 

An example sequence might be like the following:

sequenceDiagram participant A as OpenCab Consumer participant B as OpenCab Provider participant C as Consumer Auth Service A->>+B: provider.call(METHOD_GET_LOGIN_TOKEN, version: 1) B->>A: loginToken A->>C: Authentication Request w/loginToken C->>A: Authentication Response

Security

The OpenCab provider app must declare the ContentProviders in the manifest with dual authorities. One authority must match the OpenCab AUTHORITY in the appropriate Contract class and the second should be unique to the provider application. The OpenCab consumer app will identify the ContentProvider based on the OpenCab AUTHORITY, but then will use the second authority to make the call to the ContentProvider.

An example of the ContentProvider declared in the manifest:

 
         <provider android:authorities="org.opencabstandard.identity;com.myexample.identity"
             android:exported="true"
             android:label="identity"
             android:name="com.myexample.IdentityContentProvider">
         </provider>
 
 
The OpenCab consumer app must register the OpenCab authorities as queries in the Android manifest as follows:
 
     <queries>
         <provider android:authorities="org.opencabstandard.hos" />
         <provider android:authorities="org.opencabstandard.identity" />
     </queries>