Skip to main content
Version: 7.2402.x.x RR

IdmUserNotificationState

To send notifications with nevisIDM, configure a ScriptState. This AuthState gathers the required data from the session and sends the notification using the nevisIDM REST service. The notification template can be configured in nevisIDM.

  • For more details on the configuration of the notification template, see the chapter nevisIDM notifications.
  • For more information on how to create a ScriptState, see the chapter ScriptState in the nevisAuth Reference Guide.

Be sure to always use the script shown in the code block below. Do not use the built in the ch.nevis.idm.authstate.IdmUserNotifyState because it is not capable of sending additional login information in the notification.

user_notification.groovy
import ch.nevis.idm.client.IdmRestClient
import ch.nevis.idm.client.IdmRestClientFactory

IdmRestClient rest = IdmRestClientFactory.get(parameters)

// collect data from session
String clientId = session.get('ch.adnovum.nevisidm.user.clientExtId')
String extId = session.get('ch.adnovum.nevisidm.user.extId')

String date = session.get('ch.nevis.nevisadapt.observation.date')
String city = session.get('ch.nevis.nevisadapt.observation.city')
String countryCode = session.get('ch.nevis.nevisadapt.observation.countryCode')
String country = session.get('ch.nevis.nevisadapt.observation.country')
String latitude = session.get('ch.nevis.nevisadapt.observation.latitude')
String longitude = session.get('ch.nevis.nevisadapt.observation.longitude')
String ipAddress = session.get('ch.nevis.nevisadapt.observation.ip')
String os = session.get('ch.nevis.nevisadapt.observation.os')
String browser = session.get('ch.nevis.nevisadapt.observation.browser')
String device = session.get('ch.nevis.nevisadapt.observation.device')

String notificationBaseUrl = '${base_url}/nevisidm/api/notification/v1/'

def body = '{"clientExtId":"'+clientId+'","userExtId":"'+extId+'","notificationType":"userNotification17","sendingMethod":["Email"],"async":false,"placeholders":{"en":{},"de":{},"languageIndependent":{"EXTERNAL_CITY":"'+city+'","EXTERNAL_COUNTRY_CODE":"'+countryCode+'","EXTERNAL_COUNTRY":"'+country+'","EXTERNAL_LATITUDE":"'+latitude+'","EXTERNAL_LONGITUDE":"'+longitude+'","EXTERNAL_IP_ADDRESS":"'+ipAddress+'","EXTERNAL_DEVICE":"'+device+'","EXTERNAL_OS":"'+os+'","EXTERNAL_BROWSER":"'+browser+'","EXTERNAL_DATE":"'+date+'"}}}'

// send user notification with nevisIDM
String result = rest.post(notificationBaseUrl, body)
LOG.debug("response: " + result)

Example configuration
<AuthState class="ch.nevis.esauth.auth.states.scripting.ScriptState" final="false" name="sso_authstate-adapt_IdmUserNotification">
<ResultCond name="clientNotFound" next="sso_Authentication_Failed"/>
<ResultCond name="failed" next="sso_Check_Done"/>
<ResultCond name="ok" next="sso_Check_Done"/>
<Response value="AUTH_DONE">
<Gui name="auth_User_Notification"/>
</Response>
<property name="script" value="file:///var/opt/nevisauth/auth/conf/authstate-adapt_IdmUserNotification.groovy"/>
</AuthState>