Notifications

Last modified 14 Mar 2024 12:46 +01:00
Notifications feature
This page is an introduction to Notifications midPoint feature. Please see the feature page for more details.

Introduction

This mechanism is used to notify users about relevant changes in midPoint and/or connected resources. For example, a user (or user’s boss, or the person who requested the operation, the security manager…​) may be notified when one of user’s accounts is created, modified, or removed. Or, when the midPoint user record is created, when the password is changed, or when he has a new work item to process. There are many such situations imaginable.

These are just some examples of the supported kinds of notifications:

  • User notifications are related to midPoint user record, e.g. its creation, modification or removal.

  • Focal object notifications are related to midPoint focal objects such as Organizations, Roles or Services, e.g. its creation, modification or removal.

  • Resource object notifications are related to the objects on resources, e.g. creation, modification, or removal of accounts, groups, etc.

  • Approval notifications are generated when a work item is created or completed, or when a case is started or finished. See also Cases and Approvals.

  • Access certification notifications are sent when a campaign is started, closed or about-to-be-closed, or when a response is requested from a reviewer.

  • Task/acitivity notifications are created when a task or its activity is started or finished. They are useful e.g. to notify in when a recurring task (like a reconciliation or live sync) ends with a failure.

  • Report notifications are sent when a report is created.

  • Custom notifications can be used for any other purposes.

Notifications rely on the following concepts:

  • Event is generated by midPoint, mostly for well-defined situations, but there is also an option to sending custom event.

  • Notifiers are configured in the System Configuration Object. Notifier is part of the so-called notifiaction event handler where events can be filtered. Its task is to prepare a notification message and send it using one of configured transports. There many prepared notifier types to handle the basic situations and many things can be customized. Examples are shown later in this document.

  • Message template (added in version 4.5) is an object containing predefined message. The message template can have multiple localizations and optionally contain attachments. In versions 4.4 and lower, the content of the notifiaction message could be specified only directly in the notifier (which is still an option, but localization is very cumbersome).

  • Transport is a component for sending messages, e.g. via email or SMS. Multiple transports can be configured, even of the same type. Custom transport can be also implemented, if needed.

For instructions how to configure notifiers, filters, and transports please see the Configuration guide.

For a step by step examples with screenshots please refer to Notifications HOWTO.

Some simple examples

Configuration of notifications is currently done within System Configuration Object. Some examples are shown below:

<notificationConfiguration>
    <handler>

       <!-- this event handler sends accounts passwords (when created or changed) via mail to the account owner email address, if known -->
        <accountPasswordNotifier>
            <recipientExpression>
                <script><code>requestee.getEmailAddress()</code></script>
            </recipientExpression>
            <transport>mail</transport>
        </accountPasswordNotifier>

        <!-- this event handler sends accounts passwords (when created or changed) via mail to the account owner email address stored in schema extension attribute otherMailbox, if known -->
        <accountPasswordNotifier>
            <recipientExpression>
                <script><code>basic.getExtensionPropertyValue(requestee, 'http://evolveum.com/my', 'otherMailbox')</code></script>
            </recipientExpression>
            <transport>mail</transport>
        </accountPasswordNotifier>

        <!-- this event handler sends accounts passwords (when created or changed) via SMS to the account owner telephone number, if known -->
        <accountPasswordNotifier>
            <recipientExpression>
                <script><code>requestee.getTelephoneNumber()</code></script>
            </recipientExpression>
            <transport>sms:default</transport>
        </accountPasswordNotifier>

        <!-- this event handler sends *user* passwords (when created or changed) via SMS to the user's telephone number, if known -->
        <userPasswordNotifier>
            <recipientExpression>
                <script><code>requestee.getTelephoneNumber()</code></script>
            </recipientExpression>
            <transport>sms</transport>
        </userPasswordNotifier>

    	<!-- this event handler sends notifications about successful account creation to the account owner mail, if known -->
        <simpleResourceObjectNotifier>
            <status>success</status>		<!-- only successful operations! -->
            <transport>mail</transport>
        </simpleResourceObjectNotifier>

        <simpleUserNotifier>		<!-- sends notification about user operations to the user's mail address -->
            <transport>mail</transport>
        </simpleUserNotifier>

        <simpleTaskNotifier>
            <transport>mail</transport>
        </simpleTaskNotifier>

   </handler>

    <!-- configurations suitable for testing - they redirect all notifications to log files; some more real configurations are show below -->
    <messageTransportConfiguration>
        <mail>
            <name>mail</name>
            <redirectToFile>mail-notifications.log</redirectToFile>
        </mail>
        <sms>
            <name>sms</name>
            <redirectToFile>sms-notifications.log</redirectToFile>
        </sms>
    </messageTransportConfiguration>
</notificationConfiguration>

General Notifier Example

<notificationConfiguration>
...
    <handler>
    	<generalNotifier>
        	<name>Notify system administrator for organization change - general</name>
            <expressionFilter>      <!-- Filter only changes of OrgType objects -->
                <script>
                    <code>
                    import com.evolveum.midpoint.notifications.api.events.ModelEvent
                    import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType

                   (event instanceof ModelEvent &amp;&amp; event.getFocusContext() != null &amp;&amp; OrgType.class.isAssignableFrom(event.getFocusContext().getObjectTypeClass()))
                    </code>
                </script>
            </expressionFilter>
            <recipientExpression>    <!-- Send notifications to iam@localhost -->
                <value>iam@localhost</value>
            </recipientExpression>
            <subjectExpression>      <!-- Subject expression is defined here -->
                <script>
                    <code>
                    tmpObject = 'Organization - GeneralNotifier - '
                    if (event.isSuccess())
                        tmpText = "[IDM] SUCCESS: " + tmpObject + event?.getChangeType() + " operation succeeded"
                    else if (event.isFailure())
                        tmpText = "[IDM] ERROR: " + tmpObject + event?.getChangeType() + " operation failed"
                    else  tmpText = "[IDM] IN PROGRESS: " + tmpObject + event?.getChangeType() + " operation in progress"
                    return tmpText
                </code>
               </script>
            </subjectExpression>
            <bodyExpression>         <!-- Body expression is defined here -->
                <script>
                   <code>            <!-- Some imports needed to have all necessary objects and variables -->
                   import com.evolveum.midpoint.notifications.impl.notifiers.GeneralNotifier;
                   import com.evolveum.midpoint.notifications.api.events.ModelEvent;
                   import com.evolveum.midpoint.prism.delta.ObjectDelta;
                   delta = ObjectDelta.summarize(((ModelEvent) event).getFocusDeltas());
                   hiddenPaths = GeneralNotifier.getAuxiliaryPaths()
                   body = ''
                   attemptedTo = event.isSuccess() ? "" : "(attempted to be) ";
                   if (delta.isAdd()) {
                       body = "The object was " + attemptedTo + "created with the following data:\n";
                       body += textFormatter.formatObject(delta.getObjectToAdd(), hiddenPaths, false);
                   } else if (delta.isModify()) {
                       body = "The object was " + attemptedTo + "modified. Modified attributes are:\n";
                       body += textFormatter.formatObjectModificationDelta(delta, hiddenPaths, false);
                   } else if (delta.isDelete()) {
                       body = "The object was " + attemptedTo + "removed.\n\n";
                   }
                   </code>
               </script>
           </bodyExpression>
           <transport>mail</transport>
       </generalNotifier>
   </handler>
   <!-- configurations suitable for testing - they redirect all notifications to log files; some more real configurations are show below -->
    <messageTransportConfiguration>
        <mail>
            <name>mail</name>
            <redirectToFile>mail-notifications.log</redirectToFile>
        </mail>
        <sms>
            <name>sms</name>
            <redirectToFile>sms-notifications.log</redirectToFile>
        </sms>
    </messageTransportConfiguration>
</notificationConfiguration>

Another General Notifier Example

The description of this example can be found on the next page - General notification - role assignment example.

<notificationConfiguration xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
    <handler>
        <generalNotifier>
            <name>Notify user about new role added - general</name>
            <expressionFilter>
                <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                    <code>
                        import com.evolveum.midpoint.notifications.api.events.ModelEvent
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType
                        import com.evolveum.midpoint.prism.delta.ObjectDelta
                        import com.evolveum.midpoint.prism.path.ItemPath
                        import com.evolveum.midpoint.prism.PrismValue

                        if (
                        event instanceof ModelEvent
                                && event.getFocusContext().getObjectTypeClass().getName().equals(UserType.getName())
                                && !event.isOperationType(EventOperationType.DELETE)
                        ) {
                            for (ObjectDelta delta : event.getFocusDeltas()) {
                                if (delta.isAdd()) {
                                    for (AssignmentType localObject in delta.getObjectToAdd().asObjectable().assignment) {
                                        if (localObject.getTargetRef() == null) continue;
                                        if (localObject.getTargetRef().getType().localPart.equals("RoleType")) {
                                            if (midpoint.getObject(RoleType, localObject.getTargetRef().getOid(),midpoint.schemaHelper.operationOptionsBuilder.raw().build()).getIdentifier().equals("notification")) return true;
                                        }
                                    }
                                } else if (delta.isModify()) {
                                    for (ItemPath paths : delta.getModifiedItems()) {
                                        if (AssignmentHolderType.F_ASSIGNMENT.equivalent(paths)) {
                                            for (PrismValue values : delta.getNewValuesFor(paths)) {
                                                if (values.getRealClass().getName().equals(AssignmentType.getName())) {
                                                    AssignmentType localObject = values.getRealValue();
                                                    if (localObject.getTargetRef() == null) continue;
                                                    if (localObject.getTargetRef().getType().localPart.equals("RoleType")) {
                                                        if (midpoint.getObject(RoleType, localObject.getTargetRef().getOid(),midpoint.schemaHelper.operationOptionsBuilder.raw().build()).getIdentifier().equals("notification")) return true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    </code>
                </script>
            </expressionFilter>
            <recipientExpression>
                <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                    <code>
                        if (
                        event.requesteeObject.emailAddress != null
                                && event.requesteeObject.emailAddress != ""
                        ) {
                            return event.requesteeObject.emailAddress
                        } else {
                            return "iam@localhost"
                        }
                    </code>
                </script>
            </recipientExpression>
            <subjectExpression>
                <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                    <code>
                        if (
                        event.requesteeObject.emailAddress != null
                                && event.requesteeObject.emailAddress != ""
                        ) {
                            return "[IDM] New Role assignment notification"
                        } else {
                            return "[IDM] unknown address for notification"
                        }
                    </code>
                </script>
            </subjectExpression>
            <bodyExpression>
                <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                    <code>
                        import com.evolveum.midpoint.notifications.api.events.ModelEvent
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType
                        import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType
                        import com.evolveum.midpoint.prism.delta.ObjectDelta
                        import com.evolveum.midpoint.prism.path.ItemPath
                        import com.evolveum.midpoint.prism.PrismValue

                        String body = "";

                        if (
                        event instanceof ModelEvent
                                && event.getFocusContext().getObjectTypeClass().getName().equals(UserType.getName())
                                && !event.isOperationType(EventOperationType.DELETE)
                        ) {
                            for (ObjectDelta delta : event.getFocusDeltas()) {
                                if (delta.isAdd()) {
                                    for (AssignmentType localObject in delta.getObjectToAdd().asObjectable().assignment) {
                                        if (localObject.getTargetRef() == null) continue;
                                        if (localObject.getTargetRef().getType().localPart.equals("RoleType")) {
                                            if (midpoint.getObject(RoleType, localObject.getTargetRef().getOid(),midpoint.schemaHelper.operationOptionsBuilder.raw().build()).getIdentifier().equals("notification")) {
                                                body += midpoint.getObject(RoleType, localObject.getTargetRef().getOid(),midpoint.schemaHelper.operationOptionsBuilder.raw().build()).getDescription() + "\n\n";
                                            }
                                        }
                                    }
                                } else if (delta.isModify()) {
                                    for (ItemPath paths : delta.getModifiedItems()) {
                                        if (AssignmentHolderType.F_ASSIGNMENT.equivalent(paths)) {
                                            for (PrismValue values : delta.getNewValuesFor(paths)) {
                                                if (values.getRealClass().getName().equals(AssignmentType.getName())) {
                                                    AssignmentType localObject = values.getRealValue();
                                                    if (localObject.getTargetRef() == null) continue;
                                                    if (localObject.getTargetRef().getType().localPart.equals("RoleType")) {
                                                        if (midpoint.getObject(RoleType, localObject.getTargetRef().getOid(),midpoint.schemaHelper.operationOptionsBuilder.raw().build()).getIdentifier().equals("notification")) {
                                                            body += midpoint.getObject(RoleType, localObject.getTargetRef().getOid(),midpoint.schemaHelper.operationOptionsBuilder.raw().build()).getDescription() + "\n\n";
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (!body.isEmpty()) {
                            if (event?.requesteeDisplayName == null) {
                                boolean nameContructed = false
                                String tmpName = ""
                                if (event?.requesteeObject.getGivenName() != null) {
                                    tmpName += event?.requesteeObject.givenName.toString();
                                    nameContructed = true
                                }
                                if (event?.requesteeObject.getFamilyName() != null) {
                                    if (nameContructed) tmpName += " "
                                    tmpName += event?.requesteeObject.familyName.toString();
                                    nameContructed = true
                                }
                                if (nameContructed) {
                                    body = "Dear " + tmpName +
                                            " (" + event.requesteeObject.name.toString() + ")" +
                                            ",\n\n" + body + "\n\n Best regards,\n\n IDM admin team"
                                } else {
                                    body = "Dear " +
                                            event.requesteeObject.name.toString() +
                                            ",\n\n" + body + "\n\n Best regards,\n\n IDM admin team"
                                }
                            } else {
                                body = "Dear " + event?.requesteeDisplayName.toString() +
                                        " (" + event.requesteeObject.name.toString() + ")" +
                                        ",\n\n" + body + "\nBest regards,\n\n IDM admin team";
                            }

                            if (
                            event.requesteeObject.emailAddress == null
                                    || event.requesteeObject.emailAddress == ""
                            ) {
                                body = "Notification for the user : " + event.requesteeObject.name.toString() + " / " + event.requesteeObject.oid +
                                        "\nSubject: [IDM] New Role assignment notification\n" +
                                        "\nThe e-mail address is not know at this moment" +
                                        "\n - - - - - - -\n" + body
                            }

                            return body
                        }
                    </code>
                </script>
            </bodyExpression>
            <transport>mail</transport>
        </generalNotifier>
    </handler>
    <messageTransportConfiguration>
        <mail>
            <name>mail</name>
            <redirectToFile>/opt/midpoint/var/log/mails.log</redirectToFile>
        </mail>
    </messageTransportConfiguration>
</notificationConfiguration>

When something potentially of interest occurs, an event is generated. This event is then processed by one or more event handlers, as prescribed in <notificationConfiguration> section.

There are the following kinds of event handlers.

Notifiers

A notifier is a module that transforms an event to zero, one or more notifications. Examples are:

Notifier Type Description

simpleUserNotifier

User notification

Generates notifications about user records.

simpleResourceObjectNotifier

Resource object notification

Generates notifications about resource objects (e.g. accounts).

userPasswordNotifier

User notification

Generates notifications about user passwords.

accountPasswordNotifier

Account notification

Generates notifications about account passwords.

simpleWorkflowNotifier

Workflow notification

Generates notifications about start/completion of work items (i.e. user tasks) and about start/completion of workflow process instances.

simpleCampaignNotifier, simpleCampaignStageNotifier

Certification notification

Generates notifications about certification campaigns.

simpleTaskNotifier

Task notification

Generates notifications about tasks.

generalNotifier

This is a general purpose notifier that is driven by expressions, which transform an event into a notification.

Filters

A filter is a component that does not generate notifications, but passes through (or filters out) defined subsets of notifications. There are currently the following kinds of filters:

Filter Description

category

passes one or more defined categories of events: resource object-related events ("resourceObjectEvent"), user-related events ("modelEvent"), work item-related events ("workItemEvent"), workflow-related events ("workflowProcessEvent"), or any workflow-related events ("workflowEvent" - currently this means "either workItemEvent or workflowProcessEvent")

status

passes or filters events based on their status: success, alsoSuccess, failure, onlyFailure, inProgress (with a bit different sets of acceptable values and their semantics for account/user/workflow events)

operation

passes or filters events based on the kind of operation that was executed or attempted to: add, modify, or delete

expression

a generic filter that evaluates an expression and passes/filters event based on the result

objectKind

passes or filters events based on the kind of resource object they deal with (account, entitlement, generic)

objectIntent

passes or filters events based on the intent of resource object they deal with

A filter can be specified as part of a notifier - in that case it defines which classes of events get processed by that notifier.

Mail attachments

Since 4.0
This functionality is available since version 4.0.

We can define attachments for mail. We have two choices, adding attributes to the xml or writing of script.

Example of attachments
<notificationConfiguration xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
...
    <handler>
        <generalNotifier>
        ...
           <attachment>
           		<contentType>image/png</contentType>
                <contentFromFile>/home/user/example.png</contentFromFile>
           </attachment>
           <attachment>
                <contentType>text/plain</contentType>
                <content>Hello world!</content>
                <fileName>hello_world.txt</fileName>
           </attachment>
           <attachment>
                <contentType>image/jpeg</contentType>
                <content xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:base64Binary">iVBORw0KGgoAAAANSUhEUgAAATUAAABLCAMAAAAmnuAzAAAAaVBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8G612AAAAInRSTlMAwIBA8NBwoOBgELAgkOgw+1Cc3B/3PK9Xh6nWyvO5Uy1z3+GvZwAAB4RJREFUeNrsmO2W2iAQhl8+EwIkTWJ0rbqn5f4vslVTOwimlWN7utbn52wCzMMwWcSLf4s1XtxPixf3c8CL+5nw4nVC/w6f8eJ+GF68rMUYtgSKUcjDCAYfCGcq4zDDwxIoZkSeQOD4OBhpuZXmMdbW/4k1Iz03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ohIvw14l9giwzHeMoXI+dXnkp3FKwWwpqxJ7p1/JUUbMf4RY8dh0yfYEFqARgQcWurGG1FYYUsO1Qi4DKbpN4kKV1qhOBYSiYBLy0wj8BP6laTXpLfQSfeplR56zHCgvVzpGis95QjssKhSxhBp6gzxETdwBLwQdogGBHwo7DGFt6N4abBLmEe9EAIfIQz84aVYHyQ8a0+ARuC3aRMEwkuxPoX2jMBv8zVsAv6AtkUgsPEDb0ZOzzalzlUAAAAASUVORK5CYII</content>
                <fileName>evolveum_logo.jpg</fileName>
           </attachment>
           <attachmentExpression>
                <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                    <code>
                       import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationMessageAttachmentType;

                       NotificationMessageAttachmentType attachment = new NotificationMessageAttachmentType();
                       attachment.setContentType("text/html");
                       attachment.setContent("&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt;Hello World!&lt;/body&gt;&lt;/html&gt;");
                       attachment.setFileName("hello_world.html");
                       return attachment;
                    </code>
                </script>
            </attachmentExpression>
            <transport>mail</transport>
        </generalNotifier>
    </handler>
</notificationConfiguration>

Attributes

If we use attachment, then we have two choices, insert the content to the xml or use file.

Name Required Description

contentType

true

Content type for the attachment, e.g. image/png or text/html.

content

choice

Content of the attachment.

contentFromFile

choice

Path of the file that provides the content for this attachment.

fileName

false

File name for the attachment. E.g. in the case of the mail transport it should be put into Content-Disposition header field. If omitted and if contentFromFile is used, it is derived from the name of that file. If it omitted with used content, it’s value is 'attachment'.

contentId

false

Value of the Content-ID header of MIME body part for this attachment. This can be used to reference image attachments from your email HTML. E.g. <c:contentId><customerLogo></c:contentId> is referenced in HTML as <img src="cid:customerLogo"/>

Executing the handlers

When an event is created, all the handlers defined at the level of <notificationConfiguration> are executed.

Some more advanced examples:

TODO

For instructions how to configure notifiers, filters, and transports please see administrator’s guide, the page also documents the variables that can be used in notification expressions.

To send HTML emails, set <contentType>text/html; charset=UTF-8</contentType> and put to <bodyExpression> escaped HTML in single quote.

Custom notifications

These are briefly described in the Sending custom notifications HOWTO.

Was this page helpful?
YES NO
Thanks for your feedback