Search in sources :

Example 16 with Notifier

use of org.wso2.carbon.apimgt.impl.notifier.Notifier in project carbon-apimgt by wso2.

the class TokenRevocationNotifierImpl method sendMessageOnRealtime.

/**
 * Method to publish the revoked token on to the realtime message broker
 *
 * @param revokedToken requested revoked token
 * @param properties realtime notifier properties read from the config
 */
@Override
public void sendMessageOnRealtime(String revokedToken, Properties properties) {
    // Variables related to Realtime Notifier
    String realtimeNotifierTTL = realTimeNotifierProperties.getProperty("ttl", DEFAULT_TTL);
    long expiryTimeForJWT = Long.parseLong(properties.getProperty("expiryTime"));
    String eventId = properties.getProperty(APIConstants.NotificationEvent.EVENT_ID);
    String tokenType = properties.getProperty(APIConstants.NotificationEvent.TOKEN_TYPE);
    int tenantId = (int) properties.get(APIConstants.NotificationEvent.TENANT_ID);
    Object[] objects = new Object[] { eventId, revokedToken, realtimeNotifierTTL, expiryTimeForJWT, tokenType, tenantId };
    EventPublisherEvent tokenRevocationEvent = new EventPublisherEvent(APIConstants.TOKEN_REVOCATION_STREAM_ID, System.currentTimeMillis(), objects);
    APIUtil.publishEvent(EventPublisherType.TOKEN_REVOCATION, tokenRevocationEvent, tokenRevocationEvent.toString());
}
Also used : EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent)

Aggregations

Properties (java.util.Properties)6 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 NotificationException (org.wso2.carbon.apimgt.impl.notification.exception.NotificationException)4 APIUtil (org.wso2.carbon.apimgt.impl.utils.APIUtil)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 JSONArray (org.json.simple.JSONArray)2 JSONObject (org.json.simple.JSONObject)2 JSONParser (org.json.simple.parser.JSONParser)2 Before (org.junit.Before)2 APIManagerConfiguration (org.wso2.carbon.apimgt.impl.APIManagerConfiguration)2 Notifier (org.wso2.carbon.apimgt.impl.notifier.Notifier)2 CompilerPlugin (org.ballerinalang.compiler.plugins.CompilerPlugin)1 AnnotationAttachmentNode (org.ballerinalang.model.tree.AnnotationAttachmentNode)1 Matchers.anyString (org.mockito.Matchers.anyString)1 BLangAnnotationAttachment (org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1