MidPoint Developer Zone

Last modified 26 Feb 2024 22:34 +01:00

The Developer’s Guide section of wiki provides information for midPoint developers and contributors. The pages provide guidelines for code structure, programming practices, code organization, etc.

The content is not formally organized now. It is (more or less) just a set of useful pages. We will try to create some kind of structure as the volume of information grows.

<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2010-2017 Evolveum
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->


<resource 	oid="ef2bc95b-76e0-48e2-86d6-3d4f02d3fafe"
		xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
		xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
		xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
       	xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">

	<name>HR</name>
    <description>Source resource</description>

	<connectorRef type="ConnectorType">
		<filter>
            <q:text>c:connectorType = 'com.evolveum.polygon.connector.csv.CsvConnector'</q:text>
        </filter>
	</connectorRef>

	<connectorConfiguration xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector">
		<icfc:configurationProperties>
				<icfi:filePath>pathToCsvFile/accounts.csv</icfi:filePath>
				<icfi:encoding>utf-8</icfi:encoding>
				<icfi:quote>"</icfi:quote>
				<icfi:quoteMode>ALL</icfi:quoteMode>
				<icfi:fieldDelimiter>,</icfi:fieldDelimiter>
				<icfi:multivalueDelimiter>;</icfi:multivalueDelimiter>
				<icfi:uniqueAttribute>login</icfi:uniqueAttribute>
				<icfi:passwordAttribute>password</icfi:passwordAttribute>
			</icfc:configurationProperties>

			<!-- Generic ICF configuration -->

	</connectorConfiguration>

        <!-- Resource Schema Handling definition.
             This part defines how the schema defined above will be used by
             midPoint. It defines expressions and limitations for individual
             schema attributes.

             The expressions that describe both inbound and outbound flow of
             the attributes are defined in this section.

             This is the part where most of the customization takes place.
        -->
		<schemaHandling>

            <!-- Definition of default account type.
                 This is now the only account type that midPoint can work with. -->
			<objectType>
                <!-- Readable name for the account type -->
				<displayName>Default Account</displayName>
				<default>true</default>
                <!-- Reference to the Resource Schema (see above) specifying
                     object class for this account type -->
				<objectClass>ri:AccountObjectClass</objectClass>
				<attribute>
					<ref>ri:login</ref>

					<displayName>Login</displayName>

					<limitations>
						<minOccurs>0</minOccurs>
					</limitations>
					<inbound>
						<target>
							<path>name</path>
						</target>
					</inbound>
				</attribute>

				<attribute>
					<ref>ri:firstname</ref>
					<displayName>First name</displayName>
					<description>Definition of Firstname attribute handling.</description>
					<inbound>
						<target>
							<path>givenName</path>
						</target>
					</inbound>
				</attribute>
				<attribute>
					<ref>ri:lastname</ref>
					<displayName>Last name</displayName>
					<description>Definition of Lastname attribute handling.</description>
					<inbound>
						<target>
							<path>$user/familyName</path>
						</target>
					</inbound>
				</attribute>
				<attribute>
					<ref>ri:memberOf</ref>
					<displayName>Member of specified organization unit/project</displayName>
					<!-- CSV connector does not know about multivalue, so pretend this attribute is multivalue. -->
					<limitations>
						<minOccurs>0</minOccurs>
						<maxOccurs>-1</maxOccurs>
					</limitations>
                    <inbound>
                        <expression>
                            <assignmentTargetSearch>
                                <targetType>c:ArchetypeType</targetType>
			            	    <filter>
                                    <q:text>name = ```
                                                    if (input.contains("Professors") || input.contains("Auxiliary")) {
                                                        return "Teacher";
                                                    }
                                                    if (input.contains("Gryffindor") || input.contains("Hufflepuff") || input.contains("Ravenclaw") || input.contains("Slytherin")) {
                                                        return "Student";
                                                    }
                                                    return null
                                                ```
                                    </q:text>
                                </filter>
                            </assignmentTargetSearch>
                        </expression>
                        <target>
                            <path>assignment</path>
                        </target>
                    </inbound>
					<inbound>
						<expression>
							<assignmentTargetSearch>
			            	<targetType>c:OrgType</targetType>
			        		<filter>
                                <q:text>name =[polyStringNorm] ```
                                            parent = input.tokenize('/').reverse()[0]
                                            if (!parent) {
                                                return "hogwarts";
                                            } else {
                                                return parent;
                                            }
                                            return "TOP"
                                            ```
                                </q:text>
							</filter>
							<createOnDemand>true</createOnDemand>
							<populateObject>
								<populateItem>
									<expression>
										<script>
											<code>
												input.tokenize('/').reverse()[0]
											</code>
										</script>
									</expression>
									<target>
										<path>name</path>
									</target>
								</populateItem>
								<populateItem>
									<expression>
										<value>access</value>
									</expression>
									<target>
										<path>subtype</path>
									</target>
								</populateItem>
								<populateItem>
									<expression>
										<script>
											<code>
												input.tokenize('/').reverse()[1..-1].join('/').tokenize('/').reverse()[0..-1].join('/')
											</code>
										</script>
									</expression>
									<target>
										<path>identifier</path>
									</target>
								</populateItem>
							</populateObject>
			            </assignmentTargetSearch>
						</expression>
						<target>
							<path>assignment</path>
							<set>
					            <condition>
					                <script>
					                    <code>
					                         import com.evolveum.midpoint.schema.constants.*
					                         import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;

					                        if (assignment.targetRef != null &amp;&amp; assignment.targetRef.type.localPart == "OrgType") {
					                        	org = midpoint.getObject(OrgType.class, assignment.targetRef.oid)
					                        	inRange = org.subtype?.contains('access') || org.subtype?.contains('team')
					                        	return inRange
					                        }
					                    </code>
					                </script>
					            </condition>
					        </set>
						</target>
					</inbound>

				</attribute>

				<attribute>
					<ref>ri:managerOf</ref>
					<displayName>Manager of specified organization unit/project</displayName>
					<!-- CSV connector does not know about multivalue, so pretend this attribute is multivalue. -->
					<limitations>
						<minOccurs>0</minOccurs>
						<maxOccurs>-1</maxOccurs>
					</limitations>
					<inbound>
						<expression>
							<assignmentTargetSearch>
			            	<targetType>c:OrgType</targetType>
                                <assignmentProperties>
                                    <relation>manager</relation>
                                </assignmentProperties>

			        		<filter>
                                <q:text>name =[polyStringNorm] ```
                                    parent = input.tokenize('/').reverse()[0]
                                    if (!parent) {
                                        return "hogwarts";
                                    } else {
                                        return parent;
                                    }
                                    ```
                                </q:text>
							</filter>
							<createOnDemand>true</createOnDemand>
							<populateObject>
								<populateItem>
									<expression>
										<script>
											<code>
												input.tokenize('/').reverse()[0]
											</code>
										</script>
									</expression>
									<target>
										<path>name</path>
									</target>
								</populateItem>
								<populateItem>
									<expression>
										<value>access</value>
									</expression>
									<target>
										<path>subtype</path>
									</target>
								</populateItem>
								<populateItem>
									<expression>
										<script>
											<code>
												input.tokenize('/').reverse()[1..-1].join('/').tokenize('/').reverse()[0..-1].join('/')
											</code>
										</script>
									</expression>
									<target>
										<path>identifier</path>
									</target>
								</populateItem>
							</populateObject>
			            </assignmentTargetSearch>
						</expression>
						<target>
							<path>assignment</path>
							<set>
					            <condition>
					                <script>
					                    <code>
					                         import com.evolveum.midpoint.schema.constants.*
					                         import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;

					                        if (assignment.targetRef != null &amp;&amp; assignment.targetRef.type.localPart == "OrgType") {
					                        	role = midpoint.getObject(OrgType.class, assignment.targetRef.oid)
					                        	inRange = role.subtype?.contains('access') || role.subtype?.contains('team')
					                        	return inRange
					                        }
					                    </code>
					                </script>
					            </condition>
					        </set>
						</target>
					</inbound>
					<inbound>
						<expression>
							<assignmentTargetSearch>
			            	<targetType>c:RoleType</targetType>
			            	<oid>e2c88fea-db21-11e5-80ba-d7b2f1155264</oid>
			            </assignmentTargetSearch>
						</expression>
						<target>
							<path>assignment</path>
							<set>
					            <condition>
					                <script>
					                    <code>
					                         import com.evolveum.midpoint.schema.constants.*
					                         import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;

					                        if (assignment.targetRef != null &amp;&amp; assignment.targetRef.type.localPart == "OrgType") {
					                        	role = midpoint.getObject(OrgType.class, assignment.targetRef.oid)
					                        	inRange = role.subtype.contains('access')
					                        	return inRange
					                        }
					                    </code>
					                </script>
					            </condition>
					        </set>
						</target>
					</inbound>
				</attribute>

				<activation>
					<administrativeStatus>
						<inbound/>
					</administrativeStatus>
				</activation>

				<credentials>
					<password>
						<inbound>
							 <strength>weak</strength>
							 <expression>
							 	<asIs/>
							 </expression>
						</inbound>
						<outbound/>
					</password>
				</credentials>

			</objectType>
		</schemaHandling>

		<!-- Resource capabilities. It defines a simulated enableDisable capability. -->
		<capabilities xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">
			<configured>
				<cap:activation>
					<cap:status>
						<cap:attribute>ri:disabled</cap:attribute>
						<cap:enableValue>false</cap:enableValue>
						<cap:disableValue>true</cap:disableValue>
					</cap:status>
				</cap:activation>
				<cap:delete>
					<cap:enabled>false</cap:enabled>
				</cap:delete>
			</configured>
		</capabilities>
		<synchronization>
			<objectSynchronization>
				<!--
	                The synchronization for this resource is enabled.
	                It will be used to correctly run discovery when account already exists.
	                 -->
				<enabled>true</enabled>

				<correlation>
					<q:description>
	                    Correlation expression is a search query.
	                    Following search query will look for users that have "name"
	                    equal to the "login" attribute of the account. Simply speaking,
	                    it will look for match in usernames in the IDM and the resource.
	                    The correlation rule always looks for users, so it will not match
	                    any other object type.
					</q:description>
					<q:equal>
						<q:path>c:name</q:path>
						<expression>
							<path>$account/attributes/ri:login</path>
						</expression>
					</q:equal>
				</correlation>

				<!-- Confirmation rule may be here, but as the search above will
	                 always return at most one match, the confirmation rule is not needed. -->

				<!-- Following section describes reactions to a situations.
	                 The setting here assumes that this resource is authoritative,
	                 therefore all accounts created on the resource should be
	                 reflected as new users in IDM.
	                 See http://wiki.evolveum.com/display/midPoint/Synchronization+Situations
	             -->
				<reaction>
					<situation>linked</situation>
					<synchronize>true</synchronize>
				</reaction>
				<reaction>
					<situation>deleted</situation>
					<synchronize>true</synchronize>
					<action>
						<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlink</handlerUri>
					</action>
				</reaction>
				<reaction>
					<situation>unlinked</situation>
					<synchronize>true</synchronize>
					<action>
						<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#link</handlerUri>
					</action>
				</reaction>
				<reaction>
					<situation>unmatched</situation>
					<synchronize>true</synchronize>
					<action>
						<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addFocus</handlerUri>
					</action>
				</reaction>
			</objectSynchronization>
		</synchronization>
</resource>
login firstname lastname memberOf managerOf disabled password

h.potter

Harry

Potter

Hogwarts/Students/Gryffindor

quiddich-griffindor

false

asd123

h.granger

Hermione

Granger

Hogwarts/Students/Gryffindor

false

huGHa

r.weasley

Ron

Weasley

Hogwarts/Students/Gryffindor

false

asd123

f.weasley

Fred

Weasley

Hogwarts/Students/Gryffindor;quiddich-griffindor

false

sLh5D

ge.weasley

George

Weasley

Hogwarts/Students/Gryffindor;quiddich-griffindor

false

Hhktd

gi.weasley

Ginny

Weasley

Hogwarts/Students/Gryffindor

false

HidpQ

p.weasley

Percy

Weasley

Hogwarts/Students/Gryffindor

false

BVzp7

n.longbottom

Neville

Longbottom

Hogwarts/Students/Gryffindor

false

4j91q

s.finnigan

Seamus

Finnigan

Hogwarts/Students/Gryffindor

false

X3rVs

o.wood

Oliver

Wood

Hogwarts/Students/Gryffindor

quiddich-griffindor

false

He7jK

k.bell

Katie

Bell

Hogwarts/Students/Gryffindor;quiddich-griffindor

false

CStTz

l.brown

Lavender

Brown

Hogwarts/Students/Gryffindor

false

3PnNC

c.creevey

Colin

Creevey

Hogwarts/Students/Gryffindor

false

FxRQO

d.creevey

Dennis

Creevey

Hogwarts/Students/Gryffindor

false

O0Unq

a.johnson

Angelina

Johnson

Hogwarts/Students/Gryffindor;quiddich-griffindor

false

xwlPf

l.jordan

Lee

Jordan

Hogwarts/Students/Gryffindor

false

FeJKf

c.mcLaggen

Cormac

McLaggen

Hogwarts/Students/Gryffindor

false

WGV9Z

p.patil

Parvati

Patil

Hogwarts/Students/Gryffindor

false

L06xC

a.spinnet

Alicia

Spinnet

Hogwarts/Students/Gryffindor;quiddich-griffindor

false

3QyWK

d.thomas

Dean

Thomas

Hogwarts/Students/Gryffindor;quiddich-griffindor

false

7bUIs

s.bones

Susan

Bones

Hogwarts/Students/Hufflepuff

false

zzkzQ

c.diggory

Cedric

Diggory

Hogwarts/Students/Hufflepuff

quiddich-hufflepuff

false

dDtXQ

j.finchFletchley

Justin

Finch-Fletchley

Hogwarts/Students/Hufflepuff

false

4hicr

e.macmillan

Ernie

Macmillan

Hogwarts/Students/Hufflepuff

false

o1vdP

z.smith

Zacharias

Smith

Hogwarts/Students/Hufflepuff;quiddich-hufflepuff

false

wWytb

m.oflaherty

Maxine

O’Flaherty

Hogwarts/Students/Hufflepuff;quiddich-hufflepuff

false

8zSQC

a.rickett

Anthony

Rickett

Hogwarts/Students/Hufflepuff;quiddich-hufflepuff

false

aR5Qz

m.mcManus

Michael

McManus

Hogwarts/Students/Hufflepuff;quiddich-hufflepuff

false

68oPS

m.preece

Malcolm

Preece

Hogwarts/Students/Hufflepuff;quiddich-hufflepuff

false

SjkHQ

h.macavoy

Heidi

Macavoy

Hogwarts/Students/Hufflepuff;quiddich-hufflepuff

false

jkxdA

t.applebee

Tamsin

Applebee

Hogwarts/Students/Hufflepuff;quiddich-hufflepuff

false

b5eaL

l.lovegood

Luna

Lovegood

Hogwarts/Students/Ravenclaw

false

gVpvc

t.boot

Terry

Boot

Hogwarts/Students/Ravenclaw

false

jMeJC

ch.Chang

Cho

Chang

Hogwarts/Students/Ravenclaw;quiddich-ravenclaw

false

MyNFI

p.clearwater

Penelope

Clearwater

Hogwarts/Students/Ravenclaw

false

beT2o

m.corner

Michael

Corner

Hogwarts/Students/Ravenclaw

false

SzZjR

r.davies

Roger

Davies

Hogwarts/Students/Ravenclaw

quiddich-ravenclaw

false

1WPNp

m.edgecombe

Marietta

Edgecombe

Hogwarts/Students/Ravenclaw

false

9NXxc

a.goldstein

Anthony

Goldstein

Hogwarts/Students/Ravenclaw

false

QGLi0

pa.patil

Padma

Patil

Hogwarts/Students/Ravenclaw

false

L06xC

j.stretton

Jeremy

Stretton

Hogwarts/Students/Ravenclaw;quiddich-ravenclaw

false

Qo2kc

r.burrow

Randolph

Burrow

Hogwarts/Students/Ravenclaw;quiddich-ravenclaw

false

BtwrF

d.inglebee

Duncan

Inglebee

Hogwarts/Students/Ravenclaw;quiddich-ravenclaw

false

0hFEp

d.malfoy

Draco

Malfoy

Hogwarts/Students/Slytherin;quiddich-slytherin

false

lOBrZ

m.bulstrode

Millicent

Bulstrode

Hogwarts/Students/Slytherin

false

fzFmz

v.crabbe

Vincent

Crabbe

Hogwarts/Students/Slytherin;quiddich-slytherin

false

gFv53

m.flint

Marcus

Flint

Hogwarts/Students/Slytherin

quiddich-slytherin

false

Iy6lp

g.goyle

Gregory

Goyle

Hogwarts/Students/Slytherin;quiddich-slytherin

false

wboNH

g.montague

Graham

Montague

Hogwarts/Students/Slytherin;quiddich-slytherin

false

H08hH

t.nott

Theodore

Nott

Hogwarts/Students/Slytherin

false

sOc81

p.parkinson

Pansy

Parkinson

Hogwarts/Students/Slytherin

false

wd7TU

b.zabini

Blaise

Zabini

Hogwarts/Students/Slytherin

false

bwdzH

a.dumbledore

Albus

Dumbledore

Hogwarts/Staff/Professors

Hogwarts/Staff/Professors;Hogwarts/Staff/Auxiliary

false

asd123

l.voldemort

Lord

Voldemort

Hogwarts/Staff/Professors

false

w3Hn3

m.mcGonagall

Minerva

McGonagall

Hogwarts/Staff/Professors

Hogwarts/Students/Gryffindor

false

LnwYb

s.snape

Severus

Snape

Hogwarts/Staff/Professors

Hogwarts/Students/Slytherin

false

3p0AE

p.sprout

Pomona

Sprout

Hogwarts/Staff/Professors

Hogwarts/Students/Hufflepuff

false

TPL2T

f.flitwick

Filius

Flitwick

Hogwarts/Staff/Professors

Hogwarts/Students/Ravenclaw

false

3seVL

s.trelawney

Sybill

Trelawney

Hogwarts/Staff/Professors

false

irY4l

ch.burbage

Charity

Burbage

Hogwarts/Staff/Professors

false

JIZxz

r.hooch

Rolanda

Hooch

Hogwarts/Staff/Professors

false

VmbKi

s.kettleburn

Silvanus

Kettleburn

Hogwarts/Staff/Professors

false

tVxYS

g.lockhart

Gilderoy

Lockhart

Hogwarts/Staff/Professors

false

asd123

a.sinistra

Aurora

Sinistra

Hogwarts/Staff/Professors

false

top0f

s.vector

Septima

Vector

Hogwarts/Staff/Professors

false

NJFjE

a.filch

Argus

Filch

Hogwarts/Staff/Auxiliary

false

LUdDa

r.hagrid

Rubeus

Hagrid

Hogwarts/Staff/Auxiliary;Hogwarts/Staff/Professors

false

asd123

i.pince

Irma

Pince

Hogwarts/Staff/Auxiliary

false

ZnHa4

p.pomfrey

Poppy

Pomfrey

Hogwarts/Staff/Auxiliary

false

bvYIK

Was this page helpful?
YES NO
Thanks for your feedback