Example of calling GroupWise REST API from Identity Manager policy - Part 2
This article is an extension of Part 1 (Part 1) where the gwutils java class has been added with more generic Http methods. In the previous example very specific use case requirements were targeted. The focus still has been with the GroupWise requirements as explained in the previous part and hence testing has been done only with the GroupWise REST apis via Identity manager. In no way this article is to be used as a substitute to the GWREST Identity manager connector offered out of the box . It is to be used as an extension to the existing Groupwise REST connector in situations where there is a need to make GroupWise REST calls to solve use cases for which there is no functionality(yet) in the existing out of the box driver or where the requirement is very specific for a certain Groupwise REST call to be available in your implementation.
(Note: Please refer to Part 1 for the needed setup to get the java class working in the Identity Manager policies.
The "GW14 Rest Operations" policy and its rules are placed in the output transformations just for demo purposes. Hence these policies can be moved to any policy set as required and the trigger conditions modified to satisfy a real world use case. That said from where ever these rules are being called , ensure that the gwutils namespace is added as explained in the part 1.)
Essentially 4 new methods have been added to support the 4 types of REST methods. They are GET, PUT, POST and DELETE.
Executing HttpGet
Method Name: exeGet
Method Parameter: Takes the complete GroupWise REST URI as the string input.
Method Output: GroupWise response as XML output
Policy example of fetching groupmemberships of a user:
Example of executing HttpGet
Trace:
Executing HttpPut
Method Name: exePut
Method Parameter 1: Takes the complete GroupWise REST URI as the string input.
Method Parameter 2: XML string representing the data to be updated.
Method Output: GroupWise response as XML output
Policy example of changing the participation of a user in a group (changing primary to carbon copy) :
Example of executing HttpPut
Trace :
(Note: Only xml type input is accepted at this time when updating GroupWise)
Executing HttpPost
Method Name: exePost
Method Parameter 1: Takes the complete GroupWise REST URI as the string input.
Method Parameter 2: XML string representing the data to be updated.
Method Output: GroupWise response as XML output
Policy example of adding a user to a group:
Example of executing HttpPost
(Note: Only xml type input is accepted at this time when updating GroupWise)
Executing HttpDelete
Method Name: exeDelete
Method Parameter: Takes the complete GroupWise REST URI as the string input of the object to be deleted.
Method Output: GroupWise response as XML output
Policy example deleting a user:
Example of executing HttpDelete
Trace:
Hope this is helpful and please leave any comment below if this can be improved in anyway.
Download GWRestUtils2.0
Download gwrestutils_3.0 (This version has been compiled for java 1.8 and should work against GW 2018)
(Note: Please refer to Part 1 for the needed setup to get the java class working in the Identity Manager policies.
The "GW14 Rest Operations" policy and its rules are placed in the output transformations just for demo purposes. Hence these policies can be moved to any policy set as required and the trigger conditions modified to satisfy a real world use case. That said from where ever these rules are being called , ensure that the gwutils namespace is added as explained in the part 1.)
Essentially 4 new methods have been added to support the 4 types of REST methods. They are GET, PUT, POST and DELETE.
Executing HttpGet
Method Name: exeGet
Method Parameter: Takes the complete GroupWise REST URI as the string input.
Method Output: GroupWise response as XML output
Policy example of fetching groupmemberships of a user:

Trace:
[02/21/16 09:54:32.270]:GroupWise 2014 REST ST: Action: do-set-local-variable("varURI",scope="policy","https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2/groupmemberships").
[02/21/16 09:54:32.270]:GroupWise 2014 REST ST: arg-string("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2/groupmemberships")
[02/21/16 09:54:32.270]:GroupWise 2014 REST ST: token-text("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2/groupmemberships")
[02/21/16 09:54:32.270]:GroupWise 2014 REST ST: Arg Value: "https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2/groupmemberships".
[02/21/16 09:54:32.271]:GroupWise 2014 REST ST: Action: do-set-local-variable("varGWMemNS",scope="policy",token-xpath("gwutils:exeGet($varURI)")).
[02/21/16 09:54:32.271]:GroupWise 2014 REST ST: arg-string(token-xpath("gwutils:exeGet($varURI)"))
[02/21/16 09:54:32.271]:GroupWise 2014 REST ST: token-xpath("gwutils:exeGet($varURI)")
[02/21/16 09:54:32.271]:GroupWise 2014 REST ST: == GWRestUtils ==> : GroupWise URI (exeGet) : https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2/groupmemberships
[02/21/16 09:54:32.297]:GroupWise 2014 REST ST: == GWRestUtils ==> :
<?xml version="1.0" encoding="UTF-8"?><list xmlns:ns2="http://www.w3.org/2005/Atom">
<object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="membership">
<domainName>GW14LAB</domainName>
<id>GROUP.GW14LAB.gw14PO.GWGrp5</id>
<name>GWGrp5</name>
<postOfficeName>gw14PO</postOfficeName>
<participation>CARBON_COPY</participation>
</object>
<resultInfo>
<outOf>1</outOf>
</resultInfo>
</list>
[02/21/16 09:54:32.308]:GroupWise 2014 REST ST: == GWRestUtils ==> : Successfully executed HttpGet
Executing HttpPut
Method Name: exePut
Method Parameter 1: Takes the complete GroupWise REST URI as the string input.
Method Parameter 2: XML string representing the data to be updated.
Method Output: GroupWise response as XML output
Policy example of changing the participation of a user in a group (changing primary to carbon copy) :

Trace :
[02/21/16 09:54:32.308]:GroupWise 2014 REST ST: Action: do-set-local-variable("varURI",scope="policy","https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members/USER.GW14LAB.GW14PO.Dom9U3").
[02/21/16 09:54:32.309]:GroupWise 2014 REST ST: arg-string("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members/USER.GW14LAB.GW14PO.Dom9U3")
[02/21/16 09:54:32.309]:GroupWise 2014 REST ST: token-text("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members/USER.GW14LAB.GW14PO.Dom9U3")
[02/21/16 09:54:32.309]:GroupWise 2014 REST ST: Arg Value: "https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members/USER.GW14LAB.GW14PO.Dom9U3".
[02/21/16 09:54:32.309]:GroupWise 2014 REST ST: Action: do-set-local-variable("varURIInputXML",scope="policy","<member><forceNullOnAttrs/> <participation>CARBON_COPY</participation></member>").
[02/21/16 09:54:32.309]:GroupWise 2014 REST ST: arg-string("<member><forceNullOnAttrs/> <participation>CARBON_COPY</participation></member>")
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: token-text("<member><forceNullOnAttrs/> <participation>CARBON_COPY</participation></member>")
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: Arg Value: "<member><forceNullOnAttrs/> <participation>CARBON_COPY</participation></member>".
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: Action: do-set-local-variable("varGWMemNS",scope="policy",token-xpath("gwutils:exePut($varURI,$varURIInputXML)")).
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: arg-string(token-xpath("gwutils:exePut($varURI,$varURIInputXML)"))
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: token-xpath("gwutils:exePut($varURI,$varURIInputXML)")
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: == GWRestUtils ==> : GroupWise URI (exePut) : https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members/USER.GW14LAB.GW14PO.Dom9U3
[02/21/16 09:54:32.311]:GroupWise 2014 REST ST: == GWRestUtils ==> : GroupWise Input (exePut) : <member><forceNullOnAttrs/> <participation>CARBON_COPY</participation></member>
[02/21/16 09:54:32.322]:GroupWise 2014 REST ST: == GWRestUtils ==> : Sucessfully executed HttpPut
[02/21/16 09:54:32.329]:GroupWise 2014 REST ST: Token Value: "200".
[02/21/16 09:54:32.330]:GroupWise 2014 REST ST: Arg Value: "200".
(Note: Only xml type input is accepted at this time when updating GroupWise)
Executing HttpPost
Method Name: exePost
Method Parameter 1: Takes the complete GroupWise REST URI as the string input.
Method Parameter 2: XML string representing the data to be updated.
Method Output: GroupWise response as XML output
Policy example of adding a user to a group:

[02/19/16 07:33:22.708]:GroupWise 2014 REST ST: Action: do-set-local-variable("varURI",scope="policy","https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members").
[02/19/16 07:33:22.709]:GroupWise 2014 REST ST: arg-string("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members")
[02/19/16 07:33:22.709]:GroupWise 2014 REST ST: token-text("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members")
[02/19/16 07:33:22.709]:GroupWise 2014 REST ST: Arg Value: "https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members".
[02/19/16 07:33:22.709]:GroupWise 2014 REST ST: Action: do-set-local-variable("varURIInputXML",scope="policy","<member><id>USER.GW14LAB.GW14PO.Dom9U2</id><forceNullOnAttrs/><participation>PRIMARY</participation></member>").
[02/19/16 07:33:22.709]:GroupWise 2014 REST ST: arg-string("<member><id>USER.GW14LAB.GW14PO.Dom9U2</id><forceNullOnAttrs/><participation>PRIMARY</participation></member>")
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: token-text("<member><id>USER.GW14LAB.GW14PO.Dom9U2</id><forceNullOnAttrs/><participation>PRIMARY</participation></member>")
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: Arg Value: "<member><id>USER.GW14LAB.GW14PO.Dom9U2</id><forceNullOnAttrs/><participation>PRIMARY</participation></member></member>".
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: Action: do-set-local-variable("varGWReturnCode",scope="policy",token-xpath("gwutils:exePost($varURI,$varURIInputXML)")).
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: arg-string(token-xpath("gwutils:exePut($varURI,$varURIInputXML)"))
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: token-xpath("gwutils:exePut($varURI,$varURIInputXML)")
[02/21/16 09:54:32.310]:GroupWise 2014 REST ST: == GWRestUtils ==> : GroupWise URI (exePut) : https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/groups/GWGrp5/members
[02/21/16 09:54:32.311]:GroupWise 2014 REST ST: == GWRestUtils ==> : GroupWise Input (exePut) : <member><id>USER.GW14LAB.GW14PO.Dom9U2</id><forceNullOnAttrs/><participation>PRIMARY</participation></member>
[02/21/16 09:54:32.322]:GroupWise 2014 REST ST: == GWRestUtils ==> : Sucessfully executed HttpPost
[02/21/16 09:54:32.329]:GroupWise 2014 REST ST: Token Value: "200".
[02/21/16 09:54:32.330]:GroupWise 2014 REST ST: Arg Value: "200".
(Note: Only xml type input is accepted at this time when updating GroupWise)
Executing HttpDelete
Method Name: exeDelete
Method Parameter: Takes the complete GroupWise REST URI as the string input of the object to be deleted.
Method Output: GroupWise response as XML output
Policy example deleting a user:

Trace:
[02/21/16 11:34:36.308]:GroupWise 2014 REST ST: Action: do-set-local-variable("varURI",scope="policy","https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2").
[02/21/16 11:34:36.309]:GroupWise 2014 REST ST: arg-string("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2")
[02/21/16 11:34:36.309]:GroupWise 2014 REST ST: token-text("https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2")
[02/21/16 11:34:36.309]:GroupWise 2014 REST ST: Arg Value: "https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2".
[02/21/16 11:34:36.310]:GroupWise 2014 REST ST: Action: do-set-local-variable("varGWReturnCode",scope="policy",token-xpath("gwutils:exeDelete($varURI)")).
[02/21/16 11:34:36.310]:GroupWise 2014 REST ST: arg-string(token-xpath("gwutils:exeDelete($varURI)"))
[02/21/16 11:34:36.310]:GroupWise 2014 REST ST: token-xpath("gwutils:exeDelete($varURI)")
[02/21/16 11:34:36.310]:GroupWise 2014 REST ST: == GWRestUtils ==> : GroupWise URI (exeDelete) : https://192.168.1.165:9710/gwadmin-service/domains/GW14LAB/postoffices/GW14PO/users/Dom9U2
[02/21/16 11:34:36.322]:GroupWise 2014 REST ST: == GWRestUtils ==> : Sucessfully executed HttpDelete
[02/21/16 11:34:36.329]:GroupWise 2014 REST ST: Token Value: "200".
[02/21/16 11:34:36.330]:GroupWise 2014 REST ST: Arg Value: "200".
Hope this is helpful and please leave any comment below if this can be improved in anyway.
Download GWRestUtils2.0
Download gwrestutils_3.0 (This version has been compiled for java 1.8 and should work against GW 2018)