Changes for page Groovy Script
Last modified by Erik Bakker on 2024/09/05 13:53
From version 11.2
edited by Erik Bakker
on 2022/07/28 08:47
on 2022/07/28 08:47
Change comment:
Update document after refactoring.
To version 5.2
edited by Erik Bakker
on 2022/07/26 08:16
on 2022/07/26 08:16
Change comment:
Update document after refactoring.
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -expert- data-handling-groovy-script1 +expert-create-your-transformations-xpath-expert - Default language
-
... ... @@ -1,1 +1,0 @@ 1 -en - Content
-
... ... @@ -1,59 +1,93 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 - In the crash courseon theAPI Gatewaywediscussed thevarious optionsavailableto[[secure>>doc:Main.eMagizAcademy.Microlearnings.CrashCourse.CrashCourseAPIGateway.crashcourse-api-gateway-security.WebHome||target="blank"]] yourAPI Gateway properly. In thismicrolearning, wewillexpandourknowledgeonthat topicby lookingata specialcasef securing yourAPI Gateway. Thatcaseis specialasyouuse anexternalidentityprovider(IDP)togovern therolesandusersthathaverightson yourAPI Gateway.2 +Within the crash course, we already explained XPath conceptually. In that same microlearning, we also looked at some more uncomplicated cases of using XPath within your transformation. If you need to brush up on that knowledge, please check out this [microlearning](crashcourse-platform-create-transformation-xpath-basic.md). In the intermediate microlearning on this subject, we built upon that knowledge. Please check out this [microlearning](intermediate-create-your-transformations-xpath-intermediate.md) if you need a refresher on that. In this microlearning, we will build upon that knowledge and look at some concrete, practical examples that could be useful in your project. 3 3 4 4 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 5 5 6 +* Last update: October 25th, 2021 7 +* Required reading time: 6 minutes 8 + 6 6 == 1. Prerequisites == 7 7 8 -* Expert knowledge of the eMagiz platform 11 +* Advanced knowledge of the eMagiz platform 12 +* [[XPath Basic>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic.WebHome||target="blank"]] 13 +* [[XPath Intermediate>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate.WebHome||target="blank"]] 9 9 15 + 10 10 == 2. Key concepts == 11 11 12 -This microlearning focuses on using an external IDP tovalidate whethera useris authorized to executea certain action on your API Gateway and whatconfigurationisneeded in eMagiz to make this work.18 +This microlearning focuses on more complex XPath operations. 13 13 14 -* The Token and Issuer URL of the external IDP need to be known 15 -* Users and Roles under User Management need to be manually configured and maintained to keep them in sync with the external IDP 20 +With XPath Advanced, we mean learning that XPath options are complex but could benefit you in your daily work. 16 16 17 - ==3.ExternalIDP==22 +Some of the more complex XPath options are: 18 18 19 -In the crash course on the API Gateway we discussed the various options available to [[secure>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course API Gateway.crashcourse-api-gateway-security.WebHome||target="blank"]] your API Gateway properly. In this microlearning, we will expand our knowledge on that topic by looking at a special case of securing your API Gateway. That case is special as you use an external identity provider (IDP) to govern the roles and users that have rights on your API Gateway. 24 +* dateTime calculation 25 +* Filter list 26 +* XPath on JSON 27 +* SpEL notation for XPath 20 20 21 -When selecting the option OAuth2.0 (or OpenID Connect) you have the option to use the IDP provided by eMagiz which makes the configuration easy or you could use an external IDP which you have control over and want to use for this purposes. 22 22 23 -In this microlearning we will highlight what you need to configure in Design and Deploy to make this work within the tooling of eMagiz. 24 24 25 -== =3.1Design ===31 +== 3. XPath Advanced == 26 26 27 - On the security level oftheAPIGatewayinDesign you need to select the desiredption,for exampleOAuth2.0. Insteadofnotfillingin the token andissuerURL,indicating that youwantetheMagizIDP,you needtofill thesein toreferencetheIDPofyourchoice. Below yousee anexampleof howthiscould beconfigured.33 +Within the crash course, we already explained XPath conceptually. In that same microlearning, we also looked at some more uncomplicated cases of using XPath within your transformation. If you need to brush up on that knowledge, please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic.WebHome||target="blank"]]. In the intermediate microlearning on this subject, we built upon that knowledge. Please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate.WebHome||target="blank"]] if you need a refresher on that. In this microlearning, we will build upon that knowledge and look at some concrete, practical examples that could be useful in your project. 28 28 29 - [[image:Main.Images.Microlearning.WebHome@expert-securing-data-traffic-api-gw-security-external-idp-security-config-design.png]]35 +Some of the more complex XPath options are: 30 30 31 -Note that the environmentID in this example should be replaced with an actual environmentID that references your environment. 37 +* dateTime calculation 38 +* Filter list 39 +* XPath on JSON 40 +* SpEL notation for XPath 32 32 33 -=== 3. 2Deploy===42 +=== 3.1 dateTime calculation === 34 34 35 - Normally,eMagizwillautomaticallyupdatethe UserManagementinformationbasedonthe configurationinDesign. However,because theidentitycheck isnotonebyeMagizbut byan externalpartyyou need tomanuallyenterthe rolesandusers andconfigure thescopecorrectlyonrolelevel.44 +Sometimes we see that a dateTime calculation is needed within a transformation to determine a specific action. As these calculations are not natively supported within the eMagiz platform, you need to use XPath's functionality to calculate the new valid date (or dateTime). 36 36 37 -T odo sonavigate toUserManagementDeployand addtheusersyouwantmanuallyby pressingtheNew buttonandproviding themwithaname. Do subsequently thesamefor theroles.Onroleveldo not forget tocorrectlyenterthe scopeto makethecallwork. Note that the help textonthescopelevelgently remindsyouwhatyou needto do to make thiswork.46 +The XPath standard offers several functions to calculate with dateTime values. The two most used options are dayTimeDuration and yearMonthDuration. With the help of the dayTimeDuration, you can add, subtract, multiple, or divide seconds, minutes, hours, and days regarding the original value. The yearMonthDuration works similarly but then for months and years. An example of such an XPath is: <xsl:value-of xmlns:xs="http://www.w3.org/2001/XMLSchema" select="CDM:StartDate + xs:dayTimeDuration('P1D') * xs:yearMonthDuration('P1M')"/>. In this example, XPath adds one day and subtracts one month from the input date. Note that making this work requires the additional namespace to be defined. Therefore you need a custom snippet within your transformation or a custom transformation to make this work. Furthermore, note that the P1D and P1M could also be filled with the help of parameters to make them dynamic in nature. 38 38 39 - [[image:Main.Images.Microlearning.WebHome@expert-securing-data-traffic-api-gw-security-external-idp-scope-configuration.png]]48 +Some examples that we saw during the years: 40 40 41 -{{warning}}When implementing this you would be the first to do so with this setup. This means there might be some unexpected behavior when configuring this.{{/warning}} 50 +* https://my.emagiz.com/p/question/172825635700358186 51 +* https://my.emagiz.com/p/question/172825635700352588 42 42 53 +=== 3.2 Filter list === 54 + 55 +Sometimes you have a large message which contains a certain list within it. However, logic dictates that you can only send the message if at least one entry in the list for which attribute A is filled and attribute B equals type C. To make that happen in XPath, we first need to navigate to the list within the message. As we previously learned, there are two options to do so. One is to use // to navigate to the entity somewhere in the tree directly. The other is to start at the root and walk the tree from there. In this example, we use the latter. That results in the following XPath example: /root/list[attributeB = 'type C']/attributeA !=''. With this XPath, you filter the list on the specified check and subsequently check whether one of those entries that remains has an attributeA which is filled in. 56 + 57 +=== 3.3 XPath on JSON === 58 + 59 +With the release of build number .50, we expanded our offering on JSON messages to resemble much of the functionality we previously offered for XML messages. As a result, you can use XPath expressions on JSON messages within the following components (related to XPath): 60 + 61 +* XPath header enricher 62 +* XPath transformer 63 +* XPath router 64 + 65 +To activate the functionality, simply link the JSON source factory support object to one of these components to achieve the desired result. For more information, check out: https://emagiz.github.io/docs/release-notes/build50. 66 + 67 +=== 3.4 SpEL notation for XPath === 68 + 69 +Sometimes you want to perform an XPath operation but store the header via a standard message header enricher component. As a result, you need a valid SpEL expression to help you in this cause. To do so, you need to know the correct notation for an XPath expression when using the SpEL language. An example of the correct notation is: #xpath(payload,'/root/entity/attribute') 70 + 43 43 == 4. Assignment == 44 44 45 -No assignment 73 +Check out which of the XPaths we have discussed today can be found within your project. 74 +This assignment can be completed within the (Academy) project you created/used in the previous assignment. 46 46 47 47 == 5. Key takeaways == 48 48 49 -* The Token and Issuer URL of the external IDP need to be known 50 -* Users and Roles under User Management need to be manually configured and maintained to keep them in sync with the external IDP 51 -* When implementing this you would be the first to do so with this setup. 78 +Some of the more complex XPath options are: 52 52 80 +* dateTime calculation 81 +* Filter list 82 +* XPath on JSON 83 +* SpEL notation for XPath 84 + 53 53 == 6. Suggested Additional Readings == 54 54 55 -If you are interested in this topic and want more information, please read the help text provided by eMagiz .87 +If you are interested in this topic and want more information on it, please read the help text provided by eMagiz and read more information on the following link: 56 56 89 +* https://www.w3schools.com/xml/xpath_intro.asp 90 + 57 57 == 7. Silent demonstration video == 58 58 59 59 As this is more of theoretical microlearning, there is no video accompanying the microlearning.)))((({{toc/}}))){{/container}}{{/container}}