<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
  ~ 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.
  -->

<systemConfiguration oid="00000000-0000-0000-0000-000000000001" version="0"
    xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
    xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
    xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3">
    <name>SystemConfiguration</name>

    <!-- THIS IS NOT A COMPLETE EXAMPLE -->
    <!-- This is an object that has part that are supposed to be
         copied (added) into the default system configuration. -->

    <globalSecurityPolicyRef oid="b50aff7e-3784-11e6-b97e-0b955775c407"/>


    <notificationConfiguration>
        <handler>
            <passwordResetNotifier>
                <recipientExpression>
                    <script>
                        <code>return requestee.getEmailAddress()</code>
                    </script>
                </recipientExpression>
                <bodyExpression>
                    <script>
                        <code>
                            import com.evolveum.midpoint.notifications.api.events.ModelEvent
                            modelEvent = (ModelEvent) event
                            newUser = modelEvent.getFocusContext().getObjectNew();
                            userType = newUser.asObjectable();

                            link = midpoint.createPasswordResetLink(userType)
                            bodyMessage = "Did you request password reset? If yes, click on the link bellow \n" + link

                            return bodyMessage;
                        </code>
                    </script>
                </bodyExpression>
                <transport>mail</transport>
            </passwordResetNotifier>
        </handler>
        <mail>
            <redirectToFile>/var/opt/midpoint/mail.log</redirectToFile>
        </mail>
    </notificationConfiguration>


    <!-- Role lifecycle implementation -->
    <globalPolicyRule>
        <name>Sensitive role approvals</name>
        <policyConstraints>
            <modification>
                <operation>add</operation>
            </modification>
        </policyConstraints>
        <policyActions>
            <approval>
                <approverRef oid="00000000-0000-0000-0000-000000000002" type="UserType"/>   <!-- approve by administrator -->
            </approval>
        </policyActions>
        <focusSelector>
            <type>RoleType</type>
            <filter>
                <q:text>riskLevel = "high"</q:text>
            </filter>
        </focusSelector>
    </globalPolicyRule>

</systemConfiguration>
