midpoint源码阅读九(使用示例:多租户用户管理五——示例配置文件分析)

本文主要是介绍midpoint源码阅读九(使用示例:多租户用户管理五——示例配置文件分析),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

上篇 midpoint源码阅读八(使用示例:多租户用户管理四——示例操作步骤) 介绍了如何使用该示例的配置文件将环境搭建好,本篇将通过分析其配置文件,说明系统中的组织、用户是如何关联创建的。

1、组织结构

官网对组织结构(Organizational Structure)的介绍地址:https://wiki.evolveum.com/display/midPoint/Organizational+Structure

<objects xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
<org xmlns="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:t="http://prism.evolveum.com/xml/ns/public/types-3"xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"oid="0271f2da-f77b-4a27-9a80-832f7f2f99e4"version="0"><!--midpoint中唯一标识(组织名称)--><name>CUSTOMERS</name><activation><effectiveStatus>enabled</effectiveStatus><enableTimestamp>2016-02-05T10:22:40.341+01:00</enableTimestamp></activation><!--用户看的组织名称--><displayName>Customers</displayName><!--数据源中的组织唯一标识,用于同步--><identifier>0001</identifier><!--用于标识组织的用途(该字段值根据自己的业务自定义--><orgType>functional</orgType>
</org>
</objects>

2、数据字典

定义了员工类型

<lookupTable oid="5783c174-d141-11e4-bb29-001e8c717e5b"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"xmlns:piracy='http://midpoint.evolveum.com/xml/ns/samples/piracy'><name>Employee Type</name><row><!--键--><key>customer-admin</key><!--值--><label>customer-admin</label></row><row><key>customer-user</key><label>customer-user</label></row>
</lookupTable>

3、资源配置文件

连接器的配置可以参看官网手册:https://wiki.evolveum.com/display/midPoint/Resource+Configuration

①入站映射(inbound)(同步数据到midpoint)

我们来看看crm-simulation-sync.xml文件,学习midpoint中资源的配置
该文件说明了如何将源中数据同步到midpoint中。

<c:resource oid="b2911718-cbe3-11e5-b1ea-3c970e44b9e2"><!-- 资源名称 --><c:name>CRM Simulation</c:name><!-- CSV文件连接器定义 --><connectorRef type="ConnectorType"><filter><q:equal><q:path>c:connectorType</q:path><q:value>com.evolveum.polygon.csvfile.CSVFileConnector</q:value></q:equal></filter></connectorRef><!-- 连接器的配置 --><c:connectorConfiguration><icfc:configurationProperties
                xmlns:icfccsvfile="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csvfile/com.evolveum.polygon.csvfile.CSVFileConnector"><icfccsvfile:filePath>C://ProjectIntelljIdea//midpoint//samples//stories//multitenant-idm-saas//misc//midpoint-crm-flatfile.csv</icfccsvfile:filePath><icfccsvfile:encoding>utf-8</icfccsvfile:encoding><icfccsvfile:valueQualifier>"</icfccsvfile:valueQualifier><icfccsvfile:fieldDelimiter>,</icfccsvfile:fieldDelimiter><icfccsvfile:multivalueDelimiter>;</icfccsvfile:multivalueDelimiter><icfccsvfile:usingMultivalue>false</icfccsvfile:usingMultivalue><icfccsvfile:uniqueAttribute>name</icfccsvfile:uniqueAttribute></icfc:configurationProperties></c:connectorConfiguration><!-- Resource Schema Handling definition.官网文档为:https://wiki.evolveum.com/display/midPoint/Resource+Schema+Handling该部分定义了该资源在midpoint中如何被使用,以及该资源中可读的条目的自定义属性,该属性用于inbound(数据源中的数据如何存入到midpoint中)、outbound(midpoint中的数据如何同步到数据源中)--><schemaHandling><!-- 数据源中的数据定义,其告诉midpoint如何同步数据源的数据--><objectType><displayName>Default Account</displayName><default>true</default><!-- 对象类型,它是数据源中存在的数据类型(一般midpoint中无该类型定义),用于outbound时,数据源知道如何处理数据 --><objectClass>ri:AccountObjectClass</objectClass><attribute><ref>icfs:uid</ref><displayName>Entry UUID</displayName><!-- 该属性的访问控制 --><limitations><access><read>true</read></access></limitations></attribute><attribute><ref>icfs:name</ref><displayName>Name</displayName><limitations><minOccurs>0</minOccurs><access><read>true</read><add>false</add><modify>false</modify></access></limitations><!--数据同步到midpoint时,数据源中该条记录的 name属性 同步到 UserType的name属性中--><inbound><target><path>$user/name</path></target></inbound><!--数据同步到midpoint时,同时将UserType的employeeType属性设置为customer-admin--><inbound><expression><value>customer-admin</value></expression><target><path>$user/employeeType</path></target></inbound></attribute>........<attribute><ref>ri:customerName</ref><displayName>Customer Name (Organization)</displayName><description>Definition of customerName attribute handling.</description><limitations><access><read>true</read><add>false</add><modify>false</modify></access></limitations><inbound><target><path>$user/organizationalUnit</path></target></inbound></attribute><attribute><ref>ri:customerDisplayName</ref><displayName>Customer Display Name (Organization)</displayName><description>Definition of customerDisplayName attribute handling.</description><limitations><access><read>true</read><add>false</add><modify>false</modify></access></limitations><inbound><target><path>$user/organization</path></target></inbound></attribute><attribute><ref>ri:customerContact</ref><displayName>Customer Contact (Email)</displayName><description>Definition of customerContact attribute handling.</description><limitations><access><read>true</read><add>false</add><modify>false</modify></access></limitations><inbound><target><path>$user/emailAddress</path></target></inbound></attribute><activation><administrativeStatus><inbound/></administrativeStatus></activation><!--密码--><credentials><password><inbound><strength>weak</strength><expression><generate/></expression></inbound></password></credentials></objectType></schemaHandling><!--定义了该资源 midpoint能进行什么样的操作--><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><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 "name" 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 matchany other object type.</q:description><q:equal><q:path>c:name</q:path><expression><path>declare namespace icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3";$account/attributes/icfs:name</path></expression></q:equal></correlation><reaction><situation>linked</situation><action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#modifyUser</handlerUri></action></reaction><reaction><situation>deleted</situation><action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlinkAccount</handlerUri></action></reaction><reaction><situation>unlinked</situation><action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#linkAccount</handlerUri></action></reaction><reaction><situation>unmatched</situation><action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser</handlerUri></action></reaction></objectSynchronization></synchronization>
</c:resource>

该资源定义,官网给出的整体图如下:
整体

②出站映射(outbound)(从midpoint同步数据到数据源)

下面来看看openldap-customers.xml文件,该文件说明的是 如何把midpoint中的数据创建到openldap中

<resource oid="40be7fa0-cbec-11e5-926a-3c970e44b9e2"><!-- Resource name. It will be displayed in GUI.  --><name>OpenLDAP for Customers</name><description>LDAP resource using a ConnId LDAP connector. It contains configurationfor use with OpenLDAP servers.</description><connectorRef type="ConnectorType"><description>Reference to the OpenICF LDAP connector. This is dynamic reference, it will be translated toOID during import.</description><filter><q:equal><q:path>c:connectorType</q:path><q:value>com.evolveum.polygon.connector.ldap.LdapConnector</q:value></q:equal></filter></connectorRef><connectorConfiguration xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3"xmlns:icfcldap="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector"><icfc:configurationProperties><icfcldap:port>389</icfcldap:port><icfcldap:host>xap.com</icfcldap:host><icfcldap:baseContext>ou=customers,dc=example,dc=com</icfcldap:baseContext><icfcldap:bindDn>cn=admin,dc=example,dc=com</icfcldap:bindDn><icfcldap:bindPassword><t:clearValue>zhl</t:clearValue></icfcldap:bindPassword><icfcldap:pagingStrategy>auto</icfcldap:pagingStrategy><icfcldap:passwordHashAlgorithm>SSHA</icfcldap:passwordHashAlgorithm><icfcldap:vlvSortAttribute>uid</icfcldap:vlvSortAttribute><icfcldap:vlvSortOrderingRule>2.5.13.3</icfcldap:vlvSortOrderingRule><icfcldap:operationalAttributes>memberOf</icfcldap:operationalAttributes><icfcldap:operationalAttributes>createTimestamp</icfcldap:operationalAttributes></icfc:configurationProperties><icfc:resultsHandlerConfiguration><icfc:enableNormalizingResultsHandler>false</icfc:enableNormalizingResultsHandler><icfc:enableFilteredResultsHandler>false</icfc:enableFilteredResultsHandler><icfc:enableAttributesToGetSearchResultsHandler>false</icfc:enableAttributesToGetSearchResultsHandler></icfc:resultsHandlerConfiguration></connectorConfiguration><schema><!--openldap中的类型 --><generationConstraints><generateObjectClass>ri:inetOrgPerson</generateObjectClass><generateObjectClass>ri:groupOfUniqueNames</generateObjectClass><generateObjectClass>ri:groupOfNames</generateObjectClass><generateObjectClass>ri:organizationalUnit</generateObjectClass></generationConstraints></schema><schemaHandling><!--用于将midpoint中的用户信息 创建成openldap中的账号 --><objectType><kind>account</kind><displayName>Normal Account</displayName><default>true</default><!--openldap中的类型 --><objectClass>ri:inetOrgPerson</objectClass><attribute><ref>ri:dn</ref><displayName>Distinguished Name</displayName><limitations><minOccurs>0</minOccurs><access><read>true</read><add>true</add><modify>true</modify></access></limitations><matchingRule>mr:stringIgnoreCase</matchingRule><!--midpoint中的信息同步到openldap中,outbound 说明了 openldap中的 dn为 'uid=' + name + ',ou=' + organizationalUnit + ',ou=customers,dc=example,dc=com'--><outbound><source><path>$user/name</path></source><source><path>$user/organizationalUnit</path></source><expression><script><code>'uid=' + name + ',ou=' + organizationalUnit + ',ou=customers,dc=example,dc=com'</code></script></expression></outbound></attribute><attribute><ref>ri:entryUUID</ref><displayName>Entry UUID</displayName><limitations><access><read>true</read><add>false</add><modify>true</modify></access></limitations><matchingRule>mr:stringIgnoreCase</matchingRule></attribute><attribute><ref>ri:cn</ref><displayName>Common Name</displayName><limitations><minOccurs>0</minOccurs><access><read>true</read><add>true</add><modify>true</modify></access></limitations><outbound><source><path>$user/fullName</path></source></outbound></attribute><attribute><ref>ri:sn</ref><displayName>Surname</displayName><limitations><minOccurs>0</minOccurs></limitations><outbound><source><!-- The path can be shorteden like this. $user is a default source "context" in outbound --><path>familyName</path></source></outbound></attribute><attribute><ref>ri:givenName</ref><displayName>Given Name</displayName><outbound><source><!-- Full namespace prefixes can be used in the path --><path>$c:user/c:givenName</path></source></outbound></attribute><attribute><ref>ri:uid</ref><displayName>Login Name</displayName><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><strength>weak</strength><source><description>Source may have description</description><path>$user/name</path></source><expression><script><code>name</code></script></expression></outbound></attribute><attribute><ref>ri:description</ref><outbound><source><path>$user/description</path></source></outbound></attribute><attribute><ref>ri:l</ref><displayName>Location</displayName><outbound><source><path>$user/locality</path></source></outbound></attribute><attribute><ref>ri:employeeType</ref><displayName>Employee Type</displayName><tolerant>false</tolerant><outbound><source><path>$user/employeeType</path></source></outbound></attribute><association><ref>ri:group</ref><displayName>LDAP Group Membership</displayName><kind>entitlement</kind><intent>ldapGroup</intent><intent>group-org-admin</intent><intent>group-org-user</intent><intent>group-org-poweruser</intent><intent>group-custom</intent><direction>objectToSubject</direction><associationAttribute>ri:member</associationAttribute><valueAttribute>ri:dn</valueAttribute><explicitReferentialIntegrity>true</explicitReferentialIntegrity></association><iteration><maxIterations>5</maxIterations></iteration><protected><filter><q:equal><q:matching>http://prism.evolveum.com/xml/ns/public/matching-rule-3#stringIgnoreCase</q:matching><q:path>attributes/ri:dn</q:path><q:value>cn=idm,ou=Administrators,dc=example,dc=com</q:value></q:equal></filter></protected><activation><administrativeStatus><outbound/></administrativeStatus></activation><credentials><password><outbound><expression><asIs/></expression></outbound></password></credentials></objectType><!--用于将midpoint中的组织信息 创建成openldap中的组织 --><objectType><kind>generic</kind><intent>ou-customer</intent><displayName>Customer Organizational Unit</displayName><default>true</default><!--openldap中的类型 --><objectClass>ri:organizationalUnit</objectClass><attribute><ref>ri:dn</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><!-- Name cannot be weak. Changes in name trigger object rename. --><source><path>$focus/name</path></source><expression><script><code>return 'ou=' + name + ',ou=customers,dc=example,dc=com'</code></script></expression></outbound></attribute><attribute><ref>ri:ou</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><strength>weak</strength><source><path>$focus/name</path></source></outbound></attribute><attribute><ref>ri:description</ref><outbound><source><path>description</path></source></outbound></attribute></objectType><!--用于创建openldap中的权限组中的成员 --><objectType><kind>entitlement</kind><intent>ldapGroup</intent><displayName>LDAP Group</displayName>   <default>true</default><!--openldap中的类型 --><objectClass>ri:groupOfNames</objectClass><attribute><ref>ri:member</ref><matchingRule>mr:distinguishedName</matchingRule><fetchStrategy>minimal</fetchStrategy></attribute>            <configuredCapabilities><cap:pagedSearch><cap:defaultSortField>ri:uid</cap:defaultSortField></cap:pagedSearch></configuredCapabilities></objectType><!--用于创建openldap中的权限组  xxx-powerusers --><objectType><kind>entitlement</kind><intent>group-org-poweruser</intent><displayName>LDAP Group - Power Users</displayName><objectClass>ri:groupOfNames</objectClass><attribute><ref>ri:dn</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><!-- Name cannot be weak. Changes in name trigger object rename. --><source><path>$focus/name</path></source><expression><script><code>return 'cn=' + name + '-powerusers,ou=' + name + ',ou=customers,dc=example,dc=com'</code></script></expression></outbound></attribute><attribute><ref>ri:member</ref><matchingRule>mr:distinguishedName</matchingRule><fetchStrategy>minimal</fetchStrategy><outbound><strength>strong</strength><!-- Workaround - groupOfNames MUST have at least one member. Even non-existent DN. --><expression><value>cn=dummy,o=whatever</value></expression></outbound></attribute>            <attribute><ref>ri:cn</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><strength>weak</strength><source><path>$focus/name</path></source><expression><script><code>return name + '-powerusers'</code></script></expression></outbound></attribute><attribute><ref>ri:description</ref><outbound><source><path>description</path></source></outbound></attribute><dependency><kind>generic</kind><intent>ou-customer</intent><strictness>relaxed</strictness></dependency><configuredCapabilities><cap:pagedSearch><cap:defaultSortField>ri:uid</cap:defaultSortField></cap:pagedSearch></configuredCapabilities></objectType><!--用于创建openldap中的权限组  xxx-users --><objectType><kind>entitlement</kind><intent>group-org-user</intent><displayName>LDAP Group - Users</displayName><objectClass>ri:groupOfNames</objectClass><attribute><ref>ri:dn</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><!-- Name cannot be weak. Changes in name trigger object rename. --><source><path>$focus/name</path></source><expression><script><code>return 'cn=' + name + '-users,ou=' + name + ',ou=customers,dc=example,dc=com'</code></script></expression></outbound></attribute><attribute><ref>ri:member</ref><matchingRule>mr:distinguishedName</matchingRule><fetchStrategy>minimal</fetchStrategy><outbound><strength>strong</strength><!-- Workaround - groupOfNames MUST have at least one member. Even non-existent DN. --><expression><value>cn=dummy,o=whatever</value></expression></outbound></attribute>            <attribute><ref>ri:cn</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><strength>weak</strength><source><path>$focus/name</path></source><expression><script><code>return name + '-users'</code></script></expression></outbound></attribute><attribute><ref>ri:description</ref><outbound><source><path>description</path></source></outbound></attribute><dependency><kind>generic</kind><intent>ou-customer</intent><strictness>relaxed</strictness></dependency><configuredCapabilities><cap:pagedSearch><cap:defaultSortField>ri:uid</cap:defaultSortField></cap:pagedSearch></configuredCapabilities></objectType><!--用于创建openldap中的权限组  xxx-admins --><objectType><kind>entitlement</kind><intent>group-org-admin</intent><displayName>LDAP Group - Admin</displayName><objectClass>ri:groupOfNames</objectClass><attribute><ref>ri:dn</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><!-- Name cannot be weak. Changes in name trigger object rename. --><source><path>$focus/name</path></source><expression><script><code>return 'cn=' + name + '-admins,ou=' + name + ',ou=customers,dc=example,dc=com'</code></script></expression></outbound></attribute><attribute><ref>ri:member</ref><matchingRule>mr:distinguishedName</matchingRule><fetchStrategy>minimal</fetchStrategy><outbound><strength>strong</strength><!-- Workaround - groupOfNames MUST have at least one member. Even non-existent DN. --><expression><value>cn=dummy,o=whatever</value></expression></outbound></attribute>            <attribute><ref>ri:cn</ref><matchingRule>mr:stringIgnoreCase</matchingRule><outbound><strength>weak</strength><source><path>$focus/name</path></source><expression><script><code>return name + '-admins'</code></script></expression></outbound></attribute><attribute><ref>ri:description</ref><outbound><source><path>description</path></source></outbound></attribute><dependency><kind>generic</kind><intent>ou-customer</intent><strictness>relaxed</strictness></dependency><configuredCapabilities><cap:pagedSearch><cap:defaultSortField>ri:uid</cap:defaultSortField></cap:pagedSearch></configuredCapabilities></objectType></schemaHandling><consistency><avoidDuplicateValues>true</avoidDuplicateValues></consistency><!-- 同步部分 说的是 同步策略、时间、行为及设置 --><synchronization><objectSynchronization><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 "uid" 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 matchany other object type.</q:description><q:equal><q:path>name</q:path><expression><path>declare namespace ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3";$account/attributes/ri:uid</path></expression></q:equal></correlation><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></reaction></objectSynchronization><objectSynchronization><objectClass>ri:organizationalUnit</objectClass><kind>generic</kind><intent>ou-customer</intent><focusType>c:OrgType</focusType><enabled>true</enabled><condition><script><code>import static com.evolveum.midpoint.schema.constants.SchemaConstants.*tmpSuffix = '(?i)^ou=.*,ou=customers,dc=example,dc=com$'re = ~tmpSuffixbasic.getAttributeValue(shadow, 'http://midpoint.evolveum.com/xml/ns/public/resource/instance-3', 'dn') ==~ re</code></script></condition><correlation><q:equal><q:matching>polyStringNorm</q:matching><q:path>c:name</q:path><expression><path>declare namespace ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3";$shadow/attributes/ri:ou</path></expression></q:equal></correlation><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></reaction></objectSynchronization>.......<objectSynchronization><objectClass>ri:groupOfNames</objectClass><kind>entitlement</kind><intent>group-org-admin</intent><focusType>c:OrgType</focusType><enabled>true</enabled><condition><script><code>import static com.evolveum.midpoint.schema.constants.SchemaConstants.*tmpSuffix = '(?i)^cn=.*-admins,ou=.*,ou=customers,dc=example,dc=com$'re = ~tmpSuffixbasic.getAttributeValue(shadow, 'http://midpoint.evolveum.com/xml/ns/public/resource/instance-3', 'dn') ==~ re</code></script></condition><correlation><q:equal><q:matching>polyStringNorm</q:matching><q:path>c:name</q:path><expression><script><code>tmpCn = basic.getAttributeValue(shadow, 'http://midpoint.evolveum.com/xml/ns/public/resource/instance-3', 'cn')re = /(?i)^(.*)-admins$/matcher = (tmpCn =~ re)if (matcher.matches()) return matcher[0][1]</code></script></expression></q:equal></correlation><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></reaction></objectSynchronization></synchronization>
</resource>

4、对象模板

对象模板在midpoint用于 创建该模板的对象时,自动处理好该对象的附加属性

① 用户对象模板

下面是用户对象模板object-user-template.xml配置文件的解读,该示例代码在创建用户的时候,会根据该模板将用户的fullName补齐、(若该用户组织还未创建,则创建该组织)、同时根据employType的属性给该用户赋予对应的角色。

<objectTemplate oid="e63e1118-cbe5-11e5-b08e-3c970e44b9e2"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"><name>User Template</name><item><ref>employeeType</ref><valueEnumerationRef oid="5783c174-d141-11e4-bb29-001e8c717e5b"/></item><!--在crm-simulation-sync.xml中定义了orgaization的数据源对应项为ri:customerDisplayName--><item><ref>organization</ref></item><!--在crm-simulation-sync.xml中定义了organizationalUnit的数据源对应项为ri:customerName--><item><ref>organizationalUnit</ref></item><!--说明了fullname字段如何填充--><mapping><name>Fullname</name><authoritative>true</authoritative><strength>strong</strength><source><path>givenName</path></source><source><path>familyName</path></source><expression><script><code>basic.concatName(givenName, familyName)</code></script></expression><target><path>fullName</path></target></mapping><!--根据用户的organization、organizationUnit值,给该用户赋予组织,若找不到该组织则创建该组织.通过csv导入用户时,组织都未创建,则该段代码创建的组织结构如下:用户信息:name,           givenName,  familyName,     customerName,       customerDisplayName,        customerContact,                disabled"ultraone-admin","Perry",   "Houser",       "ultra1",           "Ultra One Cloud Inc.",     "ultraone-admin@example.com",   "false" <org><name>organizationalUnit——> ultra1</name><displayName>organizationa——> Ultra One Cloud Inc.</displayName><orgType>customer</orgType></org>--><mapping><name>Org mapping - organization member</name><description>Look for appropriate Org objects by using the user's organizationalUnit propertyas the name of the org object. When no such object is found we want to create it ondemand. We want to populate new Org object with a name and displayName derived fromthe user.</description><authoritative>true</authoritative><strength>strong</strength><source><path>organization</path></source><source><path>organizationalUnit</path></source><expression><!--如果orgType项中的name属性没有organizationalUnit值的话,则创建该组织(Organizational Structure),使Organizational Structure中的 name=organizationalUnit='ultra1',displayName=organization='Ultra One Cloud Inc.',orgType='customer'--><assignmentTargetSearch><!-- c:orgType 指 Organizational Structure --><targetType>c:OrgType</targetType><filter><q:equal><q:path>c:name</q:path><expression><script><code>log.info("XXXXXX USER TEMPLATE assignmentTargetSearch, organizationalUnit {}", organizationalUnit);return organizationalUnit</code></script></expression></q:equal></filter><createOnDemand>true</createOnDemand><populateObject><populateItem><expression><script><code>log.info("XXXXXX USER TEMPLATE populate item organizationalUnit {}", organizationalUnit);return organizationalUnit</code></script></expression><target><path>name</path></target></populateItem><populateItem><expression><script><code>log.info("XXXXXX USER TEMPLATE populate item organization {}", organization);return organization</code></script></expression><target><path>displayName</path></target></populateItem><populateItem><expression><value>customer</value></expression><!-- orgType 指 Organizational Structure中的属性orgType --><target><path>orgType</path></target></populateItem></populateObject></assignmentTargetSearch>       </expression><target><path>assignment</path></target></mapping><mapping><name>Org mapping - organization manager</name><description>Look for appropriate Org objects by using the user's organizationalUnit propertyas the name of the org object. When no such object is found we want to create it ondemand. We want to populate new Org object with a name and displayName derived fromthe user.</description><authoritative>true</authoritative><strength>strong</strength><source><path>organization</path></source><source><path>organizationalUnit</path></source><source><path>employeeType</path></source><expression><assignmentTargetSearch><targetType>c:OrgType</targetType><filter><q:equal><q:path>c:name</q:path><expression><script><code>log.info("XXXXXX USER TEMPLATE assignmentTargetSearch, organizationalUnit {}", organizationalUnit);return organizationalUnit</code></script></expression></q:equal></filter><relation>org:manager</relation></assignmentTargetSearch>       </expression><target><path>assignment</path></target><condition><script><code>employeeType == 'customer-admin'</code></script></condition></mapping><!--给用户赋予角色--><mapping><name>Basic Customer Admin role assignment</name><strength>strong</strength><source><path>$user/employeeType</path></source><expression><assignmentTargetSearch><targetType>c:RoleType</targetType><oid>3410a44a-cc00-11e5-bc03-3c970e44b9e2</oid></assignmentTargetSearch>       </expression><target><path>assignment</path></target><condition><script><code>employeeType == 'customer-admin'</code></script></condition></mapping>..........
</objectTemplate>

②组织对象模板

组织对象模板object-template-org.xml相对来说比较简单,仅仅用于创建组织的时候给该组织赋予相应的角色,在此就不展示了。

5、组织——数据源角色

在metarole-org.xml中通过间接分配,给组织分配了 在数据源中 对应的角色

<role oid="bb1adfda-cbee-11e5-a445-3c970e44b9e2"xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"><name>Functional Orgstruct Metarole</name><inducement><construction><!-- OpenLDAP --><resourceRef oid="40be7fa0-cbec-11e5-926a-3c970e44b9e2" type="c:ResourceType"/><!--kind和intent的组合,我们可以在openldap-customers.xml中找到对应的objectClass如kind=generic、intent=ou-customer 其对应的objectClass = organizationalUnit--><kind>generic</kind><intent>ou-customer</intent></construction><condition><source><path>$immediateRole/orgType</path></source><expression><script><code>orgType == 'customer'</code></script></expression></condition></inducement><inducement><construction><!-- OpenLDAP --><resourceRef oid="40be7fa0-cbec-11e5-926a-3c970e44b9e2" type="c:ResourceType"/><!--kind和intent的组合,我们可以在openldap-customers.xml中找到对应的objectClass如kind=generic、intent=ou-customer 其对应的objectClass =groupOfNames--><kind>entitlement</kind><intent>group-org-admin</intent></construction><condition><source><path>$immediateRole/orgType</path></source><expression><script><code>orgType == 'customer'</code></script></expression></condition></inducement>..........<inducement><focusMappings><mapping><name>Set organizationalUnit from organization name</name><strength>weak</strength><!-- XXX --><source><path>$immediateRole/name</path></source><target><path>$user/organizationalUnit</path></target></mapping></focusMappings><order>2</order><focusType>c:UserType</focusType></inducement>
</role>

6、角色权限配置

该类配置文件就不详细介绍了,直接参看示例配置就行。

<role oid="c546fe38-def1-11e5-85bb-3c970e44b9e2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-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:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"><name>Delegated Administration Role</name><description>Role to delegate administration to customer admins.</description><!-- ***** GUI ***** --><authorization><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-ui-3#users</action> <action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-ui-3#user</action> <action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-ui-3#userDetails</action><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-ui-3#findUsers</action><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-ui-3#orgStruct</action><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-ui-3#orgTree</action><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-ui-3#orgUnit</action></authorization><authorization><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action><object><special>self</special></object></authorization><authorization><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action><object><type>ShadowType</type><owner><special>self</special></owner></object></authorization><authorization><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#changeCredentials</action><phase>request</phase><object><special>self</special></object><item>credentials</item></authorization><authorization><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#modify</action><phase>execution</phase><object><special>self</special></object><item>credentials</item></authorization><authorization><name>Read for all password policies, all resources and roles of roleType=customer and End User</name><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action><object><type>ValuePolicyType</type></object><object><type>ResourceType</type></object><object><type>RoleType</type><filter><q:or><q:equal><q:path>roleType</q:path><q:value>customer</q:value></q:equal><q:equal><q:path>name</q:path><q:value>End user</q:value></q:equal><q:equal><q:path>name</q:path><q:value>Delegated Administration Role</q:value><!-- To see also this role --></q:equal></q:or></filter></object></authorization><!-- ***** Model ***** --<!-- Authorization to see lookupTables --><authorization><name>Read for lookuptable</name><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action><object><type>LookupTableType</type></object></authorization><!-- Authorization to read own organization and its content including the path from root - if assigned as manager --><authorization><name>Magic read/modify</name><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#modify</action><object><orgRelation><subjectRelation>org:manager</subjectRelation><scope>allDescendants</scope><includeReferenceOrg>true</includeReferenceOrg></orgRelation></object></authorization><!-- Authorization to modify some attributes IN their own organizations - if assigned as manager --><authorization><name>Modify some user attributes</name><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#modify</action><object><type>UserType</type><orgRelation><subjectRelation>org:manager</subjectRelation></orgRelation></object><item>name</item><item>description</item><item>givenName</item><item>familyName</item><item>employeeType</item><item>emailAddress</item><item>activation</item><item>credentials</item></authorization><!-- Authorization to CRD IN their own organizations - if assigned as manager --><authorization><name>Authz: CRD UserType</name><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#add</action>
<!--        <action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#modify</action>--><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#delete</action><object><type>UserType</type><orgRelation><subjectRelation>org:manager</subjectRelation></orgRelation></object></authorization><!-- Authorization to assign/unassign IN their own organization - roles of roleType=customer or End user --><authorization><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#assign</action><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#unassign</action><object><type>UserType</type><orgRelation><subjectRelation>org:manager</subjectRelation></orgRelation></object><target><type>RoleType</type><filter><q:or><q:equal><q:path>roleType</q:path><q:value>customer</q:value></q:equal><q:equal><q:path>name</q:path><q:value>End user</q:value></q:equal></q:or></filter></target><!-- Authorization to read entitlements and generic --><authorization><name>Read all entitlements and generic shadows</name><action>http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#read</action><object><type>ShadowType</type><filter><q:or><q:equal><q:path>kind</q:path><q:value>entitlement</q:value></q:equal><q:equal><q:path>kind</q:path><q:value>generic</q:value></q:equal></q:or></filter></object></authorization><requestable>false</requestable>
</role>

7、示例代码后台数据创建过程

1)导入租户管理员csv文件(midpoint-crm-flatfile.csv)
2)根据该文件的用户记录,填充好fullName (object-template-user.xml)
3)根据该文件的用户记录,查询用户所属的组织是否存在,不存在的话,根据“Org mapping - organization membe” mapping里的描述创建该组织(object-template-user.xml)
4)创建组织时参照 组织模板文件 (object-template-org.xml)给创建的组织赋予父节点,根据metarole-org.xml文件 参照inducement段中的描述创建 projection
5)根据metarole-org.xml)中的inducement同时参照openldap-customers.xml的outbound描述在openldap中创建该组织及该组织下的角色组(groupOfNames)和用户(inetOrgPerson)
6)组织创建好后,在该用户的assignment中加入该组织
7)根据用户的employType给用户赋予midpoint中的角色,该角色事先通过角色权限文件(role-customer-authz-admin.xml等)导入到系统中。
8)至此用户创建完毕

这篇关于midpoint源码阅读九(使用示例:多租户用户管理五——示例配置文件分析)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/521378

相关文章

Python使用PIL库将PNG图片转换为ICO图标的示例代码

《Python使用PIL库将PNG图片转换为ICO图标的示例代码》在软件开发和网站设计中,ICO图标是一种常用的图像格式,特别适用于应用程序图标、网页收藏夹图标等场景,本文将介绍如何使用Python的... 目录引言准备工作代码解析实践操作结果展示结语引言在软件开发和网站设计中,ICO图标是一种常用的图像

C++ Primer 标准库vector示例详解

《C++Primer标准库vector示例详解》该文章主要介绍了C++标准库中的vector类型,包括其定义、初始化、成员函数以及常见操作,文章详细解释了如何使用vector来存储和操作对象集合,... 目录3.3标准库Vector定义和初始化vector对象通列表初始化vector对象创建指定数量的元素值

使用Java发送邮件到QQ邮箱的完整指南

《使用Java发送邮件到QQ邮箱的完整指南》在现代软件开发中,邮件发送功能是一个常见的需求,无论是用户注册验证、密码重置,还是系统通知,邮件都是一种重要的通信方式,本文将详细介绍如何使用Java编写程... 目录引言1. 准备工作1.1 获取QQ邮箱的SMTP授权码1.2 添加JavaMail依赖2. 实现

MyBatis与其使用方法示例详解

《MyBatis与其使用方法示例详解》MyBatis是一个支持自定义SQL的持久层框架,通过XML文件实现SQL配置和数据映射,简化了JDBC代码的编写,本文给大家介绍MyBatis与其使用方法讲解,... 目录ORM缺优分析MyBATisMyBatis的工作流程MyBatis的基本使用环境准备MyBati

使用Python开发一个图像标注与OCR识别工具

《使用Python开发一个图像标注与OCR识别工具》:本文主要介绍一个使用Python开发的工具,允许用户在图像上进行矩形标注,使用OCR对标注区域进行文本识别,并将结果保存为Excel文件,感兴... 目录项目简介1. 图像加载与显示2. 矩形标注3. OCR识别4. 标注的保存与加载5. 裁剪与重置图像

使用Python实现表格字段智能去重

《使用Python实现表格字段智能去重》在数据分析和处理过程中,数据清洗是一个至关重要的步骤,其中字段去重是一个常见且关键的任务,下面我们看看如何使用Python进行表格字段智能去重吧... 目录一、引言二、数据重复问题的常见场景与影响三、python在数据清洗中的优势四、基于Python的表格字段智能去重

使用Apache POI在Java中实现Excel单元格的合并

《使用ApachePOI在Java中实现Excel单元格的合并》在日常工作中,Excel是一个不可或缺的工具,尤其是在处理大量数据时,本文将介绍如何使用ApachePOI库在Java中实现Excel... 目录工具类介绍工具类代码调用示例依赖配置总结在日常工作中,Excel 是一个不可或缺的工http://

spring @EventListener 事件与监听的示例详解

《spring@EventListener事件与监听的示例详解》本文介绍了自定义Spring事件和监听器的方法,包括如何发布事件、监听事件以及如何处理异步事件,通过示例代码和日志,展示了事件的顺序... 目录1、自定义Application Event2、自定义监听3、测试4、源代码5、其他5.1 顺序执行

Java之并行流(Parallel Stream)使用详解

《Java之并行流(ParallelStream)使用详解》Java并行流(ParallelStream)通过多线程并行处理集合数据,利用Fork/Join框架加速计算,适用于大规模数据集和计算密集... 目录Java并行流(Parallel Stream)1. 核心概念与原理2. 创建并行流的方式3. 适

如何使用Docker部署FTP和Nginx并通过HTTP访问FTP里的文件

《如何使用Docker部署FTP和Nginx并通过HTTP访问FTP里的文件》本文介绍了如何使用Docker部署FTP服务器和Nginx,并通过HTTP访问FTP中的文件,通过将FTP数据目录挂载到N... 目录docker部署FTP和Nginx并通过HTTP访问FTP里的文件1. 部署 FTP 服务器 (