Skip to content

Commit 0077b45

Browse files
authored
Merge pull request #849 from oracle-devrel/oig-user-lifecycle-notification
Add a User Lifecycle Event Notification event handler sample for OIG
2 parents ab7b528 + 78dacb8 commit 0077b45

File tree

8 files changed

+542
-0
lines changed

8 files changed

+542
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2024 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# User Lifecycle Event Notification Event Handler
2+
3+
This asset contains the code and deployment items for an event handler that sends notifications during user lifecycle events. The targeted event is configured during deployment. It uses standard OIG APIs to handle email composition and dispatch (tcEmailNotificationUtil).
4+
5+
Developed on and compatible with OIG 11g R2 PS3 and above.
6+
7+
Review Date: 22.02.2024
8+
9+
# When to use this asset?
10+
11+
When there's a need to provide or demonstrate the functionality described above or something similar, which can be adapted from the provided code.
12+
13+
Note that OIG already provides native notification capabilities for most (but not all) user lifecycle events. Only use this approach if the out of the box functionality proves insufficient.
14+
15+
# How to use this asset?
16+
17+
## Building and deployment
18+
19+
Here's a short build and deployment checklist:
20+
21+
1. Import any additional artifacts using deployment manager, such as the `User_Lifecycle_Event_Notification_Template_And_Lookup.xml` file.
22+
2. Generate a jar file containing the sample code.
23+
3. Copy the jar file under the `lib` directory of the provided `plugin` folder structure and create a zip file with the following root structure:
24+
- lib
25+
- META-INF
26+
- plugin.xml
27+
4. Configure the type of user lifecycle event you want to send notifications for, by editing the value of the `operation` parameter inside `META-INF/EventHandlers.xml`. The provided sample file is configured to target user disable lifecycle events.
28+
5. Log into the OIM administration console and adjust the event handler functionality as needed by editing the values stored in the `Lookup.Sample.LifecycleNotification` Lookup, which was imported during step 1.
29+
6. Use the OIM administration console to also adjust the `User Lifecycle Event Notification` notification template content to your liking, if needed.
30+
7. Register the plugin zip file to an OIG environment using OIG's plugin registration utility script.
31+
32+
Please see the useful link below for detailed build and deployment steps.
33+
34+
## How do I execute the event handler?
35+
36+
Once registered the code will be run automatically when the configured lifecycle events occur in the system.
37+
38+
# Useful Links
39+
40+
[Oracle Identity Governance developer's guide - Developing plugins](https://docs.oracle.com/en/middleware/idm/identity-governance/12.2.1.4/omdev/developing-plug-ins.html#GUID-7F4EE3EA-076C-45DB-B13D-2905AB5AF6CB)
41+
42+
# License
43+
44+
Copyright (c) 2024 Oracle and/or its affiliates.
45+
46+
Licensed under the Universal Permissive License (UPL), Version 1.0.
47+
48+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version = '1.0' encoding = 'UTF-8'?>
2+
<xl-ddm-data version="12.2.1.4.0" user="XELSYSADM" database="" exported-date="1708423976085" description="User_Lifecycle_Event_Notification_Template_And_Lookup.xml"><Lookup repo-type="RDBMS" name="Lookup.Sample.LifecycleNotification" subtype="Lookup"><LKU_UPDATE>1708421725000</LKU_UPDATE><LKU_TYPE>l</LKU_TYPE><LKU_MEANING>Lookup.Sample.LifecycleNotification</LKU_MEANING><LookupValue repo-type="RDBMS" id="LKV2505"><LKV_UPDATE>1708421725000</LKV_UPDATE><LKV_ENCODED>Template Name</LKV_ENCODED><LKV_LANGUAGE>en</LKV_LANGUAGE><LKV_COUNTRY>US</LKV_COUNTRY><LKV_DISABLED>0</LKV_DISABLED><LKV_DECODED>User Lifecycle Event Notification</LKV_DECODED></LookupValue><LookupValue repo-type="RDBMS" id="LKV2506"><LKV_UPDATE>1708421725000</LKV_UPDATE><LKV_ENCODED>Recipient Emails</LKV_ENCODED><LKV_LANGUAGE>en</LKV_LANGUAGE><LKV_COUNTRY>US</LKV_COUNTRY><LKV_DISABLED>0</LKV_DISABLED><LKV_DECODED>[email protected],[email protected]</LKV_DECODED></LookupValue><LookupValue repo-type="RDBMS" id="LKV2507"><LKV_UPDATE>1708421725000</LKV_UPDATE><LKV_ENCODED>Self Recipient</LKV_ENCODED><LKV_LANGUAGE>en</LKV_LANGUAGE><LKV_COUNTRY>US</LKV_COUNTRY><LKV_DISABLED>0</LKV_DISABLED><LKV_DECODED>True</LKV_DECODED></LookupValue><LookupValue repo-type="RDBMS" id="LKV2508"><LKV_UPDATE>1708421725000</LKV_UPDATE><LKV_ENCODED>User State</LKV_ENCODED><LKV_LANGUAGE>en</LKV_LANGUAGE><LKV_COUNTRY>US</LKV_COUNTRY><LKV_DISABLED>0</LKV_DISABLED><LKV_DECODED>DISABLED</LKV_DECODED></LookupValue></Lookup><NOTIFICATIONTEMPLATE repo-type="RDBMS" name="User Lifecycle Event Notification"><CREATEUSER>1</CREATEUSER><SNMPSUPPORTED>n</SNMPSUPPORTED><CREATIONDATE>1708420930597</CREATIONDATE><DATALEVEL>0</DATALEVEL><DESCRIPTION>User Lifecycle Event Notification</DESCRIPTION><EVENTNAME>RequestStatusChange</EVENTNAME><LASTUSER>1</LASTUSER><LASTUPDATED>1708420930597</LASTUPDATED><LOCALTEMPLATE repo-type="RDBMS" id="LOCALTEMPLATE521"><CREATEUSER>1</CREATEUSER><SHORTMESSAGE>Lifecyle Event Notification</SHORTMESSAGE><CONTENTTYPE>text/plain</CONTENTTYPE><CREATIONDATE>1708420931028</CREATIONDATE><LOCALE>en_US</LOCALE><DATALEVEL>0</DATALEVEL><ENCODING>ISO-8859-1</ENCODING><SUBJECT>Lifecyle Event Notification</SUBJECT><LONGMESSAGE>Hi $display_name,
3+
4+
Your account has recently been $user_state in OIM. Please contact an administrator if you think this action is unjustified.
5+
6+
Kind regards,
7+
The OIM admin team</LONGMESSAGE><LASTUSER>1</LASTUSER><LASTUPDATED>1708420931028</LASTUPDATED></LOCALTEMPLATE></NOTIFICATIONTEMPLATE></xl-ddm-data>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<eventhandlers xmlns="http://www.oracle.com/schema/oim/platform/kernel"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.oracle.com/schema/oim/platform/kernel
5+
orchestration-handlers.xsd">
6+
<!-- Custom postprocess event handlers -->
7+
<action-handler
8+
class="com.oracle.sample.UserLifecycleEventNotification"
9+
entity-type="User"
10+
operation="DISABLE"
11+
name="UserLifecyleEventNotification"
12+
stage="postprocess"
13+
order="999"
14+
sync="TRUE"/>
15+
</eventhandlers>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Place the plugin jar file in this directory before creating the plugin zip file.
2+
3+
Note the zip file structure must contain:
4+
- lib
5+
- META-INF
6+
- plugin.xml
7+
8+
Do NOT create an archive of the entire plugin directory, only of its contents, as specified above.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<oimplugins>
3+
<plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
4+
<plugin pluginclass="com.oracle.sample.UserLifecycleEventNotification"
5+
version="1.0"
6+
name="UserLifecycleEventNotification">
7+
</plugin>
8+
</plugins>
9+
</oimplugins>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. DO NOT
3+
* ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*******************************************************************************/
41+
42+
package com.oracle.sample;
43+
44+
public class EventHandlerException extends Exception {
45+
public EventHandlerException(String errorMessage) {
46+
super(errorMessage);
47+
}
48+
}

0 commit comments

Comments
 (0)