This article discusses how to write and execute your first program on Infosys Equinox using APIs and Java SDK.

Overview

This article describes how to download and run a code sample which creates a valid authentication token to access the microservices of a business. This sample is a simple interactive program which solicits the inputs needed, and then builds the token, and calls Infosys Equinox cloud.

Technical Requirements

You will need Java, Maven and either Spring Tool Suite 4, or a current Eclipse. Instructions to download these tools are found at: Prerequisites for Developing Infosys Equinox Commerce on the Infosys Equinox Developer Portal. You will need to update your Maven’s settings.xml file to include the Infosys Equinox Enablement artifactory, this is included in the above instructions You will need a valid Business in the Infosys Equinox Cloud. If you do not have a Business, send an email, including your name, company, and email address to devportal@infosysequinox.com.

Gather Information About Your Business

We will need the following:

  1. Business ID
  2. Business Secret Keys
  3. API Gate Keys
  4. Store ID
  5. Collection ID for Catalog microservice Catalogs

You need to perform the following steps:

  1. Login to the Admin Console for the Business you are using for testing. Our default instances are at: https://cloud.skavacommerce.com/admin/foundation/login. Login will take you to the page of Businesses you’re enabled to access.
  2. Note the Business ID you’re going to use (e.g. InfosysEquinoxEnablement) and save it:
  3. Click on the Business you’re going to use (e.g. InfosysEquinoxEnablement):
  4. Click on the Keys & Credentials option:
  5. Click on the Show link under Business Secret Keys and API Gateway Keys:
  6. Copy and save the Business Secret Keys and API Gateway Keys:
  7. Navigate to Businesses (select your Business).
  8. Click the Stores tab.
  9. Select your Store:
  10. Click the Service Association tab.
  11. Click on the Edit icon for details for the Catalog Collection:
  12. Note the Collection ID for the Catalog Collection and save it:

Download the Project

Download the sample project from the Infosys Equinox’s BitBucket repository URL: https://bitbucket.org/skava-admin/firstapi/src/master/. For access to the repository, please send an email, including your name, company, and email address to devportal@infosysequinox.com. We will be building the project firstapi. Clone the repository from git. If you are using Eclipse or Spring Tool Suite (STS) import as a general projects, and you should get a project, with Maven sub-projects proper layout. For those working on the command line, the projects should import correctly for Maven. If you need details on setting up maven to resolve the Infosys Equinox SDK, or details on setting up Java or Maven, consult: Setting Up for Development on the Infosys Equinox Developer Portal.

Build the Sample

Build the project. Out of the box, it should build with mvn install or with the standard Eclipse tools.  The main is in MakeTokenAndGetCatalogs.java as a standard Java main. When run, the program solicits you for:

  • Business Secret Key
  • API Gateway Key
  • Business ID

The Collection of your Catalog:

Enter Business Secret Key :
7f4e5027d923007c5-----------315a87
Enter Business id :
50
Claims as json {"created":1655273288832,"actingusername":"0","authorities":"[{\"roles\":{\"ROLE_BUSINESS_ADMIN\":{\"business\":{\"50\":{}},\"type\":\"STANDARD\"}}}]","hash":"46a688dd8e5440c3733d4178e74e5489","username":"xxx"}
admin key with claims : eyJiaWQiOiI1MCIsIm---------------Axd8uKeySNdRjTl4hq42lWnSKvWxaGuM3tc9AwWB42qvC__M--1DzYc-bn5ccZKkGlXsL2HIBota4JVlFV9bgg

Enter api key: <API-key> Enter collectionId: 268 log4j:WARN No appenders could be found for logger (org.springframework.web.client.RestTemplate). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Catalogs response: <200 OK,{“catalogs”:[{“identifier”:”master”,”collectionId”:268,”type”:”MASTER”,”status”:”ACTIVE”,”subType”:null,”sfFilter”:null,”adminFilter”:null,”locked”:null,”startTime”:”2018-08-20T17:14:44.797+05:30″,”endTime”:”2068-08-20T17:14:44.797+05:30″,”createdOn”:null,”createdBy”:0,”updatedOn”:null,”updatedBy”:0,”properties”:[{“createdBy”:0,”createdOn”:null,”updatedBy”:0,”updatedOn”:null,”value”:”master”,”name”:”name”,”locale”:”en_US”}]},{“identifier”:”samsclub”,”collectionId”:268,”type”:”SALES”,”status”:”ACTIVE”,”subType”:”DEFAULT”,”sfFilter”:null,”adminFilter”:null,”locked”:null,”startTime”:”2019-06-13T16:45:00+05:30″,”endTime”:”2050-12-31T00:00:00+05:30″,”createdOn”:null,”createdBy”:0,”updatedOn”:”2019-06-13T22:16:48.331+05:30″,”updatedBy”:334,”properties”:[{“createdBy”:0,”createdOn”:null,”updatedBy”:0,”updatedOn”:null,”value”:”Sams Club”,”name”:”name”,”locale”:”en_US”},{“createdBy”:0,”createdOn”:null,”updatedBy”:0,”updatedOn”:null,”value”:”{\”rules\”:[{\”match\”:\”ALL\”}]}”,”name”:”rules”,”locale”:”en_US”},{“createdBy”:0,”createdOn”:null,”updatedBy”:0,”updatedOn”:null,”value”:”a catalog for sams club”,”name”:”description”,”locale”:”en_US”}]}],”pageableInfo”:{“page”:1,”size”:10,”count”:2,”totalCount”:2}},{Date=[Wed, 15 Jun 2022 06:08:32 GMT], Content-Type=[application/json;charset=UTF-8], Transfer-Encoding=[chunked], Connection=[keep-alive], Server-Timing=[intid;desc=0f3d89838eea7ea3], x-trace-id=[62a977606bdef6d1b41bb314640e484d], x-span-id=[b41bb314640e484d], x-session-id=[ef7ee9074b5f0399cfd0a23904457745], X-Content-Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], Pragma=[no-cache], Expires=[0], Strict-Transport-Security=[max-age=31536000 ; includeSubDomains]}>

Technical Details

JWTs and Shared Secrets

We generate a JWT with business level claims for accessing microservices associated with that business. For details on the JWT specification, see:

Our claims are signed using HS512, and take the form of:

<table>
  <tr>
    <td>[
  {
    "roles": {
      "ROLE_BUSINESS_ADMIN": {
        "business": {
          "50": {

} }, “type”: “STANDARD” } } } ] </td> </tr> </table> This claim asserts it applies to Business ID 50, in the role Business admin, and is a standard role.  The claim has a userid (currently ignored, but soon to be validated) and a timestamp associated with it.

Code

The code is broken into two parts, and includes a tiny helper class to organize the data being passed around. The getCatalogs method is used to fetch catalogs for a given collection, once we have the token. The next methods build the JWT and the main solicits inputs from the user, builds a JWT and gets the collection of catalogs.


Revision History
2022-06-15 | JP – Updated the content.
2022-04-10 | JP – Fixed link and http issues.
2020-03-27 | JP – Minor edits.
2019-06-17 | PLK – Page added and content uploaded.