Skip to content

Commit

Permalink
Implement option1 up to "back in midPoint" step
Browse files Browse the repository at this point in the history
What is still missing from option1 is "back in LDAP" and targets.
Plus minor improvements/fixes and tests.
  • Loading branch information
mederly committed Mar 29, 2019
1 parent e897461 commit e1c58f2
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 20 deletions.
17 changes: 10 additions & 7 deletions demo/complex/add-ref-groups.gsh
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@

def addGroups(gs,stem) {
def supergroup = GroupFinder.findByName(gs, "etc:midpointGroups", true)
def addGroups(gs,stem,owner,regexp) {
for (group in stem.childGroups) {
if (!group.name.endsWith('_includes') &&
!group.name.endsWith('_excludes') &&
!group.name.endsWith('_systemOfRecord') &&
!group.name.endsWith('_systemOfRecordAndIncludes')) {
!group.name.endsWith('_systemOfRecordAndIncludes') &&
(regexp == null || group.extension ==~ regexp)) {
println 'Adding: ' + group
def s = SubjectFinder.findById(group.getId(), 'group', 'g:gsa')
supergroup.addMember(s, false)
owner.addMember(s, false)
} else {
println 'Ignoring: ' + group
}
}
}

gs = GrouperSession.startRootSession()
def supergroup = GroupFinder.findByName(gs, "etc:midpointGroups", true)
def cs = GroupFinder.findByName(gs, "app:cs", true)

addGroups(gs, StemFinder.findByName(gs, 'ref:affiliation'))
addGroups(gs, StemFinder.findByName(gs, 'ref:dept'))
addGroups(gs, StemFinder.findByName(gs, 'ref:course'))
addGroups(gs, StemFinder.findByName(gs, 'ref:affiliation'), supergroup, null)
//addGroups(gs, StemFinder.findByName(gs, 'ref:dept'), null)
//addGroups(gs, StemFinder.findByName(gs, 'ref:course'), null)

addGroups(gs, StemFinder.findByName(gs, 'ref:course'), cs, /CS.*/)
13 changes: 11 additions & 2 deletions demo/complex/grouper_data/container_files/seed-data/demo.gsh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@ attributeAssign.getAttributeValueDelegate().assignValue(LoaderLdapUtils.grouperL
attributeAssign.getAttributeValueDelegate().assignValue(LoaderLdapUtils.grouperLoaderLdapSubjectIdTypeName(), "subjectId");

midpointGroupsGroup = new GroupSave(gs).assignName("etc:midpointGroups").assignCreateParentStemsIfNotExist(true).save();

testGroup = new GroupSave(gs).assignName("midpoint:test").assignCreateParentStemsIfNotExist(true).save();
chess = new GroupSave(gs).assignName("app:mailinglist:chess").assignCreateParentStemsIfNotExist(true).save()
idmfans = new GroupSave(gs).assignName("app:mailinglist:idm-fans").assignCreateParentStemsIfNotExist(true).save()
cs = new GroupSave(gs).assignName("app:cs").assignCreateParentStemsIfNotExist(true).save()
volunteers = new GroupSave(gs).assignName("test:volunteers").assignCreateParentStemsIfNotExist(true).save()

midpointGroupsGroup.addMember(SubjectFinder.findById(testGroup.getId(), 'group', 'g:gsa'), false)
midpointGroupsGroup.addMember(SubjectFinder.findById(chess.getId(), 'group', 'g:gsa'), false)
midpointGroupsGroup.addMember(SubjectFinder.findById(idmfans.getId(), 'group', 'g:gsa'), false)
midpointGroupsGroup.addMember(SubjectFinder.findById(cs.getId(), 'group', 'g:gsa'), false)
midpointGroupsGroup.addMember(SubjectFinder.findById(volunteers.getId(), 'group', 'g:gsa'), false)

s = SubjectFinder.findById(testGroup.getId(), 'group', 'g:gsa');
midpointGroupsGroup.addMember(s, false);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<objectTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
oid="be84a39a-c004-490b-9b78-a871b837f6df">
<name>template-org-mailing-list</name>
<mapping>
<strength>strong</strength>
<expression>
<assignmentTargetSearch>
<targetType>RoleType</targetType>
<oid>1c7beff4-cdf6-4e9f-b54c-79d0766f6fbe</oid> <!-- metarole-mailing-list -->
</assignmentTargetSearch>
</expression>
<target>
<path>assignment</path>
</target>
</mapping>

</objectTemplate>
153 changes: 151 additions & 2 deletions demo/complex/midpoint-objects/objectTemplates/template-user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<strength>strong</strength>
<source>
<path>extension/grouperGroup</path>
<set>
<condition>
<script>
<code>
!(grouperGroup ==~ /ref:affiliation:.*/) &amp;&amp; !(grouperGroup ==~ /app:mailinglist:.*/)
</code>
</script>
</condition>
</set>
</source>
<expression>
<assignmentTargetSearch>
Expand All @@ -15,7 +24,7 @@
<expression>
<script>
<code>
grouperGroup
'generic_' + grouperGroup
</code>
</script>
</expression>
Expand All @@ -33,7 +42,7 @@
<expression>
<script>
<code>
grouperGroup
'generic_' + grouperGroup
</code>
</script>
</expression>
Expand Down Expand Up @@ -62,4 +71,144 @@
</set>
</target>
</mapping>
<mapping>
<strength>strong</strength>
<source>
<path>extension/grouperGroup</path>
<set>
<condition>
<script>
<code>
grouperGroup ==~ /app:mailinglist:.*/
</code>
</script>
</condition>
</set>
</source>
<expression>
<assignmentTargetSearch>
<targetType>OrgType</targetType>
<filter>
<q:equal>
<q:path>name</q:path>
<expression>
<script>
<code>
'mailinglist_' + grouperGroup.substring(16)
</code>
</script>
</expression>
</q:equal>
</filter>
<assignmentProperties>
<subtype>mailing-list</subtype>
</assignmentProperties>
<createOnDemand>true</createOnDemand>
<populateObject>
<populateItem>
<target>
<path>name</path>
</target>
<expression>
<script>
<code>
'mailinglist_' + grouperGroup.substring(16)
</code>
</script>
</expression>
</populateItem>
<populateItem>
<target>
<path>subtype</path>
</target>
<expression>
<value>mailing-list</value>
</expression>
</populateItem>
</populateObject>
</assignmentTargetSearch>
</expression>
<target>
<path>assignment</path>
<set>
<condition>
<script>
<code>
assignment?.subtype.contains('mailing-list')
</code>
</script>
</condition>
</set>
</target>
</mapping>
<mapping>
<strength>strong</strength>
<source>
<path>extension/grouperGroup</path>
<set>
<condition>
<script>
<code>
grouperGroup ==~ /ref:affiliation:.*/
</code>
</script>
</condition>
</set>
</source>
<expression>
<assignmentTargetSearch>
<targetType>OrgType</targetType>
<filter>
<q:equal>
<q:path>name</q:path>
<expression>
<script>
<code>
'affiliation_' + grouperGroup.substring(16)
</code>
</script>
</expression>
</q:equal>
</filter>
<assignmentProperties>
<subtype>affiliation</subtype>
</assignmentProperties>
<createOnDemand>true</createOnDemand>
<populateObject>
<populateItem>
<target>
<path>name</path>
</target>
<expression>
<script>
<code>
'affiliation_' + grouperGroup.substring(16)
</code>
</script>
</expression>
</populateItem>
<populateItem>
<target>
<path>subtype</path>
</target>
<expression>
<value>affiliation</value>
</expression>
</populateItem>
</populateObject>
</assignmentTargetSearch>
</expression>
<target>
<path>assignment</path>
<set>
<condition>
<script>
<code>
assignment?.subtype.contains('affiliation')
</code>
</script>
</condition>
</set>
</target>
</mapping>
</objectTemplate>
44 changes: 36 additions & 8 deletions demo/complex/midpoint-objects/resources/resource-grouper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
<rest:password>password</rest:password>
<rest:superGroup>etc:midpointGroups</rest:superGroup>
<rest:groupIncludePattern>midpoint:.*</rest:groupIncludePattern>
<rest:groupIncludePattern>ref:.*</rest:groupIncludePattern>
<rest:groupExcludePattern>ref:.*_(includes|excludes|systemOfRecord|systemOfRecordAndIncludes)</rest:groupExcludePattern>
<rest:groupIncludePattern>app:.*</rest:groupIncludePattern>
<rest:groupIncludePattern>test:.*</rest:groupIncludePattern>
<rest:groupIncludePattern>ref:affiliation:.*</rest:groupIncludePattern>
<rest:groupExcludePattern>.*_(includes|excludes|systemOfRecord|systemOfRecordAndIncludes)</rest:groupExcludePattern>
<rest:subjectSource>ldap</rest:subjectSource>
<rest:groupSource>g:gsa</rest:groupSource>
<rest:ignoreSslValidation>true</rest:ignoreSslValidation>
Expand Down Expand Up @@ -76,8 +78,8 @@

parameters = [
superGroup: 'etc:midpointGroups',
groupIncludePattern: [ 'midpoint:.*', 'ref:.*' ],
groupExcludePattern: [ 'ref:.*_(includes|excludes|systemOfRecord|systemOfRecordAndIncludes)' ],
groupIncludePattern: [ 'midpoint:.*', 'app:.*', 'test:.*', 'ref:affiliation:.*' ],
groupExcludePattern: [ '.*_(includes|excludes|systemOfRecord|systemOfRecordAndIncludes)' ],
relevantSourceId: 'ldap'
]

Expand Down Expand Up @@ -124,14 +126,33 @@
<ref>icfs:name</ref>
<inbound>
<strength>strong</strength>
<expression>
<script>
<code>
switch (input) {
case ~/ref:affiliation:.*/: return 'affiliation_' + input.substring(16)
case ~/app:mailinglist:.*/: return 'mailinglist_' + input.substring(16)
default: return 'generic_' + input
}
</code>
</script>
</expression>
<target>
<path>name</path>
</target>
</inbound>
<inbound>
<strength>strong</strength>
<expression>
<value>generic-group</value>
<script>
<code>
switch (input) {
case ~/ref:affiliation:.*/: return 'affiliation'
case ~/app:mailinglist:.*/: return 'mailing-list'
default: return 'generic-group'
}
</code>
</script>
</expression>
<target>
<path>subtype</path>
Expand Down Expand Up @@ -190,9 +211,16 @@
<q:equal>
<q:path>name</q:path>
<expression>
<path>
$account/attributes/name
</path>
<script>
<code>
def name = basic.getAttributeValue(shadow, 'http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3', 'name')
switch (name) {
case ~/ref:affiliation:.*/: return 'affiliation_' + name.substring(16)
case ~/app:mailinglist:.*/: return 'mailinglist_' + name.substring(16)
default: return 'generic_' + name
}
</code>
</script>
</expression>
</q:equal>
</correlation>
Expand Down
4 changes: 3 additions & 1 deletion demo/complex/midpoint-objects/roles/metarole-affiliation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
oid="fecae27b-d1d3-40ae-95fa-8f7e44e2ee70">
<name>metarole-affiliation</name>
<!-- TODO -->
<inducement id="1">
<targetRef oid="1d7c0e3a-4456-409c-9f50-95407b2eb785" relation="org:default" type="c:OrgType" /> <!-- affiliations -->
</inducement>
</role>
16 changes: 16 additions & 0 deletions demo/complex/midpoint-objects/roles/metarole-mailing-list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:apti="http://midpoint.evolveum.com/xml/ns/public/common/api-types-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
oid="1c7beff4-cdf6-4e9f-b54c-79d0766f6fbe">
<name>metarole-mailing-list</name>
<inducement id="1">
<targetRef oid="d81fb46c-20c7-44d3-8402-fef404ea1264" relation="org:default" type="c:OrgType" /> <!-- mailing-lists -->
</inducement>

</role>
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
<subtype>course</subtype>
<objectTemplateRef xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" oid="d35bdec6-643b-41d8-ad5d-8eeb701169d1" relation="org:default" type="tns:ObjectTemplateType"/>
</defaultObjectPolicyConfiguration>
<defaultObjectPolicyConfiguration id="110">
<type>OrgType</type>
<subtype>mailing-list</subtype>
<objectTemplateRef xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" oid="be84a39a-c004-490b-9b78-a871b837f6df" relation="org:default" type="tns:ObjectTemplateType"/>
</defaultObjectPolicyConfiguration>
<defaultObjectPolicyConfiguration id="100">
<type>OrgType</type>
<subtype>generic-group</subtype>
Expand Down
17 changes: 17 additions & 0 deletions demo/complex/upload-async-update-task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

function upload () {
local filename=$1
local regex="midpoint-objects.*/(.*)/(.*)"
if [[ $filename =~ $regex ]]
then
type="${BASH_REMATCH[1]}"
oid=`cat $filename | sed -n 's:.*oid=\"\([A-Za-z0-9\-]*\)\".*:\1:p' | sed -n '1 p'`
echo "Uploading $filename ($type, $oid)"
curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X PUT "https://localhost:8443/midpoint/ws/rest/$type/$oid?options=overwrite" --data-binary @$filename
else
echo "Skipping $filename"
fi
}

upload midpoint-objects-manual/tasks/task-async-update-grouper.xml
Loading

0 comments on commit e1c58f2

Please sign in to comment.