<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2017-2023 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="04afeda6-394b-11e6-8cbe-abf7ff430056"
    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:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
    xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3"
    xmlns:my="http://myself.me/schemas/whatever">

    <name>CRM</name>
    <description>Customer Relationship Management</description>

    <connectorRef type="ConnectorType">
        <filter>
            <q:text>connectorType = "org.identityconnectors.databasetable.DatabaseTableConnector"</q:text>
        </filter>
    </connectorRef>

    <connectorConfiguration>

        <icfc:configurationProperties
        xmlns:icscdbtable="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-databasetable/org.identityconnectors.databasetable.DatabaseTableConnector">
            <icscdbtable:port>5432</icscdbtable:port>
            <icscdbtable:host>midpoint_data</icscdbtable:host>
            <icscdbtable:user>extradb</icscdbtable:user>
            <icscdbtable:password><clearValue>qwe123</clearValue></icscdbtable:password>
            <icscdbtable:database>extradb</icscdbtable:database>
            <icscdbtable:table>crmusers</icscdbtable:table>
            <icscdbtable:keyColumn>userId</icscdbtable:keyColumn>
            <icscdbtable:passwordColumn>password</icscdbtable:passwordColumn>
            <icscdbtable:jdbcDriver>org.postgresql.Driver</icscdbtable:jdbcDriver>
            <icscdbtable:jdbcUrlTemplate>jdbc:postgresql://%h:%p/%d</icscdbtable:jdbcUrlTemplate>
            <icscdbtable:enableEmptyString>false</icscdbtable:enableEmptyString>
            <icscdbtable:rethrowAllSQLExceptions>true</icscdbtable:rethrowAllSQLExceptions>
            <icscdbtable:nativeTimestamps>false</icscdbtable:nativeTimestamps>
            <icscdbtable:allNative>false</icscdbtable:allNative>
        </icfc:configurationProperties>

    </connectorConfiguration>

    <schemaHandling>

        <objectType>
            <displayName>User Account</displayName>
            <default>true</default>
            <delineation>
                <objectClass>AccountObjectClass</objectClass>
            </delineation>
            <attribute>
                <ref>icfs:uid</ref>
                <displayName>User ID</displayName>
            </attribute>
            <attribute>
                <ref>icfs:name</ref>
                <displayName>Name</displayName>
                <outbound>
                    <source>
                        <path>$focus/name</path>
                    </source>
                </outbound>
            </attribute>

            <attribute>
                <ref>firstname</ref>
                <displayName>First name</displayName>
                <outbound>
                    <source>
                        <path>$focus/givenName</path>
                    </source>
                </outbound>
            </attribute>
            <attribute>
                <ref>lastname</ref>
                <displayName>Last name</displayName>
                <outbound>
                    <source>
                        <path>$focus/familyName</path>
                    </source>
                </outbound>
            </attribute>
            <attribute>
                <ref>fullname</ref>
                <displayName>Full name</displayName>
                <outbound>
                    <source>
                        <path>$focus/fullName</path>
                    </source>
                </outbound>
            </attribute>
            <attribute>
                <ref>description</ref>
                <displayName>Description</displayName>
            </attribute>
            <attribute>
                <ref>empno</ref>
                <displayName>Employee number</displayName>
                <outbound>
                    <source>
                        <path>$focus/personalNumber</path>
                    </source>
                </outbound>
            </attribute>
            <attribute>
                <ref>accesslevel</ref>
                <displayName>Access level</displayName>
            </attribute>

            <activation>
                <administrativeStatus>
                    <outbound/>
                </administrativeStatus>
            </activation>

            <credentials>
                <password>
                    <outbound/>
                </password>
            </credentials>

        </objectType>
    </schemaHandling>

    <capabilities xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">
        <configured>
            <cap:activation>
                <cap:status>
                    <cap:attribute>disabled</cap:attribute>
                    <cap:enableValue></cap:enableValue>
                    <cap:enableValue>false</cap:enableValue>
                    <cap:disableValue>true</cap:disableValue>
                </cap:status>
            </cap:activation>
        </configured>
    </capabilities>

</resource>
