use of org.wso2.carbon.identity.event.services.IdentityEventService in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2TokenUtil method triggerEvent.
private static void triggerEvent(String eventName, HashMap<String, Object> properties) throws IdentityOAuth2Exception {
try {
if (StringUtils.isNotBlank(eventName)) {
Event requestObjectPersistanceEvent = new Event(eventName, properties);
IdentityEventService identityEventService = OpenIDConnectServiceComponentHolder.getIdentityEventService();
if (identityEventService != null) {
if (log.isDebugEnabled()) {
log.debug("The event: " + eventName + " triggered.");
}
identityEventService.handleEvent(requestObjectPersistanceEvent);
}
}
} catch (IdentityEventException e) {
String message = "Error while triggering the event: " + eventName;
log.error(message, e);
throw new IdentityOAuth2Exception(message, e);
}
}
use of org.wso2.carbon.identity.event.services.IdentityEventService in project identity-governance by wso2-extensions.
the class IdentityMgtEventListenerTest method mockHandleEvent.
private void mockHandleEvent() throws Exception {
identityMgtEventListener = spy(IdentityMgtEventListener.class);
userStoreManager = Mockito.mock(UserStoreManager.class);
realmConfiguration = Mockito.mock(RealmConfiguration.class);
tenantManager = Mockito.mock(TenantManager.class);
when(realmService.getTenantManager()).thenReturn(tenantManager);
when(tenantManager.getDomain(SAMPLE_TENANT_ID)).thenReturn(SAMPLE_TENANT_DOMAIN);
TestUtils.startTenantFlow(SAMPLE_TENANT_DOMAIN);
when(userStoreManager.getTenantId()).thenReturn(SAMPLE_TENANT_ID);
when(userStoreManager.getRealmConfiguration()).thenReturn(realmConfiguration);
when(realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME)).thenReturn("PRIMARY");
Map<String, Object> properties = new HashMap<>();
Event identityMgtEvent = new Event("sampleEvent", properties);
doNothing().when(identityEventService).handleEvent(any(Event.class));
identityEventService.handleEvent(identityMgtEvent);
}
Aggregations