Last modified by Eva Torken on 2023/09/20 13:51

Show last authors
1 {{container}}{{container layoutStyle="columns"}}(((
2 This microlearning will teach us how to use certificates (both trust as client) when sending data to a REST web service. In a previous course, we introduced the concept of certificates and learned about sending certificates to a SOAP web service. If you need a refresher, please check out that [[course>>doc:Main.eMagiz Academy.Microlearnings.Novice.Securing Data Traffic.WebHome||target="blank"]]. We will build upon that knowledge in this microlearning and apply our expertise to the world of REST web services.
3
4 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]].
5
6 == 1. Prerequisites ==
7
8 * Intermediate knowledge of the eMagiz platform
9 * Basic knowledge of certificates. More information can be found [[here>>doc:Main.eMagiz Academy.Microlearnings.Novice.Securing Data Traffic.WebHome||target="blank"]] in the Novice course on the subject.
10
11 == 2. Key concepts ==
12
13 This microlearning centers around sending certificates when calling a REST Webservice.
14 By certificates, we mean: A trustworthy document that is interchanged between parties to verify that both parties are whom they claim to be
15
16 In most cases, when you send a certificate to a REST service, we talk about sending a client certificate along with the REST service call. In some cases, however, the endpoint we call is not secured via a certificate chain containing a known CA. In those cases, we need to explicitly trust the party to whom we are sending data by placing data in the truststore.
17
18 In another microlearning, we will learn how to create the Keystore and truststore. The focal point of this microlearning is how you need to configure eMagiz correctly to make this work.
19
20 == 3. Sending certificates to a REST web service ==
21
22 This microlearning will teach us how to use certificates (both trust as client) when sending data to a REST web service. In a previous course, we introduced the concept of certificates and learned about sending certificates to a SOAP web service. If you need a refresher, please check out that [[course>>doc:Main.eMagiz Academy.Microlearnings.Novice.Securing Data Traffic.WebHome||target="blank"]]. We will build upon that knowledge in this microlearning and apply our expertise to the world of REST web services.
23
24 We need a support object to ensure that the proper certificates are sent along with the call to the REST web service. Support objects are components in eMagiz that support the working of other elements. In this case, we need a REST Template as our support object.
25
26 === 3.1 REST Template ===
27
28 When you navigate to the Create phase, you can open an exit flow and see whether you already have an HTTP outbound component within your exit flow. If not, please add an HTTP outbound component (gateway or channel adapter) to the flow. In a previous microlearning, we focused on these components so that we won't focus on these components in this microlearning.
29
30 To ensure that specific authorization is added to this HTTP outbound component, we need to add the support object called REST Template to the flow:
31
32 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-certificates-when-calling-a-rest-webservice--rest-template-search.png]]
33
34 After adding the support object to the canvas and giving it a name, you can open it by double-clicking on the component. eMagiz will show you the following pop-up:
35
36 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-certificates-when-calling-a-rest-webservice--rest-template-empty.png]]
37
38 As you can see here, you can select various authentication schemes. Those are discussed in other microlearnings. Today the focus will be on the Advanced tab on this screen.
39
40 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-certificates-when-calling-a-rest-webservice--rest-template-advanced-empty.png]]
41
42 In this case, we first have to select the type of request factory (ApacheHttpComponents). This will allow us to define the correct configuration. After we have chosen this option, you will notice that the options on the page change.
43
44 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-certificates-when-calling-a-rest-webservice--rest-template-advanced-selected-apache-http-components.png]]
45
46 As you can see, most of the configuration is set to default values. These default values are correct in most cases. Only deviate from them with a good reason—the only thing left for us to define the proper truststore and Keystore, including password. As a best practice, we want to enter those values with the help of properties to alter them per environment.
47
48 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-certificates-when-calling-a-rest-webservice--rest-template-advanced-filled-in.png]]
49
50 Once you are satisfied, you can press Save.
51
52 === 3.2 Link REST Template to HTTP Outbound Component ===
53
54 Now that we have successfully configured the REST Template, the last thing we need to do is link the REST Template to the HTTP Outbound component in your flow. To do so, open the HTTP Outbound component by double-clicking on the component. After you have opened the component, you need to navigate to the advanced tab. On this tab, you can select a REST Template. Select the one we have just configured from the drop-down menu and press Save.
55
56 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-certificates-when-calling-a-rest-webservice--link-rest-template-to-http-outbound-component.png]]
57
58 Now you have successfully linked the REST Template to the HTTP Outbound Gateway. If you ever want to validate whether a support object is linked to your component, click on it once. That way, eMagiz will show the selected element and all other parts that are linked to it.
59
60 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-certificates-when-calling-a-rest-webservice--link-rest-template-to-http-outbound-component-visual.png]]
61
62 == 4. Key takeaways ==
63
64 * eMagiz pushes data to or retrieves data from the external party
65 * eMagiz offers two HTTP Outbound components to call a REST Webservice. Choose based on whether you want a response or not
66 * To do so, eMagiz needs to be authorized to read and write data
67 * You could use certificates for the authorization and verification.
68 * Don't forget to link the support object to the HTTP Outbound component
69
70 == 5. Suggested Additional Readings ==
71
72 If you are interested in this topic and want more information, please read the help text provided by eMagiz.
73
74 )))((({{toc/}}))){{/container}}{{/container}}