Skip to main content Skip to complementary content

Creating a Route as Service Provider with JWT validation using Microsoft Entra ID

Procedure

  1. From the Palette, drag and drop a cBeanRegister, a cREST, a cRecipientList, five cDirect, cSetBody, and cLog components onto the design workspace.
  2. Label the components for better identification of their roles and link the them using the Row > Route connection as shown above.
  3. In the Basic settings view of the cBeanRegister component, enter "customers" in the Id field. Select the Customized option and in the Code box, enter the following code:
    beans.Customers customers = new beans.Customers();
    
    beans.Customer customer = new beans.Customer();
    customer.setFirstName(TalendDataGenerator.getFirstName());
    customer.setLastName(TalendDataGenerator.getLastName());
    customer.setCity(TalendDataGenerator.getUsCity());
    customers.addCustomer(customer);
    
    customer = new beans.Customer();
    customer.setFirstName(TalendDataGenerator.getFirstName());
    customer.setLastName(TalendDataGenerator.getLastName());
    customer.setCity(TalendDataGenerator.getUsCity());
    customers.addCustomer(customer);
    
    customer = new beans.Customer();
    customer.setFirstName(TalendDataGenerator.getFirstName());
    customer.setLastName(TalendDataGenerator.getLastName());
    customer.setCity(TalendDataGenerator.getUsCity());
    customers.addCustomer(customer);
    
    beanInstance = customers;
  4. In the Basic settings view of the cREST component:
    1. Fill the Endpoint field with "/services/customers".
    2. From the Type list, select Manual to determine the REST API mapping manually.
    3. In the REST API mapping table, click [+] to add a row in the table. In the Output Flow field, enter getAllCustomers as the name of it. Select GET in the HTTP Verb list. Keep the default settings in the other columns.
    4. Repeat the previous step to add the output flows getCustomer, addCustomer, updateCustomer, and deleteCustomer with the corresponding HTTP Verb, URI Pattern, Consumers, Producers, and Bean class as shown in the screenshot above.
    5. Select the Security check box and the JWT Bearer Token scheme.
    6. Select Java Keystore (*.jks) in the Keystore Type list.
    7. In the Keystore file field, enter the path to your keystore.
    8. In the Keystore Password field, enter your keystore password.
    9. In the Keystore Alias field, enter your keystore alias.
    10. In the Audience field, enter the Audience value you get from https://login.microsoftonline.com/<tenant ID>/oauth2/token.
  5. In the Advanced settings view of the cREST component:
    1. Select the Log messages check box.
    2. In the JAXRS Properties table, add property "rs.security.signature.algorithm" with the value "RS256".
  6. In the Basic settings view of the cRecipientList component, select Simple from the Language list, and enter "direct:${header.operationName}" in the Expression field.
  7. In the Basic settings view of the cDirect component labeled getAllCustomers, enter "getAllCustomers" in the Name field.
    Repeat this step to enter a name to each cDirect component with the following labels.
    • getCustomer: "getCustomer"
    • addCustomer: "addCustomer"
    • updateCustomer: "updateCustomer"
    • deleteCustomer: "deleteCustomer"
    Type in any string that uniquely identifies the endpoint.
  8. In the Basic settings view of the cSetBody component labeled getAllCustomers, select SIMPLE from the Language list and enter "${ref:customers}" in the Expression field.
    Repeat this step to enter a Simple expression to each cSetBody component with the following labels.
    • getCustomer: "${bean:customers.getCustomer}"
    • addCustomer: "${bean:customers.addCustomer}"
    • updateCustomer: "${bean:customers.updateCustomer(${body[0]}, ${body[1]})}"
    • deleteCustomer: "${bean:customers.deleteCustomer}"
  9. Keep the default settings of the cLog component.
  10. Run the Route in the Studio.
    The REST Service will be available at http://localhost:8090/services/customers/ with JWT validation enabled.
  11. Send a GET Request from Postman.
    1. Select OAuth 2.0 in the Auth Type list.
    2. Select Request Headers in the Add authorization data to list.
    3. Copy the access token you got from https://login.microsoftonline.com/<tenant ID>/oauth2/token in the Token field.
    You will get a successful response from the REST Service.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!