App Notification URL endpoint
In the case of certain events, such as an update to the tenantRestUrl
by the product, this is the URL to which AMS will send the notification to the app. AMS will call this endpoint and send the request body containing the notification data.
Service URL
<app-base-url><app-notification-url>
These URLs are registered with AMS when creating an app.
Request Method
POST
Request Header
Authorization: Bearer <JWT>
Content-Type=application/json
JWT claims
In the case where it is AMS making the request to the App, the key and value pairs bear the following meanings:
Key | Value Definition | Context |
---|---|---|
iss
|
The issuer of the token. | The App's Token Key. |
sub
|
The subject of the token. | Set to the app's associated product uuid. |
aud
|
The audience of the token. | The App Provider Token Key. |
exp
|
The date and time the token will expire, expressed as a Unix timestamp. Must be after the current date/time. | Set to 60 seconds after the JWT was created. |
iat
|
The date and time the JWT was issued, expressed as a Unix timestamp. | Set to the current time. |
jti
|
The unique identifier for the JWT token | Set to a random UUID |
Sample JWT Payload
Below is an example JWT payload that AMS uses to call the application notification endpoint:
{
"iss": "ams",
"sub": null,
"aud": "03a22eb2-537b-471c-bf2b-2055e2f71618",
"exp": 1507072485000,
"iat": 1506964485000,
"jti": null
}
Sample Request Body
{
"eventId": "2228f731-7b81-4d5b-a159-e0e3a8b9963c",
"eventType": "TENANT_REST_URL_CHANGE",
"data": {
"notificationType": "TENANT_REST_URL_CHANGE",
"notificationData": {
"tenantId": "312022",
"tenantRestUrl": "http://www.tru1.com/test",
"productUuid": "c9ade037-9b06-4b9c-85dd-473adc5951c8"
}
}
}
Sample Response in case of success
Any 200 status code response is appropriate.
Sample Code
@RequestMapping(value="/notification", method=RequestMethod.POST)
public ResponseEntity<String> receiveNotification(@RequestBody NotificationEventWrapper notificationEventWrapper){
if(notificationEventWrapper == null){
throw new IllegalArgumentException("Empty notification");
}
//convert and persist the notification for future use
NotificationEntity notificationEntity = new NotificationEntity();
notificationEntity.setUuid(UUID.randomUUID().toString());
notificationEntity.setExternalTenantId(notificationEventWrapper.getData().getNotificationData().getTenantId());
notificationEntity.setTenantRestUrl(notificationEventWrapper.getData().getNotificationData().getTenantRestUrl());
notificationEntity.setProductUuid(notificationEventWrapper.getData().getNotificationData().getProductUuid());
notificationService.addEntity(notificationEntity);
return new ResponseEntity(notificationEntity.getUuid(), HttpStatus.OK);
}